From daed1786eecf4bbee7b4ffd17f3b967988f09cae Mon Sep 17 00:00:00 2001 From: Nathan Pietrantonio Date: Fri, 10 Jan 2025 11:42:49 -0800 Subject: [PATCH 1/5] Change App and main to jsx --- client/index.html | 2 +- client/src/{App.tsx => App.jsx} | 1 - client/src/main.jsx | 32 ++++++++++++++++++++++++++++++++ client/src/main.tsx | 20 -------------------- 4 files changed, 33 insertions(+), 22 deletions(-) rename client/src/{App.tsx => App.jsx} (97%) create mode 100644 client/src/main.jsx delete mode 100644 client/src/main.tsx diff --git a/client/index.html b/client/index.html index e4c1f3d..96ebf54 100644 --- a/client/index.html +++ b/client/index.html @@ -17,7 +17,7 @@
diff --git a/client/src/App.tsx b/client/src/App.jsx similarity index 97% rename from client/src/App.tsx rename to client/src/App.jsx index fa48435..be8d87c 100644 --- a/client/src/App.tsx +++ b/client/src/App.jsx @@ -9,7 +9,6 @@ import { import { Admin } from "./components/admin/Admin"; import { CatchAll } from "./components/CatchAll"; import { Dashboard } from "./components/dashboard/Dashboard"; -//@ts-expect-error - Allow import of JSX page into App.tsx base import { Playground } from "./components/playground/Playground"; import { Login } from "./components/login/Login"; import { ProtectedRoute } from "./components/ProtectedRoute"; diff --git a/client/src/main.jsx b/client/src/main.jsx new file mode 100644 index 0000000..fe07186 --- /dev/null +++ b/client/src/main.jsx @@ -0,0 +1,32 @@ +import { StrictMode } from "react"; +import { createRoot } from "react-dom/client"; + +import { ChakraProvider, extendTheme } from "@chakra-ui/react"; + +import App from "./App.jsx"; + +const colors = { + brand: {}, +}; + +const theme = extendTheme({ colors }); + +// For TSX +// createRoot(document.getElementById("root")!).render( +// +// +// +// +// +// ); + +const root = document.getElementById('root'); +if (root) { + createRoot(root).render( + + + + + + ); +} diff --git a/client/src/main.tsx b/client/src/main.tsx deleted file mode 100644 index 4e66530..0000000 --- a/client/src/main.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { StrictMode } from "react"; -import { createRoot } from "react-dom/client"; - -import { ChakraProvider, extendTheme } from "@chakra-ui/react"; - -import App from "./App.tsx"; - -const colors = { - brand: {}, -}; - -const theme = extendTheme({ colors }); - -createRoot(document.getElementById("root")!).render( - - - - - -); From 8d68decb516d85be2813e07b052eab31f9505396 Mon Sep 17 00:00:00 2001 From: Nathan Pietrantonio Date: Fri, 10 Jan 2025 13:14:43 -0800 Subject: [PATCH 2/5] Change main pages to jsx --- client/src/components/login/{Login.tsx => Login.jsx} | 8 +++----- client/src/components/signup/{Signup.tsx => Signup.jsx} | 6 ++---- 2 files changed, 5 insertions(+), 9 deletions(-) rename client/src/components/login/{Login.tsx => Login.jsx} (96%) rename client/src/components/signup/{Signup.tsx => Signup.jsx} (96%) diff --git a/client/src/components/login/Login.tsx b/client/src/components/login/Login.jsx similarity index 96% rename from client/src/components/login/Login.tsx rename to client/src/components/login/Login.jsx index b8eabe3..b1844b1 100644 --- a/client/src/components/login/Login.tsx +++ b/client/src/components/login/Login.jsx @@ -29,8 +29,6 @@ const signinSchema = z.object({ password: z.string().min(6, "Password must be at least 6 characters long"), }); -type SigninFormValues = z.infer; - export const Login = () => { const navigate = useNavigate(); const toast = useToast(); @@ -42,13 +40,13 @@ export const Login = () => { register, handleSubmit, formState: { errors }, - } = useForm({ + } = useForm({ resolver: zodResolver(signinSchema), mode: "onBlur", }); const toastLoginError = useCallback( - (msg: string) => { + (msg) => { toast({ title: "An error occurred while signing in", description: msg, @@ -59,7 +57,7 @@ export const Login = () => { [toast] ); - const handleLogin = async (data: SigninFormValues) => { + const handleLogin = async (data) => { try { await login({ email: data.email, diff --git a/client/src/components/signup/Signup.tsx b/client/src/components/signup/Signup.jsx similarity index 96% rename from client/src/components/signup/Signup.tsx rename to client/src/components/signup/Signup.jsx index 751889d..8127e6f 100644 --- a/client/src/components/signup/Signup.tsx +++ b/client/src/components/signup/Signup.jsx @@ -29,8 +29,6 @@ const signupSchema = z.object({ password: z.string().min(6, "Password must be at least 6 characters long"), }); -type SignupFormValues = z.infer; - export const Signup = () => { const navigate = useNavigate(); const toast = useToast(); @@ -41,12 +39,12 @@ export const Signup = () => { register, handleSubmit, formState: { errors }, - } = useForm({ + } = useForm({ resolver: zodResolver(signupSchema), mode: "onBlur", }); - const handleSignup = async (data: SignupFormValues) => { + const handleSignup = async (data) => { try { const user = await signup({ email: data.email, From 58d6ace3531106e8a9fe9e4e976711cc83ee5d6b Mon Sep 17 00:00:00 2001 From: Nathan Pietrantonio Date: Mon, 13 Jan 2025 15:54:37 -0800 Subject: [PATCH 3/5] Setup Sign In Setup signin for sprint 3 --- client/src/components/signup/Signup.jsx | 3 +++ client/src/contexts/AuthContext.tsx | 6 +++++- server/routes/users.ts | 6 +++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/client/src/components/signup/Signup.jsx b/client/src/components/signup/Signup.jsx index 8127e6f..c322754 100644 --- a/client/src/components/signup/Signup.jsx +++ b/client/src/components/signup/Signup.jsx @@ -49,6 +49,9 @@ export const Signup = () => { const user = await signup({ email: data.email, password: data.password, + // add: + // first_name: ... + // last_name: ... }); if (user) { diff --git a/client/src/contexts/AuthContext.tsx b/client/src/contexts/AuthContext.tsx index 368476a..528b382 100644 --- a/client/src/contexts/AuthContext.tsx +++ b/client/src/contexts/AuthContext.tsx @@ -35,6 +35,8 @@ export const AuthContext = createContext(null); interface EmailPassword { email: string; password: string; + first_name: string; + last_name: string; } export const AuthProvider = ({ children }: { children: ReactNode }) => { @@ -43,7 +45,7 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => { const [currentUser, setCurrentUser] = useState(null); const [loading, setLoading] = useState(true); - const signup = async ({ email, password }: EmailPassword) => { + const signup = async ({ email, password, first_name, last_name }: EmailPassword) => { if (currentUser) { signOut(auth); } @@ -57,6 +59,8 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => { await backend.post("/users/create", { email: email, firebaseUid: userCredential.user.uid, + first_name: first_name, + last_name: last_name }); return userCredential; diff --git a/server/routes/users.ts b/server/routes/users.ts index c8c3499..ecc151c 100644 --- a/server/routes/users.ts +++ b/server/routes/users.ts @@ -52,11 +52,11 @@ usersRouter.delete("/:firebaseUid", async (req, res) => { // Create user usersRouter.post("/create", async (req, res) => { try { - const { email, firebaseUid } = req.body; + const { email, firebaseUid, first_name, last_name } = req.body; const user = await db.query( - "INSERT INTO users (email, firebase_uid) VALUES ($1, $2) RETURNING *", - [email, firebaseUid] + "INSERT INTO users (email, firebase_uid, first_name, last_name, edit_perms) VALUES ($1, $2, $3, $4, $5) RETURNING *", + [email, firebaseUid, first_name, last_name, false] ); res.status(200).json(keysToCamel(user)); From 67e2c5dfa6aec36b5031024aababff1d433abc6e Mon Sep 17 00:00:00 2001 From: Nathan Pietrantonio Date: Tue, 14 Jan 2025 13:26:11 -0800 Subject: [PATCH 4/5] Convert routes to js --- server/routes/{sample.ts => sample.js} | 0 server/routes/{users.ts => users.js} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename server/routes/{sample.ts => sample.js} (100%) rename server/routes/{users.ts => users.js} (100%) diff --git a/server/routes/sample.ts b/server/routes/sample.js similarity index 100% rename from server/routes/sample.ts rename to server/routes/sample.js diff --git a/server/routes/users.ts b/server/routes/users.js similarity index 100% rename from server/routes/users.ts rename to server/routes/users.js From 518a943abdd82bcdf9e643b485692a5c27bb22dd Mon Sep 17 00:00:00 2001 From: Nathan Pietrantonio Date: Tue, 14 Jan 2025 14:40:50 -0800 Subject: [PATCH 5/5] Convert ts to js --- server/src/{app.ts => app.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename server/src/{app.ts => app.js} (100%) diff --git a/server/src/app.ts b/server/src/app.js similarity index 100% rename from server/src/app.ts rename to server/src/app.js