Skip to content

Commit b78c3d6

Browse files
committed
fix(hub): add missing dalas icon (#2838)
Closes FRONT-710 ## Changes - Added Dallas, Texas, USA (`tr-d`) as a new region with the US flag emoji 🇺🇸 - Improved TypeScript type safety for region-related functions and objects: - Added `satisfies Record<string, IconProp | string>` to `REGION_ICON` - Added `satisfies Record<keyof typeof REGION_ICON, string>` to `REGION_LABEL` - Updated `getRegionKey` return type to `keyof typeof REGION_ICON` - Fixed type casting in `RegionIcon` component
1 parent d8d3e8e commit b78c3d6

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

frontend/packages/components/src/matchmaker/lobby-region.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Icon, type IconProp, faComputer } from "@rivet-gg/icons";
22
import { AssetImage } from "../asset-image";
33
import { convertEmojiToUriFriendlyString } from "../lib/emoji";
44

5-
export const REGION_ICON: Record<string, string | IconProp> = {
5+
export const REGION_ICON = {
66
local: faComputer,
77
unknown: "❓",
88
atlanta: "🇺🇸", // Atlanta
@@ -48,9 +48,10 @@ export const REGION_ICON: Record<string, string | IconProp> = {
4848
gru: "🇧🇷", // Sao Paulo
4949
bom: "🇮🇳", // Mumbai
5050
sin: "🇸🇬", // Singapore
51-
};
51+
"tr-d": "🇺🇸", // Dallas
52+
} satisfies Record<string, IconProp | string>;
5253

53-
export const REGION_LABEL: Record<string, string> = {
54+
export const REGION_LABEL = {
5455
local: "Local",
5556
unknown: "Unknown",
5657
atlanta: "Atlanta, Georgia, USA",
@@ -96,19 +97,23 @@ export const REGION_LABEL: Record<string, string> = {
9697
gru: "Sao Paulo",
9798
bom: "Mumbai, India",
9899
sin: "Singapore",
99-
};
100+
"tr-d": "Dallas, Texas, USA",
101+
} satisfies Record<keyof typeof REGION_ICON, string>;
100102

101-
export function getRegionKey(regionNameId: string | undefined) {
103+
export function getRegionKey(
104+
regionNameId: string | undefined,
105+
): keyof typeof REGION_ICON {
102106
// HACK: Remove prefix for old regions with format `lnd-atl`
103107
const regionIdSplit = (regionNameId || "").split("-");
104-
return regionIdSplit[regionIdSplit.length - 1];
108+
return regionIdSplit[regionIdSplit.length - 1] as keyof typeof REGION_ICON;
105109
}
106110

107111
export function RegionIcon({
108112
region = "",
109113
...props
110114
}: { region: string | undefined; className?: string }) {
111-
const regionIcon = REGION_ICON[region] ?? REGION_ICON.unknown;
115+
const regionIcon =
116+
REGION_ICON[region as keyof typeof REGION_ICON] ?? REGION_ICON.unknown;
112117

113118
if (typeof regionIcon === "string") {
114119
return (

0 commit comments

Comments
 (0)