File tree Expand file tree Collapse file tree 3 files changed +19
-9
lines changed
components/root/users/login/forgottenPassword
spring-backend/src/main/java/backend/hobbiebackend/web Expand file tree Collapse file tree 3 files changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,11 @@ import axios from "axios";
22
33const UserEmailDataService = async ( email ) => {
44 try {
5- return axios . post ( `http://localhost:8080/notification` , email ) ;
5+ return axios . post ( `http://localhost:8080/notification` , null , {
6+ params : {
7+ email,
8+ } ,
9+ } ) ;
610 } catch ( err ) {
711 let error = "" ;
812 if ( err . response ) {
Original file line number Diff line number Diff line change @@ -5,9 +5,11 @@ import { useState } from "react";
55import styles from "../../../../../css/Forms.module.css" ;
66import style from "../../../../../css/Footer.module.css" ;
77import UserEmailDataService from "../../../../../api/users/UserEmailDataService" ;
8+ import LoadingDotsDark from "../animation/LoadingDotsDark" ;
89
910const PasswordChange = ( ) => {
1011 const [ email , setEmail ] = useState ( "" ) ;
12+ const [ loading , setLoading ] = useState ( false ) ;
1113 const [ sent , setSent ] = useState ( false ) ;
1214 const [ found , setFound ] = useState ( true ) ;
1315 const [ errors , setErrors ] = useState ( { } ) ;
@@ -29,13 +31,15 @@ const PasswordChange = () => {
2931 console . log ( errors ) ;
3032
3133 if ( Object . keys ( errors ) . length === 0 ) {
34+ setLoading ( true ) ;
3235 const res = await UserEmailDataService ( email ) ;
3336 console . log ( res . status ) ;
3437
3538 if ( res . status === 200 ) {
3639 setSent ( true ) ;
3740 setFound ( true ) ;
3841 } else {
42+ setLoading ( false ) ;
3943 setFound ( false ) ;
4044 }
4145 }
@@ -77,9 +81,13 @@ const PasswordChange = () => {
7781 </ label >
7882 </ section >
7983 </ div >
80- < button className = { styles . button } onClick = { sentClicked } >
81- Submit
82- </ button >
84+ { loading && < LoadingDotsDark className = { styles . dots } /> }
85+
86+ { ! loading && (
87+ < button className = { styles . button } onClick = { sentClicked } >
88+ Submit
89+ </ button >
90+ ) }
8391 </ div >
8492 ) }
8593 { sent && (
Original file line number Diff line number Diff line change 2828
2929import java .io .UnsupportedEncodingException ;
3030import java .net .URLDecoder ;
31-
31+ import java . nio . charset . StandardCharsets ;
3232
3333
3434@ RestController
@@ -110,10 +110,8 @@ public ResponseEntity<?> updateUser(@RequestBody UpdateAppClientDto user) {
110110
111111 }
112112 @ PostMapping ("/notification" )
113- public ResponseEntity <?> sendNotification (@ RequestBody String e ) throws UnsupportedEncodingException {
114- String email = URLDecoder .decode (e , "UTF-8" );
115- email = email .substring (0 , email .length ()-1 );
116- UserEntity userByEmail = this .userService .findUserByEmail (email );
113+ public ResponseEntity <?> sendNotification (@ RequestParam ("email" ) String e ) {
114+ UserEntity userByEmail = this .userService .findUserByEmail (e );
117115
118116 if (userByEmail == null ){
119117 throw new NotFoundException ("User not found" );
You can’t perform that action at this time.
0 commit comments