diff --git a/components/Login/LoginForm.tsx b/components/Login/LoginForm.tsx index cefc2e6..c10508b 100644 --- a/components/Login/LoginForm.tsx +++ b/components/Login/LoginForm.tsx @@ -2,9 +2,10 @@ import sendLoginUserRequest from '@/requests/sendLoginUserRequest'; import LoginValidationSchema from '@/services/User/schema/LoginValidationSchema'; import { zodResolver } from '@hookform/resolvers/zod'; import { useRouter } from 'next/router'; -import { useState } from 'react'; +import { useContext, useState } from 'react'; import { useForm, SubmitHandler } from 'react-hook-form'; import { z } from 'zod'; +import UserContext from '@/contexts/userContext'; import ErrorAlert from '../ui/alerts/ErrorAlert'; import FormError from '../ui/forms/FormError'; import FormInfo from '../ui/forms/FormInfo'; @@ -28,10 +29,13 @@ const LoginForm = () => { const [responseError, setResponseError] = useState(''); + const { mutate } = useContext(UserContext); + const onSubmit: SubmitHandler = async (data) => { try { await sendLoginUserRequest(data); - router.push(`/user/current`); + await mutate!(); + await router.push(`/user/current`); } catch (error) { if (error instanceof Error) { setResponseError(error.message); diff --git a/components/ui/Layout.tsx b/components/ui/Layout.tsx index d1446e1..3ff6558 100644 --- a/components/ui/Layout.tsx +++ b/components/ui/Layout.tsx @@ -4,10 +4,10 @@ import Navbar from './Navbar'; const Layout: FC<{ children: ReactNode }> = ({ children }) => { return (
-
- -
-
{children}
+ +
+ {children} +
); }; diff --git a/components/ui/Navbar.tsx b/components/ui/Navbar.tsx index a75639f..47ebece 100644 --- a/components/ui/Navbar.tsx +++ b/components/ui/Navbar.tsx @@ -42,10 +42,10 @@ const Navbar = () => { ]; return ( -