Skip to content

Commit 8259fb4

Browse files
committed
MP-280 sort country dropdowns
1 parent 42ba148 commit 8259fb4

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/apps/accounts/src/settings/tabs/account/address/MemberAddress.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Dispatch, FC, SetStateAction, useState } from 'react'
1+
import { Dispatch, FC, SetStateAction, useMemo, useState } from 'react'
22
import { toast } from 'react-toastify'
33
import { bind, trim } from 'lodash'
44
import classNames from 'classnames'
@@ -24,6 +24,12 @@ const MemberAddress: FC<MemberAddressProps> = (props: MemberAddressProps) => {
2424
const countryLookup: CountryLookup[] | undefined
2525
= useCountryLookup()
2626

27+
const contries = useMemo(() => (countryLookup || []).map((cl: CountryLookup) => ({
28+
label: cl.country,
29+
value: cl.countryCode,
30+
}))
31+
.sort((a, b) => a.label.localeCompare(b.label)), [countryLookup])
32+
2733
const [formValues, setFormValues]: [any, Dispatch<any>] = useState({
2834
country: props.profile.homeCountryCode || props.profile.competitionCountryCode,
2935
...props.profile.addresses ? props.profile.addresses[0] : {},
@@ -162,10 +168,7 @@ const MemberAddress: FC<MemberAddressProps> = (props: MemberAddressProps) => {
162168
value={formValues.zip}
163169
/>
164170
<InputSelect
165-
options={(countryLookup || []).map((cl: CountryLookup) => ({
166-
label: cl.country,
167-
value: cl.countryCode,
168-
}))}
171+
options={contries}
169172
value={formValues.country}
170173
onChange={bind(handleFormValueChange, this, 'country')}
171174
name='country'

src/apps/profiles/src/member-profile/local-info/ModifyLocationModal/ModifyLocationModal.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Dispatch, FC, SetStateAction, useState } from 'react'
1+
import { Dispatch, FC, SetStateAction, useMemo, useState } from 'react'
22
import { bind, trim } from 'lodash'
33
import { toast } from 'react-toastify'
44

@@ -22,6 +22,12 @@ const ModifyLocationModal: FC<ModifyLocationModalProps> = (props: ModifyLocation
2222
const countryLookup: CountryLookup[] | undefined
2323
= useCountryLookup()
2424

25+
const contries = useMemo(() => (countryLookup || []).map((cl: CountryLookup) => ({
26+
label: cl.country,
27+
value: cl.countryCode,
28+
}))
29+
.sort((a, b) => a.label.localeCompare(b.label)), [countryLookup])
30+
2531
const [formValues, setFormValues]: [any, Dispatch<any>] = useState({
2632
country: props.profile.homeCountryCode || props.profile.competitionCountryCode,
2733
...props.profile.addresses ? props.profile.addresses[0] : {},
@@ -112,10 +118,7 @@ const ModifyLocationModal: FC<ModifyLocationModalProps> = (props: ModifyLocation
112118
placeholder='Select your city name'
113119
/>
114120
<InputSelect
115-
options={(countryLookup || []).map((cl: CountryLookup) => ({
116-
label: cl.country,
117-
value: cl.countryCode,
118-
}))}
121+
options={contries}
119122
value={formValues.country}
120123
onChange={bind(handleFormValueChange, this, 'country')}
121124
name='country'

0 commit comments

Comments
 (0)