diff options
author | rohan09-raj <rajrohan1914@gmail.com> | 2022-08-17 16:37:42 +0530 |
---|---|---|
committer | rohan09-raj <rajrohan1914@gmail.com> | 2022-08-17 16:37:42 +0530 |
commit | 3e7f5cbd876b29c92fc1cda58aa54a9c591ef026 (patch) | |
tree | e5706d93708ae378e913a4d1737b0aec6c3b382d | |
parent | 1c9a3d21cc3479d299181d98fb895614e0aaf649 (diff) |
lol
-rw-r--r-- | client/src/components/LanguageSelect/locales/hi/translation.json | 75 | ||||
-rw-r--r-- | client/src/context/User.js | 28 | ||||
-rw-r--r-- | client/src/index.js | 5 | ||||
-rw-r--r-- | client/src/pages/Update/Demographic/Demographic.jsx | 48 | ||||
-rw-r--r-- | client/src/pages/Update/Update.jsx | 15 |
5 files changed, 154 insertions, 17 deletions
diff --git a/client/src/components/LanguageSelect/locales/hi/translation.json b/client/src/components/LanguageSelect/locales/hi/translation.json index 3b0eadd..a5b3080 100644 --- a/client/src/components/LanguageSelect/locales/hi/translation.json +++ b/client/src/components/LanguageSelect/locales/hi/translation.json @@ -1,4 +1,77 @@ { + "AADHAAR": "आधार", + "MERA_AADHAAR_MERI_PEHCHAN": "मेरा आधार मेरी पहचान", "ENROLLMENT": "उपस्थिति पंजी", - "UPDATE": "अद्यतन" + "UPDATE": "अद्यतन", + "INDIAN_RESIDENT": "भारतीय निवासी", + "NON_RESIDENTIAL_INDIAN": "गैर-आवासीय भारतीय", + "FULL_NAME": "पूरा नाम", + "ENTER_YOUR_FULL_NAME": "अपना पूरा नाम भरें", + "MALE": "पुरुष", + "FEMALE": "मादा", + "OTHER": "अन्य", + "DATE_OF_BIRTH": "जन्म की तारीख", + "MOBILE": "मोबाइल", + "ENTER_YOUR_MOBILE_NUMBER": "अपना मोबाइल नंबर दर्ज करें", + "EMAIL": "ईमेल", + "ENTER_YOUR_EMAIL_ID": "अपना ईमेल आईडी दर्ज करें", + "COUNTRY": "देश", + "STATE": "राज्य", + "DISTRICT": "जिला", + "VILLAGE_TOWN": "गाँव / नगर", + "ENTER_YOUR_VILLAGE_TOWN": "अपना गांव / कस्बा दर्ज करें", + "HOUSE_NUMBER_APARTMENT": "हाउस नंबर / अपार्टमेंट", + "ENTER_YOUR_HOUSE_NUMBER_APARTMENT": "अपना घर नंबर/अपार्टमेंट दर्ज करें", + "STREET_ROAD": "सड़क / सड़क", + "ENTER_YOUR_STREET_ROAD": "अपनी गली / सड़क दर्ज करें", + "AREA_LOCALITY": "क्षेत्र / इलाका", + "ENTER_YOUR_AREA_LOCALITY": "अपना क्षेत्र / इलाका दर्ज करें", + "POST_OFFICE": "डाकघर", + "ENTER_YOUR_AREA_POST_OFFICE": "अपना क्षेत्र डाकघर दर्ज करें", + "LANDMARK": "लैंडमार्क", + "ENTER_ANY_NEAREST_LANDMARK": "कोई भी निकटतम लैंडमार्क दर्ज करें", + "PINCODE": "पिनकोड", + "ENTER_YOUR_AREA_PINCODE": "अपना क्षेत्र पिनकोड दर्ज करें", + "CAPTURE": "कैप्चर", + "RESET": "रीसेट", + "PLEASE_LOOK_INTO_THE_CAMERA": "कृपया कैमरे में देखें", + "CLICK_CAPTURE_TO_CAPTURE_THE_PHOTO": "फ़ोटो कैप्चर करने के लिए कैप्चर करें क्लिक करें", + "CLICK_RESET_TO_REMOVE_THE_CAPTURED_PHOTO": "कैप्चर की गई फ़ोटो को निकालने के लिए रीसेट करें क्लिक करें", + "PROOF_OF_IDENTITY": "पहचान का प्रमाण", + "PROOF_OF_ADDRESS": "पते का प्रमाण", + "PROOF_OF_DOB": "जन्म तिथि का प्रमाण", + "SCAN": "स्कैन", + "KINDLY_CLICK_THE_PICTURE_OF_YOUR_DOCUMENTS": "कृपया अपने दस्तावेज़ों की तस्वीर क्लिक करें", + "ALL_STEPS_COMPLETED": "सभी चरण पूरे हुए - आपका काम पूरा हो गया", + "BACK": "पीछे", + "FINISH": "फिनिश", + "NEXT": "अगला", + "PLEASE_PUT_YOUR_EYES_INSIDE_THE_IRIS_SCANNER": "कृपया अपनी आंखें आईरिस स्कैनर के अंदर रखें।.", + "WAIT_FOR_PROMPT_AND_BEEP_SOUND_TO_REMOVE_YOUR_EYES": "अपनी आंखों को हटाने के लिए संकेत और बीप ध्वनि की प्रतीक्षा करें", + "THANK_YOU_FOR_YOUR_TIME": "आपके समय के लिए धन्यवाद", + "ENSURE_THAT_RECIEVED_A_CONFIRMATION_MESSAGE": "कृपया सुनिश्चित करें कि आपको जाने से पहले एक पुष्टिकरण संदेश प्राप्त हुआ है", + "PLEASE_PUT_YOUR_FINGERS_ON_THE_FINGERPRINT_SCANNER": "कृपया अपनी उंगलियों को एक-एक करके फ़िंगरप्रिंट स्कैनर पर रखें", + "WAIT_FOR_PROMPT_AND_BEEP_SOUND_TO_REMOVE_YOUR_FINGERS": "अपनी उंगलियों को हटाने के लिए संकेत और बीप ध्वनि की प्रतीक्षा करें", + "PLEASE_VERIFY_YOUR_IDENTITY": "कृपया अपने पंजीकृत मोबाइल नंबर xxxxxxxx15 पर ओटीपी प्राप्त करके अपनी पहचान सत्यापित करें", + "SEND_OTP": "ओटीपी भेजें", + "RESEND": "फिर से भेजें", + "PLEASE_SELECT_YOUR_RESIDENCY": "कृपया अपना निवास चुनें", + "PLEASE_ENTER_VALID_EMAIL": "कृपया मान्य ईमेल दर्ज करें", + "PLEASE_SELECT_YOUR_COUNTRY": "कृपया अपना देश चुनें", + "PLEASE_SELECT_YOUR_STATE": "कृपया अपना राज्य चुनें", + "PLEASE_SELECT_YOUR_DISTRICT": "कृपया अपना जिला चुनें", + "PLEASE_ENTER_YOUR_VILLAGE": "कृपया अपने गांव में प्रवेश करें", + "PLEASE_ENTER_YOUR_HOUSE_NUMBER": "कृपया अपने घर का नंबर दर्ज करें", + "PLEASE_ENTER_YOUR_STREET": "कृपया अपनी गली में प्रवेश करें", + "PLEASE_ENTER_YOUR_LOCALITY": "कृपया अपना इलाका दर्ज करें", + "PLEASE_ENTER_YOUR_AREA_POST_OFFICE": "कृपया अपने क्षेत्र के डाकघर में प्रवेश करें", + "PLEASE_ENTER_NEAREST_LANDMARK": "कृपया निकटतम लैंडमार्क दर्ज करें", + "PLEASE_ENTER_YOUR_AREA_PINCODE": "कृपया अपने क्षेत्र का पिनकोड दर्ज करें", + "PLEASE_ENTER_VALID_PINCODE": "कृपया मान्य पिनकोड दर्ज करें", + "I_HEREBY_CONFIRM_THE_IDENTITY_AND_ADDRESS": "मैं ___________ की पहचान और पते को सत्य, सही और सटीक होने की पुष्टि करता हूं", + "PHOTOGRAPH": "फोटोग्राफ", + "FINGERPRINT_SCAN": "फिंगरप्रिंट स्कैन", + "IRIS_SCAN": "आइरिस स्कैन", + "DEMOGRAPHIC": "जनसांख्यिकीय", + "BIOMETRIC": "बायोमेट्रिक" } diff --git a/client/src/context/User.js b/client/src/context/User.js new file mode 100644 index 0000000..fce7eda --- /dev/null +++ b/client/src/context/User.js @@ -0,0 +1,28 @@ +import React, { createContext, useState, useContext } from 'react' + +export const UserContext = createContext() + +export const Context = ({ children }) => { + const [aadhaarNumber, setAadhaarNumber] = useState(null) + const [userData, setUserData] = useState({}) + + const initialUser = { + aadhaarNumber, + setAadhaarNumber, + userData, + setUserData + } + + return ( + <UserContext.Provider value={initialUser}>{children}</UserContext.Provider> + ) +} + +export const userContext = () => { + const context = useContext(UserContext) + if (!context) { + throw new Error(`userContext context can only + be used in a component wrapped with UserContext`) + } + return context +} diff --git a/client/src/index.js b/client/src/index.js index 652a231..0f8c576 100644 --- a/client/src/index.js +++ b/client/src/index.js @@ -5,6 +5,7 @@ import { QueryClient, QueryClientProvider } from 'react-query' import './index.css' import App from './App' import './i18nextInit' +import { Context } from './context/User' const queryClient = new QueryClient() @@ -13,7 +14,9 @@ root.render( <React.StrictMode> <BrowserRouter> <QueryClientProvider client={queryClient}> - <App /> + <Context> + <App /> + </Context> </QueryClientProvider> </BrowserRouter> </React.StrictMode> diff --git a/client/src/pages/Update/Demographic/Demographic.jsx b/client/src/pages/Update/Demographic/Demographic.jsx index 27a162a..5be3e3b 100644 --- a/client/src/pages/Update/Demographic/Demographic.jsx +++ b/client/src/pages/Update/Demographic/Demographic.jsx @@ -1,4 +1,6 @@ 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' @@ -11,15 +13,43 @@ import { } from '../../../components/RegEx/RegEx' import UpdateSelect from '../UpdateSelect/UpdateSelect' import { useTranslation } from 'react-i18next' +import { userContext } from '../../../context/User' const Demographic = () => { const { t } = useTranslation() + const { aadhaarNumber, userData, setUserData } = userContext() + const [page, setPage] = useState(0) + const isLongEnough = aadhaarNumber?.toString().length > 11 + + const { data } = useQuery( + ['user', aadhaarNumber], + () => getUserByAadhaar(aadhaarNumber), + { + enabled: isLongEnough, + retry: 1, + onSuccess: () => { + while (!data?.data?.name) { + console.log(formData.name) + console.log('success') + setUserData(data?.data) + console.log(data?.data) + console.log(userData?.name) + console.log(data?.data?.name) + setFormData({ + ...formData, + name: userData?.name + }) + } + } + } + ) + const [formData, setFormData] = useState({ name: '', gender: '', - dob: new Date().toISOString().slice(0, 10), + dob: '', mobile: '', email: '', country: '', @@ -31,10 +61,22 @@ const Demographic = () => { locality: '', postOffice: '', landmark: '', - pincode: '', - address: '' + pincode: '' + // address: userData?.address }) + const address = userData?.address + console.log(address) + + console.log( + 'Aadhaar: ', + aadhaarNumber, + 'Islong: ', + isLongEnough, + 'User: ', + userData + ) + const handleSubmit = () => { if (page === 0) { if (formData.name === '' || formData.name.length < 1) { diff --git a/client/src/pages/Update/Update.jsx b/client/src/pages/Update/Update.jsx index afa3bbd..eb0aa58 100644 --- a/client/src/pages/Update/Update.jsx +++ b/client/src/pages/Update/Update.jsx @@ -1,24 +1,15 @@ -import React, { useState } from 'react' +import React from 'react' import { useNavigate } from 'react-router-dom' import Header from '../../components/Header/Header' import styles from './Update.module.css' import Input from '../../components/Input/Input' -// import { useQuery } from 'react-query' import { Grid, Button } from '@mui/material' -// import { getUserByAadhaar } from '../../services/apiservice' -// import { validAadhaar } from '../../components/RegEx/RegEx' +import { userContext } from '../../context/User' const Update = () => { - const [aadhaarNumber, setAadhaarNumber] = useState() + const { aadhaarNumber, setAadhaarNumber } = userContext() const navigate = useNavigate() - // console.log(aadhaarNumber) - // const user = useQuery(['user', aadhaarNumber], () => - // getUserByAadhaar(aadhaarNumber) - // ) - - // console.log(user.data.data) - return ( <> <Header subheading="Update" /> |