From 0a1a985de6e9a53896d2ba17e26d042009b3e1b4 Mon Sep 17 00:00:00 2001 From: rohan09-raj Date: Thu, 18 Aug 2022 16:12:35 +0530 Subject: Condtional update handling --- .../src/pages/Update/Demographic/Demographic.jsx | 26 +--------------------- 1 file changed, 1 insertion(+), 25 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 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
{t('loading')}
- } - - if (isError) { - return
{t('error')}
- } - - if (data) { - setUserData(data?.data) - } - const handleSubmit = () => { if (page === 0) { if (userData.name === '' || userData.name.length < 1) { -- cgit