Files
CapaKraken/packages/db/src/holiday-demo-profiles.ts
T

40 lines
1.6 KiB
TypeScript

export type HolidayDemoProfile = {
countryCode: "DE" | "ES" | "IN" | "US";
stateCode: string | null;
cityName: string;
};
export const HOLIDAY_DEMO_PROFILES: HolidayDemoProfile[] = [
{ countryCode: "DE", stateCode: "BW", cityName: "Stuttgart" },
{ countryCode: "DE", stateCode: "BY", cityName: "Muenchen" },
{ countryCode: "DE", stateCode: "NW", cityName: "Koeln" },
{ countryCode: "DE", stateCode: "HH", cityName: "Hamburg" },
{ countryCode: "DE", stateCode: "BE", cityName: "Berlin" },
{ countryCode: "DE", stateCode: "BY", cityName: "Augsburg" },
{ countryCode: "ES", stateCode: "MD", cityName: "Madrid" },
{ countryCode: "ES", stateCode: "CT", cityName: "Barcelona" },
{ countryCode: "IN", stateCode: "KA", cityName: "Bangalore" },
{ countryCode: "IN", stateCode: "MH", cityName: "Mumbai" },
{ countryCode: "US", stateCode: "CA", cityName: "Los Angeles" },
{ countryCode: "US", stateCode: "NY", cityName: "New York" },
];
export function getHolidayDemoProfileForIndex(index: number): HolidayDemoProfile {
return HOLIDAY_DEMO_PROFILES[index % HOLIDAY_DEMO_PROFILES.length]!;
}
export function getHolidayDemoCityNamesByCountry() {
const grouped = new Map<string, Set<string>>();
for (const profile of HOLIDAY_DEMO_PROFILES) {
const cityNames = grouped.get(profile.countryCode) ?? new Set<string>();
cityNames.add(profile.cityName);
grouped.set(profile.countryCode, cityNames);
}
return Object.fromEntries(
[...grouped.entries()]
.map(([countryCode, cityNames]) => [countryCode, [...cityNames].sort()] as const),
) as Record<HolidayDemoProfile["countryCode"], string[]>;
}