@@ -2,10 +2,10 @@ import type { Interpolation, Theme } from "@emotion/react";
2
2
import LoadingButton from "@mui/lab/LoadingButton" ;
3
3
import Button from "@mui/material/Button" ;
4
4
import TextField from "@mui/material/TextField" ;
5
- import { getErrorMessage } from "api/errors" ;
6
5
import { changePasswordWithOTP } from "api/queries/users" ;
6
+ import { ErrorAlert } from "components/Alert/ErrorAlert" ;
7
7
import { CustomLogo } from "components/CustomLogo/CustomLogo" ;
8
- import { displayError , displaySuccess } from "components/GlobalSnackbar/utils" ;
8
+ import { displaySuccess } from "components/GlobalSnackbar/utils" ;
9
9
import { Stack } from "components/Stack/Stack" ;
10
10
import { useFormik } from "formik" ;
11
11
import type { FC } from "react" ;
@@ -53,18 +53,14 @@ const ChangePasswordPage: FC<ChangePasswordChangeProps> = ({ redirect }) => {
53
53
const email = searchParams . get ( "email" ) ?? "" ;
54
54
const otp = searchParams . get ( "otp" ) ?? "" ;
55
55
56
- try {
57
- await changePasswordMutation . mutateAsync ( {
58
- email,
59
- one_time_passcode : otp ,
60
- password : values . password ,
61
- } ) ;
62
- displaySuccess ( "Password reset successfully" ) ;
63
- if ( redirect ) {
64
- navigate ( "/login" ) ;
65
- }
66
- } catch ( error ) {
67
- displayError ( getErrorMessage ( error , "Error resetting password" ) ) ;
56
+ await changePasswordMutation . mutateAsync ( {
57
+ email,
58
+ one_time_passcode : otp ,
59
+ password : values . password ,
60
+ } ) ;
61
+ displaySuccess ( "Password reset successfully" ) ;
62
+ if ( redirect ) {
63
+ navigate ( "/login" ) ;
68
64
}
69
65
} ,
70
66
} ) ;
@@ -78,21 +74,29 @@ const ChangePasswordPage: FC<ChangePasswordChangeProps> = ({ redirect }) => {
78
74
79
75
< div css = { styles . root } >
80
76
< main css = { styles . container } >
81
- < CustomLogo />
77
+ < CustomLogo css = { styles . logo } />
82
78
< h1
83
79
css = { {
80
+ margin : 0 ,
81
+ marginBottom : 24 ,
84
82
fontSize : 20 ,
85
83
fontWeight : 600 ,
86
84
lineHeight : "28px" ,
87
85
} }
88
86
>
89
87
Choose a new password
90
88
</ h1 >
89
+ { changePasswordMutation . error ? (
90
+ < ErrorAlert
91
+ error = { changePasswordMutation . error }
92
+ css = { { marginBottom : 24 } }
93
+ />
94
+ ) : null }
91
95
< form css = { { width : "100%" } } onSubmit = { form . handleSubmit } >
92
96
< fieldset disabled = { form . isSubmitting } >
93
97
< Stack spacing = { 2.5 } >
94
98
< TextField
95
- label = "New password "
99
+ label = "Password "
96
100
autoFocus
97
101
fullWidth
98
102
required
@@ -101,7 +105,7 @@ const ChangePasswordPage: FC<ChangePasswordChangeProps> = ({ redirect }) => {
101
105
/>
102
106
103
107
< TextField
104
- label = "Confirm new password"
108
+ label = "Confirm password"
105
109
fullWidth
106
110
required
107
111
type = "password"
@@ -125,7 +129,7 @@ const ChangePasswordPage: FC<ChangePasswordChangeProps> = ({ redirect }) => {
125
129
variant = "text"
126
130
to = "/login"
127
131
>
128
- Cancel
132
+ Back to login
129
133
</ Button >
130
134
</ Stack >
131
135
</ Stack >
@@ -138,11 +142,15 @@ const ChangePasswordPage: FC<ChangePasswordChangeProps> = ({ redirect }) => {
138
142
} ;
139
143
140
144
const styles = {
145
+ logo : {
146
+ marginBottom : 40 ,
147
+ } ,
141
148
root : {
142
149
padding : 24 ,
143
150
display : "flex" ,
144
151
alignItems : "center" ,
145
152
justifyContent : "center" ,
153
+ flexDirection : "column" ,
146
154
minHeight : "100%" ,
147
155
textAlign : "center" ,
148
156
} ,
@@ -152,7 +160,6 @@ const styles = {
152
160
display : "flex" ,
153
161
flexDirection : "column" ,
154
162
alignItems : "center" ,
155
- gap : 16 ,
156
163
} ,
157
164
icon : {
158
165
fontSize : 64 ,
0 commit comments