-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug displaying registration confirmation modal multiple times (#1161
) * Add comments and print statements to aid debugging * Update variable to disable button if the registration is incomplete * Add optional chaining to handleSubmitRegister and update useEffect dependency array * Add useSubmissionStatus hook, set is network sent state to false after user returns to review page * Remove debugging comment
- Loading branch information
1 parent
51cc7db
commit e9ea9fe
Showing
4 changed files
with
71 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
web/gds-user-ui/src/modules/dashboard/registration/hooks/useSubmissionStatus.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { useEffect, useState } from "react"; | ||
import { getSubmissionStatus } from "../service"; | ||
import { upperCaseFirstLetter } from "utils/utils"; | ||
|
||
const useSubmissionStatus = () => { | ||
const [error, setError] = useState<any>(null); | ||
const [isLoading, setIsLoading] = useState<boolean>(false); | ||
const [status, setStatus] = useState<any>(null); | ||
|
||
const fetchSubmissionStatus = async () => { | ||
setIsLoading(true); | ||
try { | ||
const response = await getSubmissionStatus(); | ||
if (!response) setError('No data found'); | ||
setStatus(response); | ||
} catch (e: any) { | ||
if (!e?.data?.success) { | ||
setError(upperCaseFirstLetter(e?.data?.error)); | ||
} else { | ||
setError('Something went wrong.'); | ||
} | ||
} finally { | ||
setIsLoading(false); | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
fetchSubmissionStatus(); | ||
}, []); | ||
|
||
return { status, isLoading, error }; | ||
}; | ||
|
||
export default useSubmissionStatus; |