quality / commitlint (push) Skipped
CD / update-wiki (push) Successful in 5s
quality / changes (push) Successful in 4s
quality / docker-check (push) Skipped
quality / web (push) Successful in 45s
quality / api (push) Successful in 36s
CD / quality (push) Successful in 1m30s
CD / publish (push) Successful in 1m51s
Co-authored-by: Cursor <[email protected]>
29 lines
727 B
TypeScript
29 lines
727 B
TypeScript
import { cn } from '@cdnmanager/ui/lib/utils'
|
|
import { COUNTRY_BY_NAME_RU } from '@cdnmanager/shared'
|
|
import { countryCodeFromName, getCountryFlagUrl } from '@/lib/country-labels'
|
|
|
|
interface CountryFlagProps {
|
|
code?: string
|
|
country?: string
|
|
className?: string
|
|
}
|
|
|
|
export function CountryFlag({ code, country, className }: CountryFlagProps) {
|
|
const resolvedCode =
|
|
code ??
|
|
(country
|
|
? COUNTRY_BY_NAME_RU[country.trim().toLowerCase()]?.code ??
|
|
countryCodeFromName(country)
|
|
: undefined)
|
|
const url = getCountryFlagUrl(resolvedCode)
|
|
if (!url) return null
|
|
|
|
return (
|
|
<img
|
|
src={url}
|
|
alt=""
|
|
className={cn('size-4 shrink-0 rounded-full object-cover', className)}
|
|
/>
|
|
)
|
|
}
|