Files
stash/ui/v2.5/src/components/Shared/CountryLabel.tsx
DingDongSoLong4 bd747317d4 Update dependencies (again) (#3442)
* Update dependencies
* Upgrade rollup
* Remove all index.ts reexport files
2023-02-17 09:42:44 +11:00

28 lines
639 B
TypeScript

import React from "react";
import { useIntl } from "react-intl";
import { CountryFlag } from "./CountryFlag";
import { getCountryByISO } from "src/utils/country";
interface IProps {
country: string | undefined;
showFlag?: boolean;
}
export const CountryLabel: React.FC<IProps> = ({
country,
showFlag = true,
}) => {
const { locale } = useIntl();
// #3063 - use alpha2 values only
const fromISO =
country?.length === 2 ? getCountryByISO(country, locale) : undefined;
return (
<div>
{showFlag && <CountryFlag className="mr-2" country={country} />}
<span>{fromISO ?? country}</span>
</div>
);
};