|
1
|
import { HttpTypes } from "@medusajs/types" |
|
2
|
import { useTranslation } from "react-i18next" |
|
3
|
|
|
4
|
import { countries as COUNTRIES } from "../../../../../lib/data/countries" |
|
5
|
import { ListSummary } from "../../../../common/list-summary" |
|
6
|
import { PlaceholderCell } from "../../common/placeholder-cell" |
|
7
|
|
|
8
|
type CountriesCellProps = { |
|
9
|
countries?: HttpTypes.AdminRegionCountry[] | null |
|
10
|
} |
|
11
|
|
|
12
|
export const CountriesCell = ({ countries }: CountriesCellProps) => { |
|
13
|
if (!countries || countries.length === 0) { |
|
14
|
return <PlaceholderCell /> |
|
15
|
} |
|
16
|
|
|
17
|
const list = countries |
|
18
|
.map( |
|
19
|
(country) => |
|
20
|
country.display_name || |
|
21
|
COUNTRIES.find((c) => c.iso_2 === country.iso_2)?.display_name |
|
22
|
) |
|
23
|
.filter(Boolean) as string[] |
|
24
|
|
|
25
|
return ( |
|
26
|
<div className="flex size-full items-center overflow-hidden"> |
|
27
|
<ListSummary list={list} /> |
|
28
|
</div> |
|
29
|
) |
|
30
|
} |
|
31
|
|
|
32
|
export const CountriesHeader = () => { |
|
33
|
const { t } = useTranslation() |
|
34
|
|
|
35
|
return ( |
|
36
|
<div className="flex size-full items-center"> |
|
37
|
<span>{t("fields.countries")}</span> |
|
38
|
</div> |
|
39
|
) |
|
40
|
} |