import React, { useState } from 'react' import { useNavigate } from 'react-router-dom' import Header from '../../../components/Header/Header' import Input from '../../../components/Input/Input' import SubmitButton from '../../../components/SubmitButton/SubmitButton' import { Country, State, City } from 'country-state-city' import Select from 'react-select' import styles from './Address.module.css' const Address = () => { const [address, setAddress] = useState('') const [houseNo, setHouseNo] = useState('') const [locality, setLocality] = useState('') const [postOffice, setPostOffice] = useState('') const [street, setStreet] = useState('') const [landmark, setLandmark] = useState('') const [town, setTown] = useState('') const [pincode, setPincode] = useState('') const [state, setState] = useState('') const [country, setCountry] = useState('') const [city, setCity] = useState('') const navigate = useNavigate() const handleSubmit = () => { navigate('/enrollment/photo') const add = `${houseNo} ${locality} ${postOffice} ${street} ${landmark} ${town} ${city} ${state} ${countries} ${pincode}` setAddress({ add }) console.log(address) } const countries = Country.getAllCountries() const updatedCountries = countries.map((country) => ({ label: country.name, value: country.id, ...country })) 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, state) => ({ ...base, width: '330px', height: '60px', margin: '10px 0px', // padding: '20px 10px', border: '3px solid', borderRadius: '10px !important' }), input: (base, state) => ({ ...base, display: 'flex', justifyContent: 'center', alignItems: 'center', padding: '0px', margin: '0px' }) } return ( <>
handleSubmit()} className={styles.address}>
setTown(e.target.value)} placeholder="Enter your Village / Town" />
setHouseNo(e.target.value)} placeholder="Enter your House Number / Apartment" /> setStreet(e.target.value)} placeholder="Enter the Street / Road" /> setLocality(e.target.value)} placeholder="Enter your Area / Locality" /> setPostOffice(e.target.value)} placeholder="Enter your Village / Town" />
setLandmark(e.target.value)} placeholder="Enter the Landmark" /> setPincode(e.target.value)} placeholder="Enter your area Pincode" pattern="[0-9]+" />
) } export default Address