Skip to content

Commit 407e1fc

Browse files
committed
Update SetPhoneNumber
1 parent 218d54f commit 407e1fc

File tree

2 files changed

+12
-22
lines changed

2 files changed

+12
-22
lines changed

app/components/UI/Card/components/Onboarding/SetPhoneNumber.test.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,8 @@ describe('SetPhoneNumber Component', () => {
312312
const countrySelect = getByTestId(
313313
'set-phone-number-country-area-code-select',
314314
);
315-
// Should show +1 for US (initial selected country)
316-
expect(countrySelect.props.selectedValue).toBe('1');
315+
// Should show country code - area code (initial selected country)
316+
expect(countrySelect.props.selectedValue).toBe('US-1');
317317
});
318318

319319
it('updates area code when different country is selected', () => {
@@ -637,8 +637,7 @@ describe('SetPhoneNumber Component', () => {
637637
const countrySelect = getByTestId(
638638
'set-phone-number-country-area-code-select',
639639
);
640-
// Should default to +1
641-
expect(countrySelect.props.selectedValue).toBe('1');
640+
expect(countrySelect.props.selectedValue).toBe('XX-1');
642641
});
643642
});
644643
});

app/components/UI/Card/components/Onboarding/SetPhoneNumber.tsx

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ const SetPhoneNumber = () => {
4545
.filter((country) => country.canSignUp)
4646
.map((country) => ({
4747
key: country.iso3166alpha2,
48-
value: country.iso3166alpha2,
49-
label: `+${country.callingCode} ${country.name}`,
48+
value: `${country.iso3166alpha2}-${country.callingCode}`,
49+
label: `${countryCodeToFlag(country.iso3166alpha2)} +${country.callingCode}`,
5050
}));
5151
}, [registrationSettings]);
5252

@@ -131,13 +131,11 @@ const SetPhoneNumber = () => {
131131
}
132132
};
133133

134-
const handleCountrySelect = (key: string) => {
134+
const handleCountrySelect = (value: string) => {
135135
resetPhoneVerificationSend();
136-
const areaCode = selectOptions.find((option) => option.key === key)?.value;
137-
if (areaCode) {
138-
setSelectedCountryAreaCode(areaCode);
139-
setSelectedCountryIsoCode(key);
140-
}
136+
const [key, areaCode] = value.split('-');
137+
setSelectedCountryAreaCode(areaCode);
138+
setSelectedCountryIsoCode(key);
141139
};
142140

143141
const handlePhoneNumberChange = (text: string) => {
@@ -182,18 +180,11 @@ const SetPhoneNumber = () => {
182180
</Label>
183181
{/* Area code selector */}
184182
<Box twClassName="flex flex-row items-center justify-center gap-2">
185-
<Box twClassName="flex flex-row items-center border border-solid border-border-default rounded-lg py-1">
186-
<Text
187-
variant={TextVariant.BodyLg}
188-
twClassName="pl-3"
189-
testID="set-phone-number-country-flag"
190-
>
191-
{countryCodeToFlag(selectedCountryIsoCode)}
192-
</Text>
193-
<Box twClassName="w-28 -ml-2">
183+
<Box twClassName="flex flex-row items-center border border-solid border-border-default rounded-lg">
184+
<Box twClassName="w-22">
194185
<SelectComponent
195186
options={selectOptions}
196-
selectedValue={selectedCountryAreaCode}
187+
selectedValue={`${selectedCountryIsoCode}-${selectedCountryAreaCode}`}
197188
onValueChange={handleCountrySelect}
198189
label={strings(
199190
'card.card_onboarding.set_phone_number.country_area_code_label',

0 commit comments

Comments
 (0)