11'use client' ;
22
3+ import PasswordTextField from '@/components/PasswordTextField/PasswordTextField' ;
34import ButtonWithLoading from '@/components/common/ButtonWithLoading' ;
45import Logo from '@/components/common/Logo' ;
56import { Link , useRouter } from '@/navigation' ;
67import { yupResolver } from '@hookform/resolvers/yup' ;
7- import { Box , Stack , TextField , Typography } from '@mui/material' ;
8+ import {
9+ Box ,
10+ Link as MuiLink ,
11+ Stack ,
12+ TextField ,
13+ Typography ,
14+ } from '@mui/material' ;
815import Card from '@mui/material/Card' ;
916import CardActions from '@mui/material/CardActions' ;
1017import CardContent from '@mui/material/CardContent' ;
@@ -14,7 +21,6 @@ import { useTransition } from 'react';
1421import { Controller , SubmitHandler , useForm } from 'react-hook-form' ;
1522import { toast } from 'react-hot-toast' ;
1623import * as yup from 'yup' ;
17- import { Link as MuiLink } from '@mui/material' ;
1824
1925type FieldNames = Partial < Record < 'username' | 'password' , any > > ;
2026
@@ -42,16 +48,17 @@ const Page = () => {
4248
4349 const onSubmit : SubmitHandler < FieldNames > = ( data ) => {
4450 startTransition ( async ( ) => {
51+ const callbackUrl =
52+ new URL ( location . href ) . searchParams . get ( 'callbackUrl' ) || '/' ;
53+
4554 const result = await signIn ( 'credentials' , {
4655 ...data ,
47- redirect : false ,
56+ callbackUrl ,
4857 } ) ;
4958
5059 if ( result ) {
5160 if ( result . status !== 200 ) {
52- toast . error ( 'An Error Occurred!' ) ;
53- } else {
54- router . push ( '/' ) ;
61+ toast . error ( t ( 'pages.error.message' ) ) ;
5562 }
5663 }
5764 } ) ;
@@ -102,10 +109,12 @@ const Page = () => {
102109 value = { value }
103110 variant = "outlined"
104111 fullWidth
105- dir = "ltr"
106- placeholder = { labels [ name ] }
112+ label = { labels [ name ] }
107113 error = { ! ! error ?. message }
108114 helperText = { error ?. message ?. toString ( ) }
115+ inputProps = { {
116+ dir : 'ltr' ,
117+ } }
109118 />
110119 ) ;
111120 } }
@@ -118,15 +127,13 @@ const Page = () => {
118127 fieldState : { error } ,
119128 } ) => {
120129 return (
121- < TextField
122- type = "password"
130+ < PasswordTextField
123131 onChange = { onChange }
124132 name = { name }
125133 value = { value }
126134 variant = "outlined"
127135 fullWidth
128- dir = "ltr"
129- placeholder = { labels [ name ] }
136+ label = { labels [ name ] }
130137 error = { ! ! error ?. message }
131138 helperText = { error ?. message ?. toString ( ) }
132139 />
0 commit comments