@voyantjs/resources-ui 0.16.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,125 +1,140 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { formatSelectionLabel, labelById, } from "@voyantjs/resources-react";
2
+ import { formatMessage } from "@voyantjs/i18n";
3
+ import { labelById, } from "@voyantjs/resources-react";
3
4
  import { Badge, Button, ConfirmActionButton, SelectionActionBar } from "@voyantjs/ui/components";
4
5
  import { DataTable } from "@voyantjs/ui/components/data-table";
5
6
  import { DataTableColumnHeader } from "@voyantjs/ui/components/data-table-column-header";
6
7
  import { TabsContent } from "@voyantjs/ui/components/tabs";
7
8
  import { ExternalLink } from "lucide-react";
9
+ import { useResourcesUiI18nOrDefault } from "../i18n";
10
+ import { formatSelectionLabel, formatSelectionSummary } from "../i18n/utils";
8
11
  import { ResourcesSectionHeader } from "./resources-section-header";
9
- const resourceColumns = (suppliers, onView) => [
12
+ const resourceColumns = (i18n, suppliers, onView) => [
10
13
  {
11
14
  accessorKey: "name",
12
- header: ({ column }) => _jsx(DataTableColumnHeader, { column: column, title: "Resource" }),
15
+ header: ({ column }) => (_jsx(DataTableColumnHeader, { column: column, title: i18n.messages.tabsPrimary.columns.resources.name })),
13
16
  },
14
17
  {
15
18
  accessorKey: "kind",
16
- header: ({ column }) => _jsx(DataTableColumnHeader, { column: column, title: "Kind" }),
17
- cell: ({ row }) => (_jsx(Badge, { variant: "outline", className: "capitalize", children: row.original.kind })),
19
+ header: ({ column }) => (_jsx(DataTableColumnHeader, { column: column, title: i18n.messages.tabsPrimary.columns.resources.kind })),
20
+ cell: ({ row }) => (_jsx(Badge, { variant: "outline", children: i18n.messages.common.resourceKindLabels[row.original.kind] })),
18
21
  },
19
22
  {
20
23
  accessorKey: "supplierId",
21
- header: ({ column }) => _jsx(DataTableColumnHeader, { column: column, title: "Supplier" }),
24
+ header: ({ column }) => (_jsx(DataTableColumnHeader, { column: column, title: i18n.messages.tabsPrimary.columns.resources.supplier })),
22
25
  cell: ({ row }) => labelById(suppliers, row.original.supplierId),
23
26
  },
24
27
  {
25
28
  accessorKey: "capacity",
26
- header: ({ column }) => _jsx(DataTableColumnHeader, { column: column, title: "Capacity" }),
27
- cell: ({ row }) => row.original.capacity ?? "-",
29
+ header: ({ column }) => (_jsx(DataTableColumnHeader, { column: column, title: i18n.messages.tabsPrimary.columns.resources.capacity })),
30
+ cell: ({ row }) => row.original.capacity === null ? "-" : i18n.formatNumber(row.original.capacity),
28
31
  },
29
32
  {
30
33
  accessorKey: "active",
31
- header: ({ column }) => _jsx(DataTableColumnHeader, { column: column, title: "Status" }),
32
- cell: ({ row }) => (_jsx(Badge, { variant: row.original.active ? "default" : "secondary", children: row.original.active ? "Active" : "Inactive" })),
34
+ header: ({ column }) => (_jsx(DataTableColumnHeader, { column: column, title: i18n.messages.tabsPrimary.columns.resources.status })),
35
+ cell: ({ row }) => (_jsx(Badge, { variant: row.original.active ? "default" : "secondary", children: row.original.active ? i18n.messages.common.active : i18n.messages.common.inactive })),
33
36
  },
34
37
  {
35
38
  id: "view",
36
- header: "View",
39
+ header: i18n.messages.tabsPrimary.columns.resources.view,
37
40
  cell: ({ row }) => (_jsxs(Button, { variant: "ghost", size: "sm", onClick: (event) => {
38
41
  event.stopPropagation();
39
42
  onView(row.original.id);
40
- }, children: [_jsx(ExternalLink, { className: "mr-2 h-4 w-4" }), "Open"] })),
43
+ }, children: [_jsx(ExternalLink, { className: "mr-2 h-4 w-4" }), i18n.messages.common.open] })),
41
44
  },
42
45
  ];
43
- const poolColumns = (products, onView) => [
46
+ const poolColumns = (i18n, products, onView) => [
44
47
  {
45
48
  accessorKey: "name",
46
- header: ({ column }) => _jsx(DataTableColumnHeader, { column: column, title: "Pool" }),
49
+ header: ({ column }) => (_jsx(DataTableColumnHeader, { column: column, title: i18n.messages.tabsPrimary.columns.pools.name })),
47
50
  },
48
51
  {
49
52
  accessorKey: "kind",
50
- header: ({ column }) => _jsx(DataTableColumnHeader, { column: column, title: "Kind" }),
51
- cell: ({ row }) => (_jsx(Badge, { variant: "outline", className: "capitalize", children: row.original.kind })),
53
+ header: ({ column }) => (_jsx(DataTableColumnHeader, { column: column, title: i18n.messages.tabsPrimary.columns.pools.kind })),
54
+ cell: ({ row }) => (_jsx(Badge, { variant: "outline", children: i18n.messages.common.resourceKindLabels[row.original.kind] })),
52
55
  },
53
56
  {
54
57
  accessorKey: "productId",
55
- header: ({ column }) => _jsx(DataTableColumnHeader, { column: column, title: "Product" }),
58
+ header: ({ column }) => (_jsx(DataTableColumnHeader, { column: column, title: i18n.messages.tabsPrimary.columns.pools.product })),
56
59
  cell: ({ row }) => labelById(products, row.original.productId),
57
60
  },
58
61
  {
59
62
  accessorKey: "sharedCapacity",
60
- header: ({ column }) => _jsx(DataTableColumnHeader, { column: column, title: "Shared Capacity" }),
61
- cell: ({ row }) => row.original.sharedCapacity ?? "-",
63
+ header: ({ column }) => (_jsx(DataTableColumnHeader, { column: column, title: i18n.messages.tabsPrimary.columns.pools.sharedCapacity })),
64
+ cell: ({ row }) => row.original.sharedCapacity === null ? "-" : i18n.formatNumber(row.original.sharedCapacity),
62
65
  },
63
66
  {
64
67
  id: "view",
65
- header: "View",
68
+ header: i18n.messages.tabsPrimary.columns.pools.view,
66
69
  cell: ({ row }) => (_jsxs(Button, { variant: "ghost", size: "sm", onClick: (event) => {
67
70
  event.stopPropagation();
68
71
  onView(row.original.id);
69
- }, children: [_jsx(ExternalLink, { className: "mr-2 h-4 w-4" }), "Open"] })),
72
+ }, children: [_jsx(ExternalLink, { className: "mr-2 h-4 w-4" }), i18n.messages.common.open] })),
70
73
  },
71
74
  ];
72
- const allocationColumns = (pools, products, onView) => [
75
+ const allocationColumns = (i18n, pools, products, onView) => [
73
76
  {
74
77
  accessorKey: "poolId",
75
- header: ({ column }) => _jsx(DataTableColumnHeader, { column: column, title: "Pool" }),
78
+ header: ({ column }) => (_jsx(DataTableColumnHeader, { column: column, title: i18n.messages.tabsPrimary.columns.allocations.pool })),
76
79
  cell: ({ row }) => labelById(pools, row.original.poolId),
77
80
  },
78
81
  {
79
82
  accessorKey: "productId",
80
- header: ({ column }) => _jsx(DataTableColumnHeader, { column: column, title: "Product" }),
83
+ header: ({ column }) => (_jsx(DataTableColumnHeader, { column: column, title: i18n.messages.tabsPrimary.columns.allocations.product })),
81
84
  cell: ({ row }) => labelById(products, row.original.productId),
82
85
  },
83
86
  {
84
87
  accessorKey: "allocationMode",
85
- header: ({ column }) => _jsx(DataTableColumnHeader, { column: column, title: "Mode" }),
86
- cell: ({ row }) => (_jsx(Badge, { variant: "outline", className: "capitalize", children: row.original.allocationMode })),
88
+ header: ({ column }) => (_jsx(DataTableColumnHeader, { column: column, title: i18n.messages.tabsPrimary.columns.allocations.mode })),
89
+ cell: ({ row }) => (_jsx(Badge, { variant: "outline", children: i18n.messages.common.allocationModeLabels[row.original.allocationMode] })),
87
90
  },
88
91
  {
89
92
  accessorKey: "quantityRequired",
90
- header: ({ column }) => _jsx(DataTableColumnHeader, { column: column, title: "Qty Required" }),
93
+ header: ({ column }) => (_jsx(DataTableColumnHeader, { column: column, title: i18n.messages.tabsPrimary.columns.allocations.quantityRequired })),
94
+ cell: ({ row }) => i18n.formatNumber(row.original.quantityRequired),
91
95
  },
92
96
  {
93
97
  accessorKey: "priority",
94
- header: ({ column }) => _jsx(DataTableColumnHeader, { column: column, title: "Priority" }),
98
+ header: ({ column }) => (_jsx(DataTableColumnHeader, { column: column, title: i18n.messages.tabsPrimary.columns.allocations.priority })),
99
+ cell: ({ row }) => i18n.formatNumber(row.original.priority),
95
100
  },
96
101
  {
97
102
  id: "view",
98
- header: "View",
103
+ header: i18n.messages.tabsPrimary.columns.allocations.view,
99
104
  cell: ({ row }) => (_jsxs(Button, { variant: "ghost", size: "sm", onClick: (event) => {
100
105
  event.stopPropagation();
101
106
  onView(row.original.id);
102
- }, children: [_jsx(ExternalLink, { className: "mr-2 h-4 w-4" }), "Open"] })),
107
+ }, children: [_jsx(ExternalLink, { className: "mr-2 h-4 w-4" }), i18n.messages.common.open] })),
103
108
  },
104
109
  ];
105
110
  export function ResourcesTab(props) {
106
- return (_jsxs(TabsContent, { value: "resources", className: "space-y-4", children: [_jsx(ResourcesSectionHeader, { title: "Resources", description: "Guides, vehicles, rooms, and other assignable assets.", actionLabel: "New Resource", onAction: props.onCreate }), _jsx(DataTable, { columns: resourceColumns(props.suppliers, props.onOpenRoute), data: props.filteredResources, emptyMessage: "No resources match the current filters.", enableRowSelection: true, getRowId: (row) => row.id, rowSelection: props.resourceSelection, onRowSelectionChange: props.setResourceSelection, renderSelectionActions: ({ selectedRows, clearSelection }) => (_jsxs(SelectionActionBar, { selectedCount: selectedRows.length, onClear: clearSelection, children: [_jsx(ConfirmActionButton, { buttonLabel: "Activate", confirmLabel: "Activate Resources", title: `Activate ${formatSelectionLabel(selectedRows.length, "resource")}?`, description: "This makes the selected resources available again for assignment and planning.", disabled: props.bulkActionTarget === "resources-activate", onConfirm: () => props.handleBulkUpdate({
111
+ const i18n = useResourcesUiI18nOrDefault();
112
+ const m = i18n.messages;
113
+ const section = m.tabsPrimary.sections.resources;
114
+ const selection = m.common.selectionNouns.resource;
115
+ return (_jsxs(TabsContent, { value: "resources", className: "space-y-4", children: [_jsx(ResourcesSectionHeader, { title: section.title, description: section.description, actionLabel: section.actionLabel, onAction: props.onCreate }), _jsx(DataTable, { columns: resourceColumns(i18n, props.suppliers, props.onOpenRoute), data: props.filteredResources, emptyMessage: section.emptyMessage, enableRowSelection: true, getRowId: (row) => row.id, rowSelection: props.resourceSelection, onRowSelectionChange: props.setResourceSelection, renderSelectionActions: ({ selectedRows, clearSelection }) => (_jsxs(SelectionActionBar, { selectedCount: selectedRows.length, onClear: clearSelection, clearLabel: m.common.clearSelection, selectionSummary: formatSelectionSummary(selectedRows.length, m.common.selectionSummary), children: [_jsx(ConfirmActionButton, { buttonLabel: section.actions.activate.buttonLabel, confirmLabel: section.actions.activate.confirmLabel, cancelLabel: m.common.cancel, title: formatMessage(section.actions.activate.title, {
116
+ selection: formatSelectionLabel(selectedRows.length, selection, m.common.selectionLabel),
117
+ }), description: section.actions.activate.description, disabled: props.bulkActionTarget === "resources-activate", onConfirm: () => props.handleBulkUpdate({
107
118
  ids: selectedRows.map((row) => row.original.id),
108
119
  endpoint: "/v1/resources/resources",
109
120
  target: "resources-activate",
110
121
  noun: "resource",
111
122
  payload: { active: true },
112
- successVerb: "Activated",
123
+ successVerb: section.actions.activate.successVerb,
113
124
  clearSelection,
114
- }) }), _jsx(ConfirmActionButton, { buttonLabel: "Deactivate", confirmLabel: "Deactivate Resources", title: `Deactivate ${formatSelectionLabel(selectedRows.length, "resource")}?`, description: "This preserves the selected resources but removes them from active operational use.", disabled: props.bulkActionTarget === "resources-deactivate", onConfirm: () => props.handleBulkUpdate({
125
+ }) }), _jsx(ConfirmActionButton, { buttonLabel: section.actions.deactivate.buttonLabel, confirmLabel: section.actions.deactivate.confirmLabel, cancelLabel: m.common.cancel, title: formatMessage(section.actions.deactivate.title, {
126
+ selection: formatSelectionLabel(selectedRows.length, selection, m.common.selectionLabel),
127
+ }), description: section.actions.deactivate.description, disabled: props.bulkActionTarget === "resources-deactivate", onConfirm: () => props.handleBulkUpdate({
115
128
  ids: selectedRows.map((row) => row.original.id),
116
129
  endpoint: "/v1/resources/resources",
117
130
  target: "resources-deactivate",
118
131
  noun: "resource",
119
132
  payload: { active: false },
120
- successVerb: "Deactivated",
133
+ successVerb: section.actions.deactivate.successVerb,
121
134
  clearSelection,
122
- }) }), _jsx(ConfirmActionButton, { buttonLabel: "Delete Selected", confirmLabel: "Delete Resources", title: `Delete ${formatSelectionLabel(selectedRows.length, "resource")}?`, description: "This permanently removes the selected resources. Use Deactivate if you only need to take them out of rotation.", disabled: props.bulkActionTarget === "resources-delete", variant: "destructive", confirmVariant: "destructive", onConfirm: () => props.handleBulkDelete({
135
+ }) }), _jsx(ConfirmActionButton, { buttonLabel: section.actions.delete.buttonLabel, confirmLabel: section.actions.delete.confirmLabel, cancelLabel: m.common.cancel, title: formatMessage(section.actions.delete.title, {
136
+ selection: formatSelectionLabel(selectedRows.length, selection, m.common.selectionLabel),
137
+ }), description: section.actions.delete.description, disabled: props.bulkActionTarget === "resources-delete", variant: "destructive", confirmVariant: "destructive", onConfirm: () => props.handleBulkDelete({
123
138
  ids: selectedRows.map((row) => row.original.id),
124
139
  endpoint: "/v1/resources/resources",
125
140
  target: "resources-delete",
@@ -128,23 +143,33 @@ export function ResourcesTab(props) {
128
143
  }) })] })), onRowClick: (row) => props.onEdit(row.original) })] }));
129
144
  }
130
145
  export function PoolsTab(props) {
131
- return (_jsxs(TabsContent, { value: "pools", className: "space-y-4", children: [_jsx(ResourcesSectionHeader, { title: "Pools", description: "Shared capacity groups by product or operational need.", actionLabel: "New Pool", onAction: props.onCreate }), _jsx(DataTable, { columns: poolColumns(props.products, props.onOpenRoute), data: props.filteredPools, emptyMessage: "No pools match the current filters.", enableRowSelection: true, getRowId: (row) => row.id, rowSelection: props.poolSelection, onRowSelectionChange: props.setPoolSelection, renderSelectionActions: ({ selectedRows, clearSelection }) => (_jsxs(SelectionActionBar, { selectedCount: selectedRows.length, onClear: clearSelection, children: [_jsx(ConfirmActionButton, { buttonLabel: "Activate", confirmLabel: "Activate Pools", title: `Activate ${formatSelectionLabel(selectedRows.length, "pool")}?`, description: "This re-enables the selected resource pools for live capacity planning.", disabled: props.bulkActionTarget === "pools-activate", onConfirm: () => props.handleBulkUpdate({
146
+ const i18n = useResourcesUiI18nOrDefault();
147
+ const m = i18n.messages;
148
+ const section = m.tabsPrimary.sections.pools;
149
+ const selection = m.common.selectionNouns.pool;
150
+ return (_jsxs(TabsContent, { value: "pools", className: "space-y-4", children: [_jsx(ResourcesSectionHeader, { title: section.title, description: section.description, actionLabel: section.actionLabel, onAction: props.onCreate }), _jsx(DataTable, { columns: poolColumns(i18n, props.products, props.onOpenRoute), data: props.filteredPools, emptyMessage: section.emptyMessage, enableRowSelection: true, getRowId: (row) => row.id, rowSelection: props.poolSelection, onRowSelectionChange: props.setPoolSelection, renderSelectionActions: ({ selectedRows, clearSelection }) => (_jsxs(SelectionActionBar, { selectedCount: selectedRows.length, onClear: clearSelection, clearLabel: m.common.clearSelection, selectionSummary: formatSelectionSummary(selectedRows.length, m.common.selectionSummary), children: [_jsx(ConfirmActionButton, { buttonLabel: section.actions.activate.buttonLabel, confirmLabel: section.actions.activate.confirmLabel, cancelLabel: m.common.cancel, title: formatMessage(section.actions.activate.title, {
151
+ selection: formatSelectionLabel(selectedRows.length, selection, m.common.selectionLabel),
152
+ }), description: section.actions.activate.description, disabled: props.bulkActionTarget === "pools-activate", onConfirm: () => props.handleBulkUpdate({
132
153
  ids: selectedRows.map((row) => row.original.id),
133
154
  endpoint: "/v1/resources/pools",
134
155
  target: "pools-activate",
135
156
  noun: "pool",
136
157
  payload: { active: true },
137
- successVerb: "Activated",
158
+ successVerb: section.actions.activate.successVerb,
138
159
  clearSelection,
139
- }) }), _jsx(ConfirmActionButton, { buttonLabel: "Deactivate", confirmLabel: "Deactivate Pools", title: `Deactivate ${formatSelectionLabel(selectedRows.length, "pool")}?`, description: "This keeps the selected pools for reference but removes them from active planning.", disabled: props.bulkActionTarget === "pools-deactivate", onConfirm: () => props.handleBulkUpdate({
160
+ }) }), _jsx(ConfirmActionButton, { buttonLabel: section.actions.deactivate.buttonLabel, confirmLabel: section.actions.deactivate.confirmLabel, cancelLabel: m.common.cancel, title: formatMessage(section.actions.deactivate.title, {
161
+ selection: formatSelectionLabel(selectedRows.length, selection, m.common.selectionLabel),
162
+ }), description: section.actions.deactivate.description, disabled: props.bulkActionTarget === "pools-deactivate", onConfirm: () => props.handleBulkUpdate({
140
163
  ids: selectedRows.map((row) => row.original.id),
141
164
  endpoint: "/v1/resources/pools",
142
165
  target: "pools-deactivate",
143
166
  noun: "pool",
144
167
  payload: { active: false },
145
- successVerb: "Deactivated",
168
+ successVerb: section.actions.deactivate.successVerb,
146
169
  clearSelection,
147
- }) }), _jsx(ConfirmActionButton, { buttonLabel: "Delete Selected", confirmLabel: "Delete Pools", title: `Delete ${formatSelectionLabel(selectedRows.length, "pool")}?`, description: "This permanently removes the selected pools and any pool-level grouping they provide.", disabled: props.bulkActionTarget === "pools-delete", variant: "destructive", confirmVariant: "destructive", onConfirm: () => props.handleBulkDelete({
170
+ }) }), _jsx(ConfirmActionButton, { buttonLabel: section.actions.delete.buttonLabel, confirmLabel: section.actions.delete.confirmLabel, cancelLabel: m.common.cancel, title: formatMessage(section.actions.delete.title, {
171
+ selection: formatSelectionLabel(selectedRows.length, selection, m.common.selectionLabel),
172
+ }), description: section.actions.delete.description, disabled: props.bulkActionTarget === "pools-delete", variant: "destructive", confirmVariant: "destructive", onConfirm: () => props.handleBulkDelete({
148
173
  ids: selectedRows.map((row) => row.original.id),
149
174
  endpoint: "/v1/resources/pools",
150
175
  target: "pools-delete",
@@ -153,7 +178,13 @@ export function PoolsTab(props) {
153
178
  }) })] })), onRowClick: (row) => props.onEdit(row.original) })] }));
154
179
  }
155
180
  export function AllocationsTab(props) {
156
- return (_jsxs(TabsContent, { value: "allocations", className: "space-y-4", children: [_jsx(ResourcesSectionHeader, { title: "Allocations", description: "Attach pools to products, rules, and start times.", actionLabel: "New Allocation", onAction: props.onCreate }), _jsx(DataTable, { columns: allocationColumns(props.pools, props.products, props.onOpenRoute), data: props.filteredAllocations, emptyMessage: "No allocations match the current filters.", enableRowSelection: true, getRowId: (row) => row.id, rowSelection: props.allocationSelection, onRowSelectionChange: props.setAllocationSelection, renderSelectionActions: ({ selectedRows, clearSelection }) => (_jsx(SelectionActionBar, { selectedCount: selectedRows.length, onClear: clearSelection, children: _jsx(ConfirmActionButton, { buttonLabel: "Delete Selected", confirmLabel: "Delete Allocations", title: `Delete ${formatSelectionLabel(selectedRows.length, "allocation")}?`, description: "This permanently removes the selected allocation rules from resource planning.", disabled: props.bulkActionTarget === "allocations-delete", variant: "destructive", confirmVariant: "destructive", onConfirm: () => props.handleBulkDelete({
181
+ const i18n = useResourcesUiI18nOrDefault();
182
+ const m = i18n.messages;
183
+ const section = m.tabsPrimary.sections.allocations;
184
+ const selection = m.common.selectionNouns.allocation;
185
+ return (_jsxs(TabsContent, { value: "allocations", className: "space-y-4", children: [_jsx(ResourcesSectionHeader, { title: section.title, description: section.description, actionLabel: section.actionLabel, onAction: props.onCreate }), _jsx(DataTable, { columns: allocationColumns(i18n, props.pools, props.products, props.onOpenRoute), data: props.filteredAllocations, emptyMessage: section.emptyMessage, enableRowSelection: true, getRowId: (row) => row.id, rowSelection: props.allocationSelection, onRowSelectionChange: props.setAllocationSelection, renderSelectionActions: ({ selectedRows, clearSelection }) => (_jsx(SelectionActionBar, { selectedCount: selectedRows.length, onClear: clearSelection, clearLabel: m.common.clearSelection, selectionSummary: formatSelectionSummary(selectedRows.length, m.common.selectionSummary), children: _jsx(ConfirmActionButton, { buttonLabel: section.actions.delete.buttonLabel, confirmLabel: section.actions.delete.confirmLabel, cancelLabel: m.common.cancel, title: formatMessage(section.actions.delete.title, {
186
+ selection: formatSelectionLabel(selectedRows.length, selection, m.common.selectionLabel),
187
+ }), description: section.actions.delete.description, disabled: props.bulkActionTarget === "allocations-delete", variant: "destructive", confirmVariant: "destructive", onConfirm: () => props.handleBulkDelete({
157
188
  ids: selectedRows.map((row) => row.original.id),
158
189
  endpoint: "/v1/resources/allocations",
159
190
  target: "allocations-delete",
@@ -1 +1 @@
1
- {"version":3,"file":"resources-tabs-secondary.d.ts","sourceRoot":"","sources":["../../src/components/resources-tabs-secondary.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,UAAU,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACrF,OAAO,EACL,KAAK,aAAa,EAIlB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,KAAK,yBAAyB,EAC9B,KAAK,UAAU,EAEhB,MAAM,2BAA2B,CAAA;AAQlC,KAAK,MAAM,GAAG,CA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,EAAE,UAAU,EAAE,CAAA;IACnB,SAAS,EAAE,WAAW,EAAE,CAAA;IACxB,QAAQ,EAAE,aAAa,EAAE,CAAA;IACzB,mBAAmB,EAAE,yBAAyB,EAAE,CAAA;IAChD,mBAAmB,EAAE,iBAAiB,CAAA;IACtC,sBAAsB,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAA;IACrD,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,gBAAgB,EAAE,MAAM,CAAA;IACxB,gBAAgB,EAAE,QAAQ,CAAA;IAC1B,QAAQ,EAAE,MAAM,IAAI,CAAA;IACpB,WAAW,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAA;IAC3C,MAAM,EAAE,CAAC,GAAG,EAAE,yBAAyB,KAAK,IAAI,CAAA;CACjD,2CAuHA;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,SAAS,EAAE,WAAW,EAAE,CAAA;IACxB,iBAAiB,EAAE,mBAAmB,EAAE,CAAA;IACxC,iBAAiB,EAAE,iBAAiB,CAAA;IACpC,oBAAoB,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAA;IACnD,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,gBAAgB,EAAE,QAAQ,CAAA;IAC1B,QAAQ,EAAE,MAAM,IAAI,CAAA;IACpB,MAAM,EAAE,CAAC,GAAG,EAAE,mBAAmB,KAAK,IAAI,CAAA;CAC3C,2CA+DA"}
@@ -1,95 +1,120 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { formatDateTime, formatSelectionLabel, labelById, slotLabel, } from "@voyantjs/resources-react";
2
+ import { formatMessage } from "@voyantjs/i18n";
3
+ import { labelById, } from "@voyantjs/resources-react";
3
4
  import { Badge, Button, ConfirmActionButton, SelectionActionBar } from "@voyantjs/ui/components";
4
5
  import { DataTable } from "@voyantjs/ui/components/data-table";
5
6
  import { DataTableColumnHeader } from "@voyantjs/ui/components/data-table-column-header";
6
7
  import { TabsContent } from "@voyantjs/ui/components/tabs";
7
8
  import { ExternalLink } from "lucide-react";
9
+ import { useResourcesUiI18nOrDefault } from "../i18n";
10
+ import { formatDateTimeOrFallback, formatResourceSlotLabel, formatSelectionLabel, formatSelectionSummary, } from "../i18n/utils";
8
11
  import { ResourcesSectionHeader } from "./resources-section-header";
9
- const assignmentColumns = (slots, resources, bookings, onView) => [
12
+ const assignmentColumns = (i18n, slots, resources, bookings, onView) => [
10
13
  {
11
14
  accessorKey: "slotId",
12
- header: ({ column }) => _jsx(DataTableColumnHeader, { column: column, title: "Slot" }),
13
- cell: ({ row }) => slotLabel(slots.find((slot) => slot.id === row.original.slotId) ?? {
15
+ header: ({ column }) => (_jsx(DataTableColumnHeader, { column: column, title: i18n.messages.tabsSecondary.columns.assignments.slot })),
16
+ cell: ({ row }) => formatResourceSlotLabel(slots.find((slot) => slot.id === row.original.slotId) ?? {
14
17
  id: row.original.slotId,
15
18
  productId: "",
16
19
  dateLocal: row.original.slotId,
17
20
  startsAt: row.original.slotId,
21
+ }, {
22
+ template: i18n.messages.common.slotLabel,
23
+ formatDate: i18n.formatDate,
18
24
  }),
19
25
  },
20
26
  {
21
27
  accessorKey: "resourceId",
22
- header: ({ column }) => _jsx(DataTableColumnHeader, { column: column, title: "Resource" }),
28
+ header: ({ column }) => (_jsx(DataTableColumnHeader, { column: column, title: i18n.messages.tabsSecondary.columns.assignments.resource })),
23
29
  cell: ({ row }) => labelById(resources, row.original.resourceId),
24
30
  },
25
31
  {
26
32
  accessorKey: "bookingId",
27
- header: ({ column }) => _jsx(DataTableColumnHeader, { column: column, title: "Booking" }),
33
+ header: ({ column }) => (_jsx(DataTableColumnHeader, { column: column, title: i18n.messages.tabsSecondary.columns.assignments.booking })),
28
34
  cell: ({ row }) => labelById(bookings, row.original.bookingId),
29
35
  },
30
36
  {
31
37
  accessorKey: "status",
32
- header: ({ column }) => _jsx(DataTableColumnHeader, { column: column, title: "Status" }),
33
- cell: ({ row }) => (_jsx(Badge, { variant: "outline", className: "capitalize", children: row.original.status })),
38
+ header: ({ column }) => (_jsx(DataTableColumnHeader, { column: column, title: i18n.messages.tabsSecondary.columns.assignments.status })),
39
+ cell: ({ row }) => (_jsx(Badge, { variant: "outline", children: i18n.messages.common.assignmentStatusLabels[row.original.status] })),
34
40
  },
35
41
  {
36
42
  accessorKey: "releasedAt",
37
- header: ({ column }) => _jsx(DataTableColumnHeader, { column: column, title: "Released" }),
38
- cell: ({ row }) => formatDateTime(row.original.releasedAt),
43
+ header: ({ column }) => (_jsx(DataTableColumnHeader, { column: column, title: i18n.messages.tabsSecondary.columns.assignments.released })),
44
+ cell: ({ row }) => formatDateTimeOrFallback(row.original.releasedAt, {
45
+ fallback: i18n.messages.common.dateTimeFallback,
46
+ formatDateTime: i18n.formatDateTime,
47
+ }),
39
48
  },
40
49
  {
41
50
  id: "view",
42
- header: "View",
51
+ header: i18n.messages.tabsSecondary.columns.assignments.view,
43
52
  cell: ({ row }) => (_jsxs(Button, { variant: "ghost", size: "sm", onClick: (event) => {
44
53
  event.stopPropagation();
45
54
  onView(row.original.id);
46
- }, children: [_jsx(ExternalLink, { className: "mr-2 h-4 w-4" }), "Open"] })),
55
+ }, children: [_jsx(ExternalLink, { className: "mr-2 h-4 w-4" }), i18n.messages.common.open] })),
47
56
  },
48
57
  ];
49
- const closeoutColumns = (resources) => [
58
+ const closeoutColumns = (i18n, resources) => [
50
59
  {
51
60
  accessorKey: "resourceId",
52
- header: ({ column }) => _jsx(DataTableColumnHeader, { column: column, title: "Resource" }),
61
+ header: ({ column }) => (_jsx(DataTableColumnHeader, { column: column, title: i18n.messages.tabsSecondary.columns.closeouts.resource })),
53
62
  cell: ({ row }) => labelById(resources, row.original.resourceId),
54
63
  },
55
64
  {
56
65
  accessorKey: "dateLocal",
57
- header: ({ column }) => _jsx(DataTableColumnHeader, { column: column, title: "Date" }),
66
+ header: ({ column }) => (_jsx(DataTableColumnHeader, { column: column, title: i18n.messages.tabsSecondary.columns.closeouts.date })),
58
67
  },
59
68
  {
60
69
  accessorKey: "startsAt",
61
- header: ({ column }) => _jsx(DataTableColumnHeader, { column: column, title: "Starts" }),
62
- cell: ({ row }) => formatDateTime(row.original.startsAt),
70
+ header: ({ column }) => (_jsx(DataTableColumnHeader, { column: column, title: i18n.messages.tabsSecondary.columns.closeouts.starts })),
71
+ cell: ({ row }) => formatDateTimeOrFallback(row.original.startsAt, {
72
+ fallback: i18n.messages.common.dateTimeFallback,
73
+ formatDateTime: i18n.formatDateTime,
74
+ }),
63
75
  },
64
76
  {
65
77
  accessorKey: "endsAt",
66
- header: ({ column }) => _jsx(DataTableColumnHeader, { column: column, title: "Ends" }),
67
- cell: ({ row }) => formatDateTime(row.original.endsAt),
78
+ header: ({ column }) => (_jsx(DataTableColumnHeader, { column: column, title: i18n.messages.tabsSecondary.columns.closeouts.ends })),
79
+ cell: ({ row }) => formatDateTimeOrFallback(row.original.endsAt, {
80
+ fallback: i18n.messages.common.dateTimeFallback,
81
+ formatDateTime: i18n.formatDateTime,
82
+ }),
68
83
  },
69
84
  {
70
85
  accessorKey: "reason",
71
- header: ({ column }) => _jsx(DataTableColumnHeader, { column: column, title: "Reason" }),
86
+ header: ({ column }) => (_jsx(DataTableColumnHeader, { column: column, title: i18n.messages.tabsSecondary.columns.closeouts.reason })),
72
87
  cell: ({ row }) => row.original.reason ?? "-",
73
88
  },
74
89
  ];
75
90
  export function AssignmentsTab(props) {
76
- return (_jsxs(TabsContent, { value: "assignments", className: "space-y-4", children: [_jsx(ResourcesSectionHeader, { title: "Slot Assignments", description: "Reserve or assign specific resources against live slots and bookings.", actionLabel: "New Assignment", onAction: props.onCreate }), _jsx(DataTable, { columns: assignmentColumns(props.slots, props.resources, props.bookings, props.onOpenRoute), data: props.filteredAssignments, emptyMessage: "No assignments match the current filters.", enableRowSelection: true, getRowId: (row) => row.id, rowSelection: props.assignmentSelection, onRowSelectionChange: props.setAssignmentSelection, renderSelectionActions: ({ selectedRows, clearSelection }) => (_jsxs(SelectionActionBar, { selectedCount: selectedRows.length, onClear: clearSelection, children: [_jsx(ConfirmActionButton, { buttonLabel: "Assign", confirmLabel: "Mark Assigned", title: `Mark ${formatSelectionLabel(selectedRows.length, "assignment")} as assigned?`, description: "This marks the selected reservations as actively assigned without deleting any linkage.", disabled: props.bulkActionTarget === "assignments-assigned", onConfirm: () => props.handleBulkUpdate({
91
+ const i18n = useResourcesUiI18nOrDefault();
92
+ const m = i18n.messages;
93
+ const section = m.tabsSecondary.sections.assignments;
94
+ const selection = m.common.selectionNouns.assignment;
95
+ return (_jsxs(TabsContent, { value: "assignments", className: "space-y-4", children: [_jsx(ResourcesSectionHeader, { title: section.title, description: section.description, actionLabel: section.actionLabel, onAction: props.onCreate }), _jsx(DataTable, { columns: assignmentColumns(i18n, props.slots, props.resources, props.bookings, props.onOpenRoute), data: props.filteredAssignments, emptyMessage: section.emptyMessage, enableRowSelection: true, getRowId: (row) => row.id, rowSelection: props.assignmentSelection, onRowSelectionChange: props.setAssignmentSelection, renderSelectionActions: ({ selectedRows, clearSelection }) => (_jsxs(SelectionActionBar, { selectedCount: selectedRows.length, onClear: clearSelection, clearLabel: m.common.clearSelection, selectionSummary: formatSelectionSummary(selectedRows.length, m.common.selectionSummary), children: [_jsx(ConfirmActionButton, { buttonLabel: section.actions.assign.buttonLabel, confirmLabel: section.actions.assign.confirmLabel, cancelLabel: m.common.cancel, title: formatMessage(section.actions.assign.title, {
96
+ selection: formatSelectionLabel(selectedRows.length, selection, m.common.selectionLabel),
97
+ }), description: section.actions.assign.description, disabled: props.bulkActionTarget === "assignments-assigned", onConfirm: () => props.handleBulkUpdate({
77
98
  ids: selectedRows.map((row) => row.original.id),
78
99
  endpoint: "/v1/resources/slot-assignments",
79
100
  target: "assignments-assigned",
80
101
  noun: "assignment",
81
102
  payload: { status: "assigned" },
82
- successVerb: "Updated",
103
+ successVerb: section.actions.assign.successVerb,
83
104
  clearSelection,
84
- }) }), _jsx(ConfirmActionButton, { buttonLabel: "Release", confirmLabel: "Release Assignments", title: `Release ${formatSelectionLabel(selectedRows.length, "assignment")}?`, description: "This marks the selected reservations as released while keeping the assignment history intact.", disabled: props.bulkActionTarget === "assignments-released", onConfirm: () => props.handleBulkUpdate({
105
+ }) }), _jsx(ConfirmActionButton, { buttonLabel: section.actions.release.buttonLabel, confirmLabel: section.actions.release.confirmLabel, cancelLabel: m.common.cancel, title: formatMessage(section.actions.release.title, {
106
+ selection: formatSelectionLabel(selectedRows.length, selection, m.common.selectionLabel),
107
+ }), description: section.actions.release.description, disabled: props.bulkActionTarget === "assignments-released", onConfirm: () => props.handleBulkUpdate({
85
108
  ids: selectedRows.map((row) => row.original.id),
86
109
  endpoint: "/v1/resources/slot-assignments",
87
110
  target: "assignments-released",
88
111
  noun: "assignment",
89
112
  payload: { status: "released" },
90
- successVerb: "Released",
113
+ successVerb: section.actions.release.successVerb,
91
114
  clearSelection,
92
- }) }), _jsx(ConfirmActionButton, { buttonLabel: "Delete Selected", confirmLabel: "Delete Assignments", title: `Delete ${formatSelectionLabel(selectedRows.length, "assignment")}?`, description: "This permanently removes the selected slot assignments. Use Release if you only need to free the resource.", disabled: props.bulkActionTarget === "assignments-delete", variant: "destructive", confirmVariant: "destructive", onConfirm: () => props.handleBulkDelete({
115
+ }) }), _jsx(ConfirmActionButton, { buttonLabel: section.actions.delete.buttonLabel, confirmLabel: section.actions.delete.confirmLabel, cancelLabel: m.common.cancel, title: formatMessage(section.actions.delete.title, {
116
+ selection: formatSelectionLabel(selectedRows.length, selection, m.common.selectionLabel),
117
+ }), description: section.actions.delete.description, disabled: props.bulkActionTarget === "assignments-delete", variant: "destructive", confirmVariant: "destructive", onConfirm: () => props.handleBulkDelete({
93
118
  ids: selectedRows.map((row) => row.original.id),
94
119
  endpoint: "/v1/resources/slot-assignments",
95
120
  target: "assignments-delete",
@@ -98,7 +123,13 @@ export function AssignmentsTab(props) {
98
123
  }) })] })), onRowClick: (row) => props.onEdit(row.original) })] }));
99
124
  }
100
125
  export function CloseoutsTab(props) {
101
- return (_jsxs(TabsContent, { value: "closeouts", className: "space-y-4", children: [_jsx(ResourcesSectionHeader, { title: "Resource Closeouts", description: "Block assets for maintenance, charter use, or operational conflicts.", actionLabel: "New Closeout", onAction: props.onCreate }), _jsx(DataTable, { columns: closeoutColumns(props.resources), data: props.filteredCloseouts, emptyMessage: "No closeouts match the current filters.", enableRowSelection: true, getRowId: (row) => row.id, rowSelection: props.closeoutSelection, onRowSelectionChange: props.setCloseoutSelection, renderSelectionActions: ({ selectedRows, clearSelection }) => (_jsx(SelectionActionBar, { selectedCount: selectedRows.length, onClear: clearSelection, children: _jsx(ConfirmActionButton, { buttonLabel: "Delete Selected", confirmLabel: "Delete Closeouts", title: `Delete ${formatSelectionLabel(selectedRows.length, "closeout")}?`, description: "This permanently removes the selected closeouts and may return the resources to operational use.", disabled: props.bulkActionTarget === "closeouts-delete", variant: "destructive", confirmVariant: "destructive", onConfirm: () => props.handleBulkDelete({
126
+ const i18n = useResourcesUiI18nOrDefault();
127
+ const m = i18n.messages;
128
+ const section = m.tabsSecondary.sections.closeouts;
129
+ const selection = m.common.selectionNouns.closeout;
130
+ return (_jsxs(TabsContent, { value: "closeouts", className: "space-y-4", children: [_jsx(ResourcesSectionHeader, { title: section.title, description: section.description, actionLabel: section.actionLabel, onAction: props.onCreate }), _jsx(DataTable, { columns: closeoutColumns(i18n, props.resources), data: props.filteredCloseouts, emptyMessage: section.emptyMessage, enableRowSelection: true, getRowId: (row) => row.id, rowSelection: props.closeoutSelection, onRowSelectionChange: props.setCloseoutSelection, renderSelectionActions: ({ selectedRows, clearSelection }) => (_jsx(SelectionActionBar, { selectedCount: selectedRows.length, onClear: clearSelection, clearLabel: m.common.clearSelection, selectionSummary: formatSelectionSummary(selectedRows.length, m.common.selectionSummary), children: _jsx(ConfirmActionButton, { buttonLabel: section.actions.delete.buttonLabel, confirmLabel: section.actions.delete.confirmLabel, cancelLabel: m.common.cancel, title: formatMessage(section.actions.delete.title, {
131
+ selection: formatSelectionLabel(selectedRows.length, selection, m.common.selectionLabel),
132
+ }), description: section.actions.delete.description, disabled: props.bulkActionTarget === "closeouts-delete", variant: "destructive", confirmVariant: "destructive", onConfirm: () => props.handleBulkDelete({
102
133
  ids: selectedRows.map((row) => row.original.id),
103
134
  endpoint: "/v1/resources/closeouts",
104
135
  target: "closeouts-delete",
@@ -0,0 +1,3 @@
1
+ import type { ResourcesUiMessages } from "./messages";
2
+ export declare const resourcesUiEn: ResourcesUiMessages;
3
+ //# sourceMappingURL=en.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/i18n/en.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAErD,eAAO,MAAM,aAAa,EAAE,mBAkQ3B,CAAA"}