File tree Expand file tree Collapse file tree 4 files changed +21
-5
lines changed
(main)/(container)/profile Expand file tree Collapse file tree 4 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -46,19 +46,28 @@ const Page = () => {
4646
4747 const [ isPending , startTransition ] = useTransition ( ) ;
4848
49+ const getCallbackUrl = ( ) => {
50+ const callbackUrl =
51+ new URL ( location . href ) . searchParams . get ( 'callbackUrl' ) || '/' ;
52+
53+ const url = new URL ( callbackUrl || '/' ) ;
54+ return url . pathname + url . search + url . hash ;
55+ } ;
56+
4957 const onSubmit : SubmitHandler < FieldNames > = ( data ) => {
5058 startTransition ( async ( ) => {
51- const callbackUrl =
52- new URL ( location . href ) . searchParams . get ( 'callbackUrl' ) || '/' ;
59+ const callbackUrl = getCallbackUrl ( ) ;
5360
5461 const result = await signIn ( 'credentials' , {
5562 ...data ,
56- callbackUrl ,
63+ redirect : false ,
5764 } ) ;
5865
5966 if ( result ) {
6067 if ( result . status !== 200 ) {
61- toast . error ( t ( 'pages.error.message' ) ) ;
68+ toast . error ( t ( 'messages.authenticationError' ) ) ;
69+ } else {
70+ router . push ( callbackUrl ) ;
6271 }
6372 }
6473 } ) ;
Original file line number Diff line number Diff line change @@ -36,7 +36,12 @@ const Page = () => {
3636 < Menu />
3737 </ MobileView >
3838 < DesktopView >
39- < Card variant = "outlined" >
39+ < Card
40+ variant = "outlined"
41+ sx = { {
42+ flexGrow : 1 ,
43+ } }
44+ >
4045 < CardContent >
4146 < CardHeader title = { t ( 'profile.latestOrders' ) } >
4247 { ! ! edges ?. length && (
Original file line number Diff line number Diff line change 44 "title" : " Are you sure?"
55 },
66 "messages" : {
7+ "authenticationError" : " Authentication Error" ,
78 "passwordNotMatch" : " Passwords must match" ,
89 "copied" : " Copied to clipboard" ,
910 "cart" : {
Original file line number Diff line number Diff line change 44 "title" : " آیا مطمئن هستید؟"
55 },
66 "messages" : {
7+ "authenticationError" : " نام کاربری یا رمز عبور اشتباه است." ,
78 "passwordNotMatch" : " تایید رمز عبور با رمز عبور مطابقت ندارد." ,
89 "copied" : " کپی شد." ,
910 "cart" : {
You can’t perform that action at this time.
0 commit comments