add list of cities for car pick drop off locations

This commit is contained in:
root
2026-06-29 20:32:08 -04:00
parent 85d1aad956
commit e1e2f55c93
6 changed files with 10757 additions and 54 deletions
+31
View File
@@ -0,0 +1,31 @@
import citiesDataset from '@/data/morocco-cities-rgph-2024.json'
export type SupportedCityLocale = 'en' | 'fr' | 'ar'
interface LocalizedName {
en: string
fr: string
ar: string
}
interface MoroccanCity {
id: string
name: LocalizedName
province: LocalizedName
}
interface MoroccanCitiesDataset {
cities: MoroccanCity[]
}
export function getMoroccanCityOptions(locale: string) {
const resolvedLocale: SupportedCityLocale = locale === 'fr' || locale === 'ar' ? locale : 'en'
const cityNames = (citiesDataset as MoroccanCitiesDataset).cities.map((city) => city.name[resolvedLocale])
return Array.from(new Set(cityNames)).sort((a, b) => a.localeCompare(b, resolvedLocale))
}
export function mergeLocationOptions(options: string[], selectedLocations: string[]) {
const selected = selectedLocations.map((location) => location.trim()).filter(Boolean)
return Array.from(new Set([...selected, ...options]))
}