@@ -8,6 +8,9 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
8
8
import { faEye , faEyeSlash } from '@fortawesome/free-solid-svg-icons' ;
9
9
import { toast } from "react-toastify" ;
10
10
import { TailSpin } from 'react-loader-spinner' ;
11
+ import { logout } from '../../store/features/auth/authSlice' ;
12
+ import { disconnect } from '../../utils/socket/socket' ;
13
+ import { useNavigate } from 'react-router-dom' ;
11
14
12
15
const passwordSchema = Yup . object ( {
13
16
oldPassword : Yup . string ( ) . required ( 'Old password is required' ) ,
@@ -25,6 +28,7 @@ const PasswordUpdate = ({ message, isError, isSuccess }) => {
25
28
const [ showConfirmPassword , setShowConfirmPassword ] = useState ( false ) ;
26
29
const [ showConfirmNewPassword , setShowConfirmNewPassword ] = useState ( false )
27
30
const [ loading , setLoading ] = useState ( false ) ;
31
+ const navigate = useNavigate ( )
28
32
29
33
const newPasswordVisibility = ( ) => {
30
34
setShowPassword ( ! showPassword ) ;
@@ -45,13 +49,23 @@ const PasswordUpdate = ({ message, isError, isSuccess }) => {
45
49
} ,
46
50
validationSchema : passwordSchema ,
47
51
onSubmit : async ( values ) => {
48
- setLoading ( true ) ;
49
52
try {
53
+ setTimeout ( ( ) => {
54
+ setLoading ( true )
55
+ } , 200 )
50
56
dispatch ( updatePassword ( values ) ) ;
51
57
} catch ( err ) {
52
58
console . log ( err )
53
59
} finally {
54
60
setLoading ( false )
61
+ toast . success ( "Password updated Successfully you will be logged out in few second " )
62
+ setTimeout ( ( ) => {
63
+ dispatch ( logout ( ) )
64
+ disconnect ( )
65
+ } , 4000 )
66
+ setTimeout ( ( ) => {
67
+ navigate ( "/login" )
68
+ } , 5500 )
55
69
}
56
70
57
71
} ,
@@ -74,7 +88,7 @@ const PasswordUpdate = ({ message, isError, isSuccess }) => {
74
88
< div className = "password" >
75
89
< div className = 'password-layout' >
76
90
< div className = "password-inp" >
77
- < label htmlFor = "oldPassword" > old password </ label >
91
+ < label htmlFor = "oldPassword" > Old Password </ label >
78
92
< div className = "input-n" >
79
93
< input
80
94
type = { showPassword ? 'text' : 'password' }
@@ -102,7 +116,7 @@ const PasswordUpdate = ({ message, isError, isSuccess }) => {
102
116
< div >
103
117
< div className = 'conf-pwd' >
104
118
< div className = "password-inp" >
105
- < label htmlFor = "newPassword" > new Password</ label >
119
+ < label htmlFor = "newPassword" > New Password</ label >
106
120
< div className = "input-n" >
107
121
< input
108
122
type = { showConfirmPassword ? 'text' : 'password' }
@@ -126,7 +140,7 @@ const PasswordUpdate = ({ message, isError, isSuccess }) => {
126
140
{ formik . errors . newPassword && < div className = 'error' > { formik . errors . newPassword } </ div > }
127
141
</ div >
128
142
< div className = "password-inp" >
129
- < label htmlFor = "confirmNewPassword" > confirm New Password</ label >
143
+ < label htmlFor = "confirmNewPassword" > Confirm New Password</ label >
130
144
< div className = "input-n" >
131
145
< input
132
146
type = { showConfirmNewPassword ? 'text' : 'password' }
0 commit comments