From a49c7aefc99a1e0584cb0b3fb08d028b65dc35d9 Mon Sep 17 00:00:00 2001
From: rohan09-raj <rajrohan1914@gmail.com>
Date: Sun, 21 Aug 2022 11:55:25 +0530
Subject: Update fixes

---
 client/src/pages/Update/Demographic/Demographic.jsx | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

(limited to 'client/src/pages/Update/Demographic/Demographic.jsx')

diff --git a/client/src/pages/Update/Demographic/Demographic.jsx b/client/src/pages/Update/Demographic/Demographic.jsx
index 0f89fe2..03f107a 100644
--- a/client/src/pages/Update/Demographic/Demographic.jsx
+++ b/client/src/pages/Update/Demographic/Demographic.jsx
@@ -15,10 +15,15 @@ import { userContext } from '../../../context/User'
 import { ToastContainer, toast } from 'react-toastify'
 import BackButton from '../../../components/BackButton/BackButton'
 import 'react-toastify/dist/ReactToastify.css'
+import { useNavigate } from 'react-router-dom'
+import { initialUserData } from '../../../constants/userData'
 
 const Demographic = () => {
   const { t } = useTranslation()
-  const { userData } = userContext()
+  const { userData, setUserData, setOriUserData, setAadhaarNumber } =
+    userContext()
+
+  const navigate = useNavigate()
 
   const [page, setPage] = useState(0)
 
@@ -91,7 +96,14 @@ const Demographic = () => {
         return (
           <>
             <SubmitButton onClick={handleSubmit} />
-            <BackButton onClick={() => setPage(page - 1)} />
+            <BackButton
+              onClick={() => {
+                setUserData(initialUserData)
+                setOriUserData(initialUserData)
+                setAadhaarNumber('')
+                navigate('/')
+              }}
+            />
           </>
         )
       case 1:
-- 
cgit 

