diff --git a/src/app/(auth)/log-in/page.tsx b/src/app/(auth)/log-in/page.tsx index d5cc86b..5116a68 100644 --- a/src/app/(auth)/log-in/page.tsx +++ b/src/app/(auth)/log-in/page.tsx @@ -15,6 +15,7 @@ import { useState } from 'react'; import { loginApi } from "@/services/api/loginApi"; import { FormControl } from '@mui/material'; import CustomTextField from "@/ui/CustomTextField"; +import { useRouter } from "next/navigation"; const loginSchema = z.object({ username: z.string(), @@ -24,7 +25,7 @@ const loginSchema = z.object({ type LoginFormValues = z.infer; export default function LoginPage() { - + const router = useRouter() const { register, handleSubmit, formState: { errors }, control } = useForm({ resolver: zodResolver(loginSchema), }); @@ -36,9 +37,8 @@ export default function LoginPage() { const response = await loginApi(data); localStorage.setItem('token', response.token); localStorage.setItem('refreshToken', response.refreshToken); - console.log("🚀 ~ response @@@ @@@ @@@ @@@ @@@@:", response) - // router.push('/dashboard'); + router.push('/home'); } catch (err) { setError('Invalid credentials'); } diff --git a/src/ui/CustomTextField.tsx b/src/ui/CustomTextField.tsx index 6610188..ad201a3 100644 --- a/src/ui/CustomTextField.tsx +++ b/src/ui/CustomTextField.tsx @@ -2,6 +2,7 @@ import React from 'react'; import TextField from '@mui/material/TextField'; import { Controller } from 'react-hook-form'; +import { styled } from "@mui/material/styles"; interface CustomTextFieldProps { name: string; @@ -12,13 +13,35 @@ interface CustomTextFieldProps { helperText?: string; } +// Define your styled component +const CssTextField = styled(TextField)({ + width: "100%", + "& label.Mui-focused": { + color: "var(--primary)", + }, + "& .MuiInputBase-root": { + borderRadius: 8, + }, + "& .MuiOutlinedInput-root": { + "& fieldset": { + borderColor: "var(--input-border-default)", + }, + "&:hover fieldset": { + borderColor: "var(--input-border-hover)", + }, + "&.Mui-focused fieldset": { + borderColor: "var(--primary)", + }, + }, +}); + const CustomTextField: React.FC = ({ name, control, label, type = 'text', error, helperText }) => { return ( ( - ( - }} - id="custom-css-outlined-input" - {...field} - type={type} - error={error} - helperText={helperText} - variant="outlined" - fullWidth - /> - )} - /> + <> + }} + + /> + ); }