From bf6f667743007df8cef61d4825f360739546bd2a Mon Sep 17 00:00:00 2001 From: rohan09-raj Date: Fri, 26 Aug 2022 15:32:00 +0530 Subject: updated address component --- client/src/pages/Enrollment/Address/Address.jsx | 165 ++++++++++++------------ 1 file changed, 82 insertions(+), 83 deletions(-) (limited to 'client/src/pages/Enrollment/Address') diff --git a/client/src/pages/Enrollment/Address/Address.jsx b/client/src/pages/Enrollment/Address/Address.jsx index 194b66b..4028fc2 100644 --- a/client/src/pages/Enrollment/Address/Address.jsx +++ b/client/src/pages/Enrollment/Address/Address.jsx @@ -1,57 +1,25 @@ -import React from 'react' +import React, { useState } from 'react' import Header from '../../../components/Header/Header' import Input from '../../../components/Input/Input' -import { State, City } from 'country-state-city' -import Select from 'react-select' import { userContext } from '../../../context/User' import { useTranslation } from 'react-i18next' import PopUpModal from '../../../components/Modal/Modal' import AudioAutoplay from '../../../components/AudioAutoplay/AudioAutoplay' +import Pincode from 'react-pincode' import styles from './Address.module.css' const Address = () => { const { t } = useTranslation() + const [pincodeData, setPincodeData] = useState('') const { userData, setUserData } = userContext() - const updatedStates = (countryId) => - State.getStatesOfCountry(countryId).map((state) => ({ - label: state.name, - value: state.id, - ...state - })) - const updatedCities = (countryID, stateId) => - City.getCitiesOfState(countryID, stateId).map((city) => ({ - label: city.name, - value: city.id, - ...city - })) - - const customStyles = { - control: (base) => ({ - ...base, - width: '500px', - height: '80px', - margin: '10px 0px', - border: '3px solid', - fontSize: '1.5rem', - borderRadius: '10px !important' - }), - input: (base) => ({ - ...base, - display: 'flex', - justifyContent: 'center', - alignItems: 'center', - padding: '0px', - margin: '0px' - }) - } - const description = [ 'ENTER_YOUR_DETAILS_ACCORDING_TO_THE_RELEVANT_FIELDS', 'SELECT_THE_STATE_YOU_BELONG_TO_FROM_THE_DROPDOWN_LIST', 'SELECT_THE_DISTRICT_YOU_BELONG_TO_FROM_THE_DROPDOWN_LIST' ] + console.log(pincodeData) return ( <> @@ -108,25 +76,24 @@ const Address = () => { }} placeholder={t('ENTER_YOUR_VILLAGE_TOWN')} /> -
- - { + setUserData({ + ...userData, + address: { + ...userData.address, + state: { + name: e.target.value } - }) - }} - styles={customStyles} - /> -
+ } + }) + }} + placeholder={t('ENTER_YOUR_STATE')} + />
{ }} placeholder={t('ENTER_YOUR_STREET_ROAD')} /> +
+
+ + { + setUserData({ + ...userData, + address: { + ...userData.address, + pincode: e.target.value + } + }) + }} + pincodeInput={{ + width: '500px', + height: '80px', + margin: '10px 0px', + padding: '18px 10px', + border: '3px solid', + borderRadius: '10px', + fontSize: '1.5rem' + }} + getData={(data) => { + setPincodeData(data) + setUserData({ + ...userData, + address: { + ...userData.address, + pincode: data.pincode, + state: { + name: data.stateName + }, + district: { + name: data.district + }, + postOffice: data.areaName + } + }) + }} + /> +
+
{ setUserData({ ...userData, address: { ...userData.address, - postOffice: e.target.value + district: { + name: e.target.value + } } }) }} - placeholder={t('ENTER_YOUR_AREA_POST_OFFICE')} + placeholder={t('ENTER_YOUR_DISTRICT')} /> -
- - { }} placeholder={t('ENTER_YOUR_AREA_LOCALITY')} /> + { setUserData({ ...userData, address: { ...userData.address, - pincode: e.target.value + postOffice: e.target.value } }) }} - placeholder={t('ENTER_YOUR_AREA_PINCODE')} + placeholder={t('ENTER_YOUR_AREA_POST_OFFICE')} />