|
|
|
|
|
|
|
export function extractCountry(place: string): string | null { |
|
if (!place) return null; |
|
|
|
|
|
const parts = place.split(','); |
|
let country = parts[parts.length - 1].trim(); |
|
|
|
|
|
if (['USA', 'U.S.A.', 'United States', 'United States of America'].includes(country)) { |
|
return 'USA'; |
|
} |
|
|
|
|
|
if (['UK', 'U.K.', 'United Kingdom', 'England', 'Scotland', 'Wales'].includes(country)) { |
|
return 'UK'; |
|
} |
|
|
|
|
|
if (parts.length === 1) { |
|
const knownCountries = [ |
|
'USA', 'Canada', 'China', 'Japan', 'Germany', 'France', 'UK', 'Italy', |
|
'Spain', 'Australia', 'Brazil', 'India', 'Singapore', 'South Korea', |
|
'Netherlands', 'Sweden', 'Switzerland', 'Belgium', 'Austria', 'Portugal', |
|
'UAE', 'Thailand', 'Hawaii', 'Russia', 'Lithuania' |
|
]; |
|
|
|
for (const country of knownCountries) { |
|
if (place.includes(country)) { |
|
return country; |
|
} |
|
} |
|
} |
|
|
|
return country; |
|
} |
|
|
|
|
|
|
|
|
|
export function getAllCountries(conferences: any[]): string[] { |
|
if (!Array.isArray(conferences)) return []; |
|
|
|
const countries = new Set<string>(); |
|
|
|
conferences.forEach(conf => { |
|
if (conf.country) { |
|
countries.add(conf.country); |
|
} |
|
}); |
|
|
|
return Array.from(countries).sort(); |
|
} |