diff options
author | Blaster4385 <venkateshchaturvedi12@gmail.com> | 2022-08-18 20:45:53 +0530 |
---|---|---|
committer | Blaster4385 <venkateshchaturvedi12@gmail.com> | 2022-08-18 20:45:53 +0530 |
commit | 1d0a79ee10a456d9c970713f2952c3319cac4f8a (patch) | |
tree | eff99523fc4b714864718d6c88208e035a9f6735 /client | |
parent | f2947397f4e99911fe0f8b38c1b1a0c2661dd3e2 (diff) |
Clear context and navigate to home on completing enrollment
Diffstat (limited to 'client')
-rw-r--r-- | client/src/pages/Enrollment/Enrollment.jsx | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/client/src/pages/Enrollment/Enrollment.jsx b/client/src/pages/Enrollment/Enrollment.jsx index 19f0133..cda04df 100644 --- a/client/src/pages/Enrollment/Enrollment.jsx +++ b/client/src/pages/Enrollment/Enrollment.jsx @@ -22,11 +22,13 @@ import { useTranslation } from 'react-i18next' import { ToastContainer, toast } from 'react-toastify' import 'react-toastify/dist/ReactToastify.css' import { userContext } from '../../context/User' +import { useNavigate } from 'react-router-dom' const Enrollment = () => { const { t } = useTranslation() const [page, setPage] = useState(0) - const { userData } = userContext() + const { userData, setUserData } = userContext() + const navigate = useNavigate() const { mutate } = useMutation((payload) => createUser(payload)) @@ -98,26 +100,33 @@ const Enrollment = () => { } else if (page === 7) { setPage(page + 1) } else if (page === 8) { - mutate({ - indianResident: userData.indianResident, - name: userData.name, - gender: userData.gender, - dob: userData.dob, - mobile: userData.mobile, - email: userData.email, - address: userData.address, - photo: userData.photo, - documents: { - POI: userData.documents.POI, - POA: userData.documents.POA, - DOB: userData.documents.DOB + mutate( + { + indianResident: userData.indianResident, + name: userData.name, + gender: userData.gender, + dob: userData.dob, + mobile: userData.mobile, + email: userData.email, + address: userData.address, + photo: userData.photo, + documents: { + POI: userData.documents.POI, + POA: userData.documents.POA, + DOB: userData.documents.DOB + } + }, + { + onSuccess: () => { + setUserData(null) + navigate('/') + } } - }) - setPage(page + 1) + ) } } -console.log(userData) + console.log(userData) const conditionalComponent = () => { switch (page) { |