Skip to content

Commit

Permalink
fix: geo location dropdown bugfixes in playground
Browse files Browse the repository at this point in the history
  • Loading branch information
kabilansakthivelu committed Oct 24, 2024
1 parent 03b688c commit efe9a60
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
8 changes: 7 additions & 1 deletion packages/i18nify-playground/src/pages/geo/getCities.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export default function GetCities() {

useEffect(() => {
setStateInp('');
setStateList([]);
setCityInp('');
setCities([]);
setCode('');
getStates(countryInp).then((res) => {
const states = Object.entries(res).map(([_code, state]) => ({
Expand All @@ -50,6 +53,8 @@ export default function GetCities() {

useEffect(() => {
if (!stateInp) return;
setCityInp('');
setCities([]);
getCities(countryInp, stateInp).then((res) => {
setCities(res);
setCityInp(res[0].name);
Expand Down Expand Up @@ -106,7 +111,7 @@ export default function GetCities() {
/>
<StateDropdown
value={stateInp}
onChange={(e) => setStateInp(e)}
onChange={(state) => setStateInp(state)}
list={stateList}
/>

Expand All @@ -119,6 +124,7 @@ export default function GetCities() {
marginRight: 1,
width: '100%',
}}
onChange={(e) => setCityInp(e.target.value || '')}
>
{cities.map((city) => (
<MenuItem key={city.name} value={city.name}>
Expand Down
6 changes: 4 additions & 2 deletions packages/i18nify-playground/src/pages/geo/getStates.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export default function GetStates() {
}, []);

useEffect(() => {
setStateVal('');
setStateList([]);
getStates(countryInp).then((res) => {
setCode(JSON.stringify(res, null, 2));
const data = Object.keys(res).map((stateCode) => ({
Expand Down Expand Up @@ -80,13 +82,13 @@ export default function GetStates() {
<CountryDropdown
value={countryInp}
list={countryList}
onChange={(e) => setCountryInp(e)}
onChange={(country) => setCountryInp(country)}
/>
<StateDropdown
label="List of States"
value={stateVal}
list={stateList}
onChange={(e) => setStateVal(e)}
onChange={(state) => setStateVal(state)}
/>
</Grid>
{!isMobile && (
Expand Down
8 changes: 7 additions & 1 deletion packages/i18nify-playground/src/pages/geo/getZipcodes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export default function GetZipcodes() {

useEffect(() => {
setStateInp('');
setStateList([]);
setZipcodeInp('');
setZipcodes([]);
setCode('');
getStates(countryInp).then((res) => {
const states = Object.entries(res).map(([_code, state]) => ({
Expand All @@ -50,6 +53,8 @@ export default function GetZipcodes() {

useEffect(() => {
if (!stateInp) return;
setZipcodeInp('');
setZipcodes([]);
getZipcodes(countryInp, stateInp).then((res) => {
setZipcodes(res);
setZipcodeInp(res[0]);
Expand Down Expand Up @@ -103,7 +108,7 @@ export default function GetZipcodes() {
/>
<StateDropdown
value={stateInp}
onChange={(e) => setStateInp(e)}
onChange={(state) => setStateInp(state)}
list={stateList}
/>

Expand All @@ -116,6 +121,7 @@ export default function GetZipcodes() {
marginRight: 1,
width: '100%',
}}
onChange={(e) => setZipcodeInp(e.target.value || '')}
>
{zipcodes.map((zipcode) => (
<MenuItem key={zipcode} value={zipcode}>
Expand Down

0 comments on commit efe9a60

Please sign in to comment.