|
1
|
import { HandTruck, PencilSquare } from "@medusajs/icons" |
|
2
|
import { HttpTypes } from "@medusajs/types" |
|
3
|
import { Container, Heading } from "@medusajs/ui" |
|
4
|
import { Fragment } from "react" |
|
5
|
import { useTranslation } from "react-i18next" |
|
6
|
|
|
7
|
import { ActionMenu } from "../../../../../components/common/action-menu" |
|
8
|
import { NoRecords } from "../../../../../components/common/empty-table-content" |
|
9
|
import { IconAvatar } from "../../../../../components/common/icon-avatar" |
|
10
|
import { useFulfillmentProviders } from "../../../../../hooks/api" |
|
11
|
import { formatProvider } from "../../../../../lib/format-provider" |
|
12
|
|
|
13
|
type LocationsFulfillmentProvidersSectionProps = { |
|
14
|
location: HttpTypes.AdminStockLocation |
|
15
|
} |
|
16
|
|
|
17
|
function LocationsFulfillmentProvidersSection({ |
|
18
|
location, |
|
19
|
}: LocationsFulfillmentProvidersSectionProps) { |
|
20
|
const { t } = useTranslation() |
|
21
|
const { fulfillment_providers } = useFulfillmentProviders({ |
|
22
|
stock_location_id: location.id, |
|
23
|
fields: "id", |
|
24
|
is_enabled: true, |
|
25
|
}) |
|
26
|
|
|
27
|
return ( |
|
28
|
<Container className="flex flex-col px-6 py-4"> |
|
29
|
<div className="flex items-center justify-between"> |
|
30
|
<Heading level="h2"> |
|
31
|
{t("stockLocations.fulfillmentProviders.header")} |
|
32
|
</Heading> |
|
33
|
|
|
34
|
<ActionMenu |
|
35
|
groups={[ |
|
36
|
{ |
|
37
|
actions: [ |
|
38
|
{ |
|
39
|
label: t("actions.edit"), |
|
40
|
to: "fulfillment-providers", |
|
41
|
icon: <PencilSquare />, |
|
42
|
}, |
|
43
|
], |
|
44
|
}, |
|
45
|
]} |
|
46
|
/> |
|
47
|
</div> |
|
48
|
|
|
49
|
{fulfillment_providers?.length ? ( |
|
50
|
<div className="flex flex-col gap-y-4 pt-4"> |
|
51
|
<div className="grid grid-cols-[28px_1fr] items-center gap-x-3 gap-y-3"> |
|
52
|
{fulfillment_providers?.map((fulfillmentProvider) => { |
|
53
|
return ( |
|
54
|
<Fragment key={fulfillmentProvider.id}> |
|
55
|
<IconAvatar> |
|
56
|
<HandTruck className="text-ui-fg-subtle" /> |
|
57
|
</IconAvatar> |
|
58
|
|
|
59
|
<div className="txt-compact-small"> |
|
60
|
{formatProvider(fulfillmentProvider.id)} |
|
61
|
</div> |
|
62
|
</Fragment> |
|
63
|
) |
|
64
|
})} |
|
65
|
</div> |
|
66
|
</div> |
|
67
|
) : ( |
|
68
|
<NoRecords |
|
69
|
className="h-fit pb-2 pt-6 text-center" |
|
70
|
action={{ |
|
71
|
label: t("stockLocations.fulfillmentProviders.action"), |
|
72
|
to: "fulfillment-providers", |
|
73
|
}} |
|
74
|
message={t("stockLocations.fulfillmentProviders.noProviders")} |
|
75
|
/> |
|
76
|
)} |
|
77
|
</Container> |
|
78
|
) |
|
79
|
} |
|
80
|
|
|
81
|
export default LocationsFulfillmentProvidersSection |