From 6b85ebee8986b982e05d49c8f1a326deb3e08bae Mon Sep 17 00:00:00 2001 From: rohan09-raj Date: Thu, 18 Aug 2022 11:43:03 +0530 Subject: Fixed components --- client/src/pages/Enrollment/Address/Address.jsx | 97 +++++++------------------ client/src/pages/Enrollment/Enrollment.jsx | 50 ++++++------- 2 files changed, 49 insertions(+), 98 deletions(-) (limited to 'client/src/pages/Enrollment') diff --git a/client/src/pages/Enrollment/Address/Address.jsx b/client/src/pages/Enrollment/Address/Address.jsx index 2e0fc6c..5324413 100644 --- a/client/src/pages/Enrollment/Address/Address.jsx +++ b/client/src/pages/Enrollment/Address/Address.jsx @@ -1,48 +1,14 @@ -import React, { useState, useEffect } from 'react' +import React from 'react' import Header from '../../../components/Header/Header' import Input from '../../../components/Input/Input' -import { Country, State, City } from 'country-state-city' +import { State, City } from 'country-state-city' import Select from 'react-select' import styles from './Address.module.css' import { useTranslation } from 'react-i18next' const Address = ({ formData, setFormData }) => { - const [tempData, setTempData] = useState({ - country: '', - state: '', - district: '' - }) const { t } = useTranslation() - const countries = Country.getAllCountries() - - useEffect(() => { - setFormData({ - ...formData, - address: { - country: { - name: tempData.country.label, - code: tempData.country.isoCode - }, - state: { - name: tempData.state.label, - code: tempData.state.isoCode - }, - district: { - name: tempData.district.label, - code: tempData.district.isoCode - } - } - }) - }, [tempData]) - - console.log('Form Data: ', formData.address) - - const updatedCountries = countries.map((country) => ({ - label: country.name, - value: country.id, - ...country - })) const updatedStates = (countryId) => State.getStatesOfCountry(countryId).map((state) => ({ @@ -81,37 +47,21 @@ const Address = ({ formData, setFormData }) => {
-
-
- - { - setTempData({ - ...tempData, - state: e + setFormData({ + ...formData, + address: { + ...formData.address, + state: e + } }) }} styles={customStyles} @@ -124,15 +74,15 @@ const Address = ({ formData, setFormData }) => {