1 import { HttpTypes } from "@medusajs/types"
2 import { Badge, Container, Tooltip } from "@medusajs/ui"
3 import { useTranslation } from "react-i18next"
4
5 import { TaxRateLine } from "../../../common/components/tax-rate-line"
6 import { TaxRegionCard } from "../../../common/components/tax-region-card"
7
8 type TaxRegionDetailSectionProps = {
9 taxRegion: HttpTypes.AdminTaxRegion
10 }
11
12 export const TaxRegionDetailSection = ({
13 taxRegion,
14 }: TaxRegionDetailSectionProps) => {
15 const { t } = useTranslation()
16
17 const defaultRates = taxRegion.tax_rates.filter((r) => r.is_default === true)
18 const showBage = defaultRates.length === 0
19
20 return (
21 <Container className="divide-y p-0">
22 <TaxRegionCard
23 taxRegion={taxRegion}
24 type="header"
25 asLink={false}
26 badge={
27 showBage && (
28 <Tooltip content={t("taxRegions.fields.noDefaultRate.tooltip")}>
29 <Badge color="orange" size="2xsmall" className="cursor-default">
30 {t("taxRegions.fields.noDefaultRate.label")}
31 </Badge>
32 </Tooltip>
33 )
34 }
35 />
36 {defaultRates.map((rate) => {
37 return <TaxRateLine key={rate.id} taxRate={rate} />
38 })}
39 </Container>
40 )
41 }