39 lines
889 B
JavaScript
39 lines
889 B
JavaScript
|
|
/**
|
||
|
|
* City Enum
|
||
|
|
* Syrian cities used in property locations
|
||
|
|
* Used in: Property search filters, location display
|
||
|
|
*/
|
||
|
|
const City = Object.freeze({
|
||
|
|
DAMASCUS: 'دمشق',
|
||
|
|
ALEPPO: 'حلب',
|
||
|
|
HOMS: 'حمص',
|
||
|
|
LATAKIA: 'اللاذقية',
|
||
|
|
DARAA: 'درعا',
|
||
|
|
TARTOUS: 'طرطوس',
|
||
|
|
SUWEIDA: 'السويداء',
|
||
|
|
DEIR_EZZOR: 'دير الزور',
|
||
|
|
RAQQA: 'الرقة',
|
||
|
|
IDLIB: 'إدلب',
|
||
|
|
HASAKAH: 'الحسكة',
|
||
|
|
QAMISHLI: 'القامشلي',
|
||
|
|
RURAL_DAMASCUS: 'ريف دمشق',
|
||
|
|
});
|
||
|
|
|
||
|
|
// All cities as a flat array
|
||
|
|
const CitiesList = Object.freeze(Object.values(City));
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Extract city name from a full address string
|
||
|
|
* @param {string} address
|
||
|
|
* @returns {string}
|
||
|
|
*/
|
||
|
|
function extractCity(address) {
|
||
|
|
if (!address) return '';
|
||
|
|
for (const city of CitiesList) {
|
||
|
|
if (address.includes(city)) return city;
|
||
|
|
}
|
||
|
|
return '';
|
||
|
|
}
|
||
|
|
|
||
|
|
export { City, CitiesList, extractCity };
|