Skip to content

Commit 3b87896

Browse files
committed
show US first in CountryCombobox
1 parent 119bdea commit 3b87896

2 files changed

Lines changed: 18 additions & 11 deletions

File tree

apps/web/ui/modals/link-builder/targeting-modal.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ function TargetingModal({
174174
setValue("geo", newGeo, { shouldDirty: true });
175175
}}
176176
options={Object.entries(COUNTRIES)
177+
// show United States first
178+
.sort((a, b) =>
179+
a[0] === "US" ? -1 : b[0] === "US" ? 1 : 0,
180+
)
177181
.filter(
178182
([ck]) =>
179183
ck === key || !Object.keys(geo).includes(ck),

apps/web/ui/partners/country-combobox.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,20 @@ export function CountryCombobox({
1515
}) {
1616
const options = useMemo(
1717
() =>
18-
Object.entries(COUNTRIES).map(([key, value]) => ({
19-
icon: (
20-
<img
21-
alt={value}
22-
src={`https://hatscripts.github.io/circle-flags/flags/${key.toLowerCase()}.svg`}
23-
className="mr-1.5 size-4"
24-
/>
25-
),
26-
value: key,
27-
label: value,
28-
})),
18+
Object.entries(COUNTRIES)
19+
// show United States first
20+
.sort((a, b) => (a[0] === "US" ? -1 : b[0] === "US" ? 1 : 0))
21+
.map(([key, value]) => ({
22+
icon: (
23+
<img
24+
alt={value}
25+
src={`https://hatscripts.github.io/circle-flags/flags/${key.toLowerCase()}.svg`}
26+
className="mr-1.5 size-4"
27+
/>
28+
),
29+
value: key,
30+
label: value,
31+
})),
2932
[],
3033
);
3134

0 commit comments

Comments
 (0)