File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
components/RecoveryPasswordPageComponent Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ import { LoginButton } from '../LoginPageComponent/LoginPageComponent.styled';
5
5
import { useMediaQuery } from 'react-responsive' ;
6
6
import { useForm } from 'react-hook-form' ;
7
7
import { PATH } from '../../constans/routes' ;
8
+ import { useParams } from 'react-router-dom' ;
9
+ import { useResetPasswordMutation } from '../../redux/auth-operations' ;
8
10
import {
9
11
RecoveryPasswordWrapper ,
10
12
RecoveryPasswordForm ,
@@ -17,6 +19,8 @@ import {
17
19
18
20
function RecoveryPasswordPageComponent ( ) {
19
21
const isTablet = useMediaQuery ( { query : '(min-width: calc(845px - 0.02px)' } ) ;
22
+ const { token } = useParams ( ) ;
23
+ const [ resetPassword ] = useResetPasswordMutation ( ) ;
20
24
const {
21
25
formState : { errors, isValid } ,
22
26
handleSubmit,
@@ -30,8 +34,10 @@ function RecoveryPasswordPageComponent() {
30
34
31
35
const onSubmit = ( values ) => {
32
36
const { password } = values ;
33
- // eslint-disable-next-line no-console
34
- console . log ( password ) ;
37
+ resetPassword ( {
38
+ newPassword : password ,
39
+ token,
40
+ } ) ;
35
41
} ;
36
42
37
43
return (
Original file line number Diff line number Diff line change @@ -44,6 +44,12 @@ const authenticationApi = createApi({
44
44
headers : { Authorization : `Bearer ${ ajwt } ` } ,
45
45
} ) ,
46
46
} ) ,
47
+ resetPassword : builder . mutation ( {
48
+ query : ( { newPassword, token } ) => ( {
49
+ url : `/change/password/restore?newPassword=${ newPassword } &token=${ token } ` ,
50
+ method : 'PATCH' ,
51
+ } ) ,
52
+ } ) ,
47
53
} ) ,
48
54
} ) ;
49
55
@@ -53,6 +59,7 @@ export const {
53
59
useLoginMutation,
54
60
useActivateMutation,
55
61
useLogoutMutation,
62
+ useResetPasswordMutation,
56
63
} = authenticationApi ;
57
64
58
65
export default authenticationApi ;
You can’t perform that action at this time.
0 commit comments