summaryrefslogtreecommitdiff
path: root/client/src/pages/Update/Demographic/Demographic.jsx
diff options
context:
space:
mode:
authorrohan09-raj <[email protected]>2022-08-18 16:12:35 +0530
committerrohan09-raj <[email protected]>2022-08-18 16:12:35 +0530
commit0a1a985de6e9a53896d2ba17e26d042009b3e1b4 (patch)
tree133d50eb69452171868b38988c6a10c9367ce171 /client/src/pages/Update/Demographic/Demographic.jsx
parent6b85ebee8986b982e05d49c8f1a326deb3e08bae (diff)
Condtional update handling
Diffstat (limited to 'client/src/pages/Update/Demographic/Demographic.jsx')
-rw-r--r--client/src/pages/Update/Demographic/Demographic.jsx26
1 files changed, 1 insertions, 25 deletions
diff --git a/client/src/pages/Update/Demographic/Demographic.jsx b/client/src/pages/Update/Demographic/Demographic.jsx
index 7638f39..61fe972 100644
--- a/client/src/pages/Update/Demographic/Demographic.jsx
+++ b/client/src/pages/Update/Demographic/Demographic.jsx
@@ -1,6 +1,4 @@
import React, { useState } from 'react'
-import { useQuery } from 'react-query'
-import { getUserByAadhaar } from '../../../services/apiservice'
import Address from '../Address/Address'
import DocumentScanner from '../DocumentScanner/DocumentScanner'
import SubmitButton from '../../../components/SubmitButton/SubmitButton'
@@ -19,32 +17,10 @@ import 'react-toastify/dist/ReactToastify.css'
const Demographic = () => {
const { t } = useTranslation()
- const { aadhaarNumber, userData, setUserData } = userContext()
+ const { userData } = userContext()
const [page, setPage] = useState(0)
- const isLongEnough = aadhaarNumber?.toString().length > 11
-
- // Make api call using the provided aadhaar number and set the user data in the context if the api call is successful. Set form data to the user data if the api call is successful and prevent too many re-renders.
- const { isLoading, isError, data } = useQuery('user', async () => {
- if (isLongEnough) {
- const response = await getUserByAadhaar(aadhaarNumber)
- return response
- }
- })
-
- if (isLoading) {
- return <div>{t('loading')}</div>
- }
-
- if (isError) {
- return <div>{t('error')}</div>
- }
-
- if (data) {
- setUserData(data?.data)
- }
-
const handleSubmit = () => {
if (page === 0) {
if (userData.name === '' || userData.name.length < 1) {