From 2e8effb0f9365ad15271f794ce18556c211068d2 Mon Sep 17 00:00:00 2001 From: TajwarSaiyeed Date: Fri, 1 Sep 2023 11:12:11 +0600 Subject: [PATCH] bug fix | update --- app/(auth)/signin/page.tsx | 193 ++++++++++++++++++++++++------------ app/(root)/profile/page.tsx | 139 +++++++++++++------------- app/api/users/route.ts | 3 +- 3 files changed, 199 insertions(+), 136 deletions(-) diff --git a/app/(auth)/signin/page.tsx b/app/(auth)/signin/page.tsx index e5598b9..a8ce7a1 100644 --- a/app/(auth)/signin/page.tsx +++ b/app/(auth)/signin/page.tsx @@ -3,23 +3,32 @@ import {useState} from "react"; import toast from "react-hot-toast"; import Loader from "@/app/components/Loader/Loader"; -import { useSession, signIn } from "next-auth/react"; -import { redirect, useRouter } from "next/navigation"; +import {useSession, signIn} from "next-auth/react"; +import {redirect, useRouter} from "next/navigation"; import LockOutlinedIcon from '@mui/icons-material/LockOutlined'; -import { createTheme, ThemeProvider } from '@mui/material/styles'; -import { FieldValues, SubmitHandler, useForm } from "react-hook-form"; -import {Avatar, Button, CssBaseline, TextField, Box, Typography,Container} from '@mui/material/'; +import {createTheme, ThemeProvider} from '@mui/material/styles'; +import {FieldValues, SubmitHandler, useForm} from "react-hook-form"; +import {Avatar, Button, CssBaseline, TextField, Box, Typography, Container} from '@mui/material/'; const defaultTheme = createTheme(); export default function SignInPage() { const [isSubmitting, setIsSubmitting] = useState(false); - const { status } = useSession(); + + const [testUser, setTestUser] = useState<{ + email: string, + password: string + }>({ + email: "", + password: "" + }) + + const {status} = useSession(); const { register, handleSubmit, - formState: { errors }, + formState: {errors}, } = useForm({ defaultValues: { email: "", @@ -48,7 +57,7 @@ export default function SignInPage() { }; if (status === "loading") { - return ; + return ; } if (status === "authenticated") { @@ -57,70 +66,122 @@ export default function SignInPage() { return ( - - - - - - - - Sign in - - - + + + + + + + + Sign in + + + + + - + + + + + + - - - + + ); } \ No newline at end of file diff --git a/app/(root)/profile/page.tsx b/app/(root)/profile/page.tsx index 0ecaf1d..4160376 100644 --- a/app/(root)/profile/page.tsx +++ b/app/(root)/profile/page.tsx @@ -346,80 +346,81 @@ export default function ProfilePage() { Password - - { - setValue("password", e.target.value); - if (getValues("confirmPassword") === e.target.value) { - setPasswordsMatch(true); - } else { - setPasswordsMatch(false); - } - }} - /> - + Disabled for demo + {/* {*/} + {/* setValue("password", e.target.value);*/} + {/* if (getValues("confirmPassword") === e.target.value) {*/} + {/* setPasswordsMatch(true);*/} + {/* } else {*/} + {/* setPasswordsMatch(false);*/} + {/* }*/} + {/* }}*/} + {/* />*/} + {/**/} Confirm Password - - - value === getValues("password") || "Passwords do not match", - })} - onChange={(e) => { - setValue("confirmPassword", e.target.value); - if (getValues("password") === e.target.value) { - setPasswordsMatch(true); - } else { - setPasswordsMatch(false); - } - }} - /> - + Disabled for demo + {/**/} + {/* */} + {/* value === getValues("password") || "Passwords do not match",*/} + {/* })}*/} + {/* onChange={(e) => {*/} + {/* setValue("confirmPassword", e.target.value);*/} + {/* if (getValues("password") === e.target.value) {*/} + {/* setPasswordsMatch(true);*/} + {/* } else {*/} + {/* setPasswordsMatch(false);*/} + {/* }*/} + {/* }}*/} + {/* />*/} + {/**/} diff --git a/app/api/users/route.ts b/app/api/users/route.ts index 849d98e..7e80989 100644 --- a/app/api/users/route.ts +++ b/app/api/users/route.ts @@ -302,7 +302,8 @@ export async function PATCH(req: Request) { height: body.height !== "" ? body.height : user.height, goal: body.goal !== "" ? body.goal : user.goal, level: body.level !== "" ? body.level : user.level, - hashedPassword + hashedPassword, + isActive: body.isActive } })