@medusajs/draft-order 2.23.0-snapshot-20261119105620 → 2.23.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.
- package/.medusa/server/src/admin/index.js +88 -57
- package/.medusa/server/src/admin/index.mjs +88 -57
- package/AGENTS.md +3 -2
- package/package.json +18 -18
|
@@ -26,6 +26,7 @@ let _medusajs_ui = require("@medusajs/ui");
|
|
|
26
26
|
let _tanstack_react_query = require("@tanstack/react-query");
|
|
27
27
|
let react = require("react");
|
|
28
28
|
react = __toESM(react);
|
|
29
|
+
let react_i18next = require("react-i18next");
|
|
29
30
|
let react_router_dom = require("react-router-dom");
|
|
30
31
|
let _medusajs_icons = require("@medusajs/icons");
|
|
31
32
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -33,7 +34,6 @@ let _medusajs_js_sdk = require("@medusajs/js-sdk");
|
|
|
33
34
|
_medusajs_js_sdk = __toESM(_medusajs_js_sdk);
|
|
34
35
|
let date_fns = require("date-fns");
|
|
35
36
|
let date_fns_locale = require("date-fns/locale");
|
|
36
|
-
let react_i18next = require("react-i18next");
|
|
37
37
|
let _hookform_resolvers_zod = require("@hookform/resolvers/zod");
|
|
38
38
|
let react_hook_form = require("react-hook-form");
|
|
39
39
|
let zod = require("zod");
|
|
@@ -108,6 +108,7 @@ var ActionMenu = ({ groups, variant = "transparent", children }) => {
|
|
|
108
108
|
};
|
|
109
109
|
// src/admin/components/common/data-table.tsx
|
|
110
110
|
var DataTable = ({ data = [], columns, filters, commands, action, actionMenu, getRowId, rowCount = 0, enablePagination = true, enableSearch = true, autoFocusSearch = false, rowHref, heading, subHeading, prefix, pageSize = 10, emptyState, rowSelection, isLoading = false, layout = "auto" }) => {
|
|
111
|
+
const { t } = (0, react_i18next.useTranslation)();
|
|
111
112
|
const enableFiltering = filters && filters.length > 0;
|
|
112
113
|
const enableCommands = commands && commands.length > 0;
|
|
113
114
|
const enableSorting = columns.some((column) => column.enableSorting);
|
|
@@ -213,6 +214,12 @@ var DataTable = ({ data = [], columns, filters, commands, action, actionMenu, ge
|
|
|
213
214
|
children: [
|
|
214
215
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_medusajs_ui.DataTable.Toolbar, {
|
|
215
216
|
className: "flex flex-col items-start justify-between gap-2 md:flex-row md:items-center",
|
|
217
|
+
translations: {
|
|
218
|
+
clearAll: t("actions.clearAll"),
|
|
219
|
+
sort: t("filters.sortLabel"),
|
|
220
|
+
filter: t("filters.filterLabel"),
|
|
221
|
+
columns: t("filters.columnsLabel")
|
|
222
|
+
},
|
|
216
223
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
217
224
|
className: "flex w-full items-center justify-between gap-2",
|
|
218
225
|
children: [shouldRenderHeading && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [heading && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Heading, { children: heading }), subHeading && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Text, {
|
|
@@ -222,8 +229,8 @@ var DataTable = ({ data = [], columns, filters, commands, action, actionMenu, ge
|
|
|
222
229
|
})] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
223
230
|
className: "flex items-center justify-end gap-x-2 md:hidden",
|
|
224
231
|
children: [
|
|
225
|
-
enableFiltering && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.DataTable.FilterMenu, { tooltip: "
|
|
226
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.DataTable.SortingMenu, { tooltip: "
|
|
232
|
+
enableFiltering && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.DataTable.FilterMenu, { tooltip: t("filters.filterLabel") }),
|
|
233
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.DataTable.SortingMenu, { tooltip: t("filters.sortLabel") }),
|
|
227
234
|
actionMenu && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionMenu, {
|
|
228
235
|
variant: "primary",
|
|
229
236
|
...actionMenu
|
|
@@ -237,14 +244,14 @@ var DataTable = ({ data = [], columns, filters, commands, action, actionMenu, ge
|
|
|
237
244
|
className: "w-full md:w-auto",
|
|
238
245
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.DataTable.Search, {
|
|
239
246
|
"data-modal-id": "modal-search-input",
|
|
240
|
-
placeholder: "
|
|
247
|
+
placeholder: t("filters.searchLabel"),
|
|
241
248
|
autoFocus: autoFocusSearch
|
|
242
249
|
})
|
|
243
250
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
244
251
|
className: "hidden items-center gap-x-2 md:flex",
|
|
245
252
|
children: [
|
|
246
|
-
enableFiltering && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.DataTable.FilterMenu, { tooltip: "
|
|
247
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.DataTable.SortingMenu, { tooltip: "
|
|
253
|
+
enableFiltering && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.DataTable.FilterMenu, { tooltip: t("filters.filterLabel") }),
|
|
254
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.DataTable.SortingMenu, { tooltip: t("filters.sortLabel") }),
|
|
248
255
|
actionMenu && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionMenu, {
|
|
249
256
|
variant: "primary",
|
|
250
257
|
...actionMenu
|
|
@@ -255,7 +262,13 @@ var DataTable = ({ data = [], columns, filters, commands, action, actionMenu, ge
|
|
|
255
262
|
})]
|
|
256
263
|
}),
|
|
257
264
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.DataTable.Table, { emptyState }),
|
|
258
|
-
enablePagination && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.DataTable.Pagination, {
|
|
265
|
+
enablePagination && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.DataTable.Pagination, { translations: {
|
|
266
|
+
of: t("general.of"),
|
|
267
|
+
results: t("general.results"),
|
|
268
|
+
pages: t("general.pages"),
|
|
269
|
+
prev: t("general.prev"),
|
|
270
|
+
next: t("general.next")
|
|
271
|
+
} }),
|
|
259
272
|
enableCommands && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.DataTable.CommandBar, { selectedLabel: (count) => `${count} selected` })
|
|
260
273
|
]
|
|
261
274
|
});
|
|
@@ -807,6 +820,7 @@ var getFullDate = ({ date, includeTime = false }) => {
|
|
|
807
820
|
// src/admin/hooks/common/use-data-table-date-filters.tsx
|
|
808
821
|
var filterHelper = (0, _medusajs_ui.createDataTableFilterHelper)();
|
|
809
822
|
var useDateFilterOptions = () => {
|
|
823
|
+
const { t } = (0, react_i18next.useTranslation)();
|
|
810
824
|
const today = (0, react.useMemo)(() => {
|
|
811
825
|
const date = /* @__PURE__ */ new Date();
|
|
812
826
|
date.setHours(0, 0, 0, 0);
|
|
@@ -815,56 +829,62 @@ var useDateFilterOptions = () => {
|
|
|
815
829
|
return (0, react.useMemo)(() => {
|
|
816
830
|
return [
|
|
817
831
|
{
|
|
818
|
-
label: "
|
|
832
|
+
label: t("filters.date.today"),
|
|
819
833
|
value: { $gte: today.toISOString() }
|
|
820
834
|
},
|
|
821
835
|
{
|
|
822
|
-
label: "
|
|
836
|
+
label: t("filters.date.lastSevenDays"),
|
|
823
837
|
value: { $gte: (0, date_fns.subDays)(today, 7).toISOString() }
|
|
824
838
|
},
|
|
825
839
|
{
|
|
826
|
-
label: "
|
|
840
|
+
label: t("filters.date.lastThirtyDays"),
|
|
827
841
|
value: { $gte: (0, date_fns.subDays)(today, 30).toISOString() }
|
|
828
842
|
},
|
|
829
843
|
{
|
|
830
|
-
label: "
|
|
844
|
+
label: t("filters.date.lastNinetyDays"),
|
|
831
845
|
value: { $gte: (0, date_fns.subDays)(today, 90).toISOString() }
|
|
832
846
|
},
|
|
833
847
|
{
|
|
834
|
-
label: "
|
|
848
|
+
label: t("filters.date.lastTwelveMonths"),
|
|
835
849
|
value: { $gte: (0, date_fns.subMonths)(today, 12).toISOString() }
|
|
836
850
|
}
|
|
837
851
|
];
|
|
838
|
-
}, [today]);
|
|
852
|
+
}, [today, t]);
|
|
839
853
|
};
|
|
840
854
|
var useDataTableDateFilters = (disableRangeOption) => {
|
|
855
|
+
const { t } = (0, react_i18next.useTranslation)();
|
|
841
856
|
const dateFilterOptions = useDateFilterOptions();
|
|
842
857
|
const rangeOptions = (0, react.useMemo)(() => {
|
|
843
858
|
if (disableRangeOption) return { disableRangeOption: true };
|
|
844
859
|
return {
|
|
845
|
-
rangeOptionStartLabel: "
|
|
846
|
-
rangeOptionEndLabel: "
|
|
847
|
-
rangeOptionLabel: "
|
|
860
|
+
rangeOptionStartLabel: t("filters.date.starting"),
|
|
861
|
+
rangeOptionEndLabel: t("filters.date.ending"),
|
|
862
|
+
rangeOptionLabel: t("filters.date.custom"),
|
|
848
863
|
options: dateFilterOptions
|
|
849
864
|
};
|
|
850
|
-
}, [
|
|
865
|
+
}, [
|
|
866
|
+
disableRangeOption,
|
|
867
|
+
t,
|
|
868
|
+
dateFilterOptions
|
|
869
|
+
]);
|
|
851
870
|
return (0, react.useMemo)(() => {
|
|
852
871
|
return [filterHelper.accessor("created_at", {
|
|
853
872
|
type: "date",
|
|
854
|
-
label: "
|
|
873
|
+
label: t("fields.createdAt"),
|
|
855
874
|
format: "date",
|
|
856
875
|
formatDateValue: (date) => getFullDate({ date }),
|
|
857
876
|
options: dateFilterOptions,
|
|
858
877
|
...rangeOptions
|
|
859
878
|
}), filterHelper.accessor("updated_at", {
|
|
860
879
|
type: "date",
|
|
861
|
-
label: "
|
|
880
|
+
label: t("fields.updatedAt"),
|
|
862
881
|
format: "date",
|
|
863
882
|
formatDateValue: (date) => getFullDate({ date }),
|
|
864
883
|
options: dateFilterOptions,
|
|
865
884
|
...rangeOptions
|
|
866
885
|
})];
|
|
867
886
|
}, [
|
|
887
|
+
t,
|
|
868
888
|
dateFilterOptions,
|
|
869
889
|
getFullDate,
|
|
870
890
|
rangeOptions
|
|
@@ -929,7 +949,11 @@ var EDIT_DRAFT_ORDER_SHIPPING_PERMISSIONS = [
|
|
|
929
949
|
];
|
|
930
950
|
// src/admin/routes/draft-orders/page.tsx
|
|
931
951
|
var PAGE_SIZE = 20;
|
|
932
|
-
var
|
|
952
|
+
var Breadcrumb = () => {
|
|
953
|
+
const { t } = (0, react_i18next.useTranslation)();
|
|
954
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: t("draftOrders.domain") });
|
|
955
|
+
};
|
|
956
|
+
var handle$12 = { breadcrumb: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Breadcrumb, {}) };
|
|
933
957
|
var List = () => {
|
|
934
958
|
const { t } = (0, react_i18next.useTranslation)();
|
|
935
959
|
const queryParams = useDraftOrderTableQuery({ pageSize: PAGE_SIZE });
|
|
@@ -980,22 +1004,24 @@ var List = () => {
|
|
|
980
1004
|
});
|
|
981
1005
|
};
|
|
982
1006
|
var config = (0, _medusajs_admin_sdk.defineRouteConfig)({
|
|
983
|
-
label: "
|
|
1007
|
+
label: "draftOrders.domain",
|
|
1008
|
+
translationNs: "translation",
|
|
984
1009
|
nested: "/orders",
|
|
985
1010
|
permissions: VIEW_DRAFT_ORDER_PERMISSIONS
|
|
986
1011
|
});
|
|
987
1012
|
var columnHelper$1 = (0, _medusajs_ui.createDataTableColumnHelper)();
|
|
988
1013
|
var useColumns$1 = () => {
|
|
1014
|
+
const { t } = (0, react_i18next.useTranslation)();
|
|
989
1015
|
return (0, react.useMemo)(() => [
|
|
990
1016
|
columnHelper$1.accessor("display_id", {
|
|
991
|
-
header: "
|
|
1017
|
+
header: t("orders.fields.displayId"),
|
|
992
1018
|
cell: ({ getValue }) => {
|
|
993
1019
|
return `#${getValue()}`;
|
|
994
1020
|
},
|
|
995
1021
|
enableSorting: true
|
|
996
1022
|
}),
|
|
997
1023
|
columnHelper$1.accessor("created_at", {
|
|
998
|
-
header: "
|
|
1024
|
+
header: t("fields.date"),
|
|
999
1025
|
cell: ({ getValue }) => {
|
|
1000
1026
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Tooltip, {
|
|
1001
1027
|
content: getFullDate({
|
|
@@ -1008,29 +1034,30 @@ var useColumns$1 = () => {
|
|
|
1008
1034
|
enableSorting: true
|
|
1009
1035
|
}),
|
|
1010
1036
|
columnHelper$1.accessor("customer_id", {
|
|
1011
|
-
header: "
|
|
1037
|
+
header: t("fields.customer"),
|
|
1012
1038
|
cell: ({ row }) => {
|
|
1013
1039
|
return row.original.customer?.email || "-";
|
|
1014
1040
|
},
|
|
1015
1041
|
enableSorting: true
|
|
1016
1042
|
}),
|
|
1017
1043
|
columnHelper$1.accessor("sales_channel_id", {
|
|
1018
|
-
header: "
|
|
1044
|
+
header: t("fields.salesChannel"),
|
|
1019
1045
|
cell: ({ row }) => {
|
|
1020
1046
|
return row.original.sales_channel?.name || "-";
|
|
1021
1047
|
},
|
|
1022
1048
|
enableSorting: true
|
|
1023
1049
|
}),
|
|
1024
1050
|
columnHelper$1.accessor("region_id", {
|
|
1025
|
-
header: "
|
|
1051
|
+
header: t("fields.region"),
|
|
1026
1052
|
cell: ({ row }) => {
|
|
1027
1053
|
return row.original.region?.name || "-";
|
|
1028
1054
|
},
|
|
1029
1055
|
enableSorting: true
|
|
1030
1056
|
})
|
|
1031
|
-
], []);
|
|
1057
|
+
], [t]);
|
|
1032
1058
|
};
|
|
1033
1059
|
var useFilters = () => {
|
|
1060
|
+
const { t } = (0, react_i18next.useTranslation)();
|
|
1034
1061
|
const dateFilterOptions = useDataTableDateFilters();
|
|
1035
1062
|
const { hasPermission } = (0, _medusajs_dashboard_hooks.usePermissions)();
|
|
1036
1063
|
const canReadCustomers = hasPermission("customer:read");
|
|
@@ -1061,7 +1088,7 @@ var useFilters = () => {
|
|
|
1061
1088
|
const filters = [];
|
|
1062
1089
|
if (canReadCustomers) filters.push({
|
|
1063
1090
|
id: "customer_id",
|
|
1064
|
-
label: "
|
|
1091
|
+
label: t("fields.customer"),
|
|
1065
1092
|
options: customers?.filter((customer) => customer !== null).map((customer) => ({
|
|
1066
1093
|
label: customer.email,
|
|
1067
1094
|
value: customer.id
|
|
@@ -1070,7 +1097,7 @@ var useFilters = () => {
|
|
|
1070
1097
|
});
|
|
1071
1098
|
if (canReadSalesChannels) filters.push({
|
|
1072
1099
|
id: "sales_channel_id",
|
|
1073
|
-
label: "
|
|
1100
|
+
label: t("fields.salesChannel"),
|
|
1074
1101
|
options: sales_channels?.map((sales_channel) => ({
|
|
1075
1102
|
label: sales_channel.name,
|
|
1076
1103
|
value: sales_channel.id
|
|
@@ -1079,7 +1106,7 @@ var useFilters = () => {
|
|
|
1079
1106
|
});
|
|
1080
1107
|
if (canReadRegions) filters.push({
|
|
1081
1108
|
id: "region_id",
|
|
1082
|
-
label: "
|
|
1109
|
+
label: t("fields.region"),
|
|
1083
1110
|
options: regions?.map((region) => ({
|
|
1084
1111
|
label: region.name,
|
|
1085
1112
|
value: region.id
|
|
@@ -1088,6 +1115,7 @@ var useFilters = () => {
|
|
|
1088
1115
|
});
|
|
1089
1116
|
return [...filters, ...dateFilterOptions];
|
|
1090
1117
|
}, [
|
|
1118
|
+
t,
|
|
1091
1119
|
canReadCustomers,
|
|
1092
1120
|
canReadSalesChannels,
|
|
1093
1121
|
canReadRegions,
|
|
@@ -7172,6 +7200,32 @@ var InlineTip = (0, react.forwardRef)(({ variant = "tip", label, className, chil
|
|
|
7172
7200
|
});
|
|
7173
7201
|
});
|
|
7174
7202
|
InlineTip.displayName = "InlineTip";
|
|
7203
|
+
// src/admin/lib/utils/metadata-utils.ts
|
|
7204
|
+
function parseValues(values, original) {
|
|
7205
|
+
const metadata = values.metadata;
|
|
7206
|
+
if (!metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value) return null;
|
|
7207
|
+
const update = {};
|
|
7208
|
+
if (original) Object.keys(original).forEach((originalKey) => {
|
|
7209
|
+
if (!metadata.some((field) => field.key === originalKey)) update[originalKey] = "";
|
|
7210
|
+
});
|
|
7211
|
+
metadata.forEach((field) => {
|
|
7212
|
+
let key = field.key;
|
|
7213
|
+
let value = field.value;
|
|
7214
|
+
const disabled = field.disabled;
|
|
7215
|
+
if (!key) return;
|
|
7216
|
+
if (disabled) {
|
|
7217
|
+
update[key] = value;
|
|
7218
|
+
return;
|
|
7219
|
+
}
|
|
7220
|
+
key = key.trim();
|
|
7221
|
+
value = value?.trim() ?? "";
|
|
7222
|
+
if (value === "true") update[key] = true;
|
|
7223
|
+
else if (value === "false") update[key] = false;
|
|
7224
|
+
else if (/^-?\d*\.?\d+$/.test(value)) update[key] = parseFloat(value);
|
|
7225
|
+
else update[key] = value;
|
|
7226
|
+
});
|
|
7227
|
+
return update;
|
|
7228
|
+
}
|
|
7175
7229
|
// src/admin/routes/draft-orders/[id]/@metadata/page.tsx
|
|
7176
7230
|
var MetadataFieldSchema = zod.z.object({
|
|
7177
7231
|
key: zod.z.string(),
|
|
@@ -7209,7 +7263,7 @@ var MetadataForm = ({ orderId, metadata }) => {
|
|
|
7209
7263
|
resolver: (0, _hookform_resolvers_zod.zodResolver)(MetadataSchema)
|
|
7210
7264
|
});
|
|
7211
7265
|
const handleSubmit = form.handleSubmit(async (data) => {
|
|
7212
|
-
const parsedData = parseValues(data);
|
|
7266
|
+
const parsedData = parseValues(data, metadata);
|
|
7213
7267
|
await mutateAsync({ metadata: parsedData }, {
|
|
7214
7268
|
onSuccess: () => {
|
|
7215
7269
|
_medusajs_ui.toast.success("Metadata updated");
|
|
@@ -7397,31 +7451,6 @@ function getDefaultValues(metadata) {
|
|
|
7397
7451
|
};
|
|
7398
7452
|
});
|
|
7399
7453
|
}
|
|
7400
|
-
function parseValues(values) {
|
|
7401
|
-
const metadata = values.metadata;
|
|
7402
|
-
if (!metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value) return null;
|
|
7403
|
-
const update = {};
|
|
7404
|
-
metadata.forEach((field) => {
|
|
7405
|
-
let key = field.key;
|
|
7406
|
-
let value = field.value;
|
|
7407
|
-
const disabled = field.disabled;
|
|
7408
|
-
if (!key || !value) return;
|
|
7409
|
-
if (disabled) {
|
|
7410
|
-
update[key] = value;
|
|
7411
|
-
return;
|
|
7412
|
-
}
|
|
7413
|
-
key = key.trim();
|
|
7414
|
-
value = value.trim();
|
|
7415
|
-
if (value === "true") update[key] = true;
|
|
7416
|
-
else if (value === "false") update[key] = false;
|
|
7417
|
-
else {
|
|
7418
|
-
const parsedNumber = parseFloat(value);
|
|
7419
|
-
if (!isNaN(parsedNumber)) update[key] = parsedNumber;
|
|
7420
|
-
else update[key] = value;
|
|
7421
|
-
}
|
|
7422
|
-
});
|
|
7423
|
-
return update;
|
|
7424
|
-
}
|
|
7425
7454
|
function getHasUneditableRows(metadata) {
|
|
7426
7455
|
if (!metadata) return false;
|
|
7427
7456
|
return Object.values(metadata).some((value) => !EDITABLE_TYPES.includes(typeof value));
|
|
@@ -9413,6 +9442,7 @@ var LEGACY_POLICY_INJECTION_ZONES = [
|
|
|
9413
9442
|
"policy.list.after"
|
|
9414
9443
|
];
|
|
9415
9444
|
var POLICY_INJECTION_ZONES = ["policy.details", "policy.list"];
|
|
9445
|
+
var AUDIT_LOG_INJECTION_ZONES = ["audit_log.details", "audit_log.list"];
|
|
9416
9446
|
var LEGACY_DRAFT_ORDER_INJECTION_ZONES = [
|
|
9417
9447
|
"draft_order.details.before",
|
|
9418
9448
|
"draft_order.details.after",
|
|
@@ -9536,6 +9566,7 @@ var SIDEBAR_INJECTION_ZONES = ["sidebar.settings.before"];
|
|
|
9536
9566
|
...ROLE_INJECTION_ZONES,
|
|
9537
9567
|
...LEGACY_POLICY_INJECTION_ZONES,
|
|
9538
9568
|
...POLICY_INJECTION_ZONES,
|
|
9569
|
+
...AUDIT_LOG_INJECTION_ZONES,
|
|
9539
9570
|
...LEGACY_DRAFT_ORDER_INJECTION_ZONES,
|
|
9540
9571
|
...DRAFT_ORDER_INJECTION_ZONES,
|
|
9541
9572
|
...LEGACY_STORE_CREDIT_ACCOUNT_INJECTION_ZONES,
|
|
@@ -9628,7 +9659,7 @@ var plugin = {
|
|
|
9628
9659
|
path: "/draft-orders",
|
|
9629
9660
|
nested: "/orders",
|
|
9630
9661
|
rank: void 0,
|
|
9631
|
-
translationNs:
|
|
9662
|
+
translationNs: config.translationNs,
|
|
9632
9663
|
permissions: config.permissions
|
|
9633
9664
|
}] },
|
|
9634
9665
|
formModule: { customFields: {} },
|
|
@@ -4,13 +4,13 @@ import { PermissionGuard, usePermissions } from "@medusajs/dashboard/hooks";
|
|
|
4
4
|
import { Avatar, Badge, Button, Container, Copy, CurrencyInput, DataTable, Divider, Drawer, DropdownMenu, FocusModal, Heading, Hint, IconButton, Input, Kbd, Label, Prompt, Select, Skeleton, StatusBadge, Switch, Text, Tooltip, clx, createDataTableColumnHelper, createDataTableFilterHelper, toast, useDataTable, usePrompt } from "@medusajs/ui";
|
|
5
5
|
import { keepPreviousData, useInfiniteQuery, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
6
6
|
import React, { Fragment, Suspense, createContext, forwardRef, useCallback, useContext, useDeferredValue, useEffect, useId, useImperativeHandle, useMemo, useRef, useState, useTransition } from "react";
|
|
7
|
+
import { useTranslation } from "react-i18next";
|
|
7
8
|
import { Link, useBlocker, useLocation, useNavigate, useParams, useSearchParams } from "react-router-dom";
|
|
8
9
|
import { ArrowDownMini, ArrowPath, ArrowUpMini, ArrowUpRightOnBox, Buildings, Channels, Check, CheckMini, Component, CurrencyDollar, EllipseMiniSolid, EllipsisHorizontal, EllipsisVertical, Envelope, ExclamationCircleSolid, FlyingBox, InformationCircleSolid, Minus, PencilSquare, Photo, Plus, PlusMini, ReceiptPercent, Shopping, SquareTwoStack, Trash, TriangleDownMini, TriangleRightMini, TrianglesMini, TruckFast, XMark, XMarkMini } from "@medusajs/icons";
|
|
9
10
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
11
|
import Medusa from "@medusajs/js-sdk";
|
|
11
12
|
import { format, formatDistance, sub, subDays, subMonths } from "date-fns";
|
|
12
13
|
import { enUS } from "date-fns/locale";
|
|
13
|
-
import { useTranslation } from "react-i18next";
|
|
14
14
|
import { zodResolver } from "@hookform/resolvers/zod";
|
|
15
15
|
import { Controller, FormProvider, useFieldArray, useForm, useFormContext, useFormState, useWatch } from "react-hook-form";
|
|
16
16
|
import { z } from "zod";
|
|
@@ -83,6 +83,7 @@ var ActionMenu = ({ groups, variant = "transparent", children }) => {
|
|
|
83
83
|
};
|
|
84
84
|
// src/admin/components/common/data-table.tsx
|
|
85
85
|
var DataTable$1 = ({ data = [], columns, filters, commands, action, actionMenu, getRowId, rowCount = 0, enablePagination = true, enableSearch = true, autoFocusSearch = false, rowHref, heading, subHeading, prefix, pageSize = 10, emptyState, rowSelection, isLoading = false, layout = "auto" }) => {
|
|
86
|
+
const { t } = useTranslation();
|
|
86
87
|
const enableFiltering = filters && filters.length > 0;
|
|
87
88
|
const enableCommands = commands && commands.length > 0;
|
|
88
89
|
const enableSorting = columns.some((column) => column.enableSorting);
|
|
@@ -188,6 +189,12 @@ var DataTable$1 = ({ data = [], columns, filters, commands, action, actionMenu,
|
|
|
188
189
|
children: [
|
|
189
190
|
/* @__PURE__ */ jsxs(DataTable.Toolbar, {
|
|
190
191
|
className: "flex flex-col items-start justify-between gap-2 md:flex-row md:items-center",
|
|
192
|
+
translations: {
|
|
193
|
+
clearAll: t("actions.clearAll"),
|
|
194
|
+
sort: t("filters.sortLabel"),
|
|
195
|
+
filter: t("filters.filterLabel"),
|
|
196
|
+
columns: t("filters.columnsLabel")
|
|
197
|
+
},
|
|
191
198
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
192
199
|
className: "flex w-full items-center justify-between gap-2",
|
|
193
200
|
children: [shouldRenderHeading && /* @__PURE__ */ jsxs("div", { children: [heading && /* @__PURE__ */ jsx(Heading, { children: heading }), subHeading && /* @__PURE__ */ jsx(Text, {
|
|
@@ -197,8 +204,8 @@ var DataTable$1 = ({ data = [], columns, filters, commands, action, actionMenu,
|
|
|
197
204
|
})] }), /* @__PURE__ */ jsxs("div", {
|
|
198
205
|
className: "flex items-center justify-end gap-x-2 md:hidden",
|
|
199
206
|
children: [
|
|
200
|
-
enableFiltering && /* @__PURE__ */ jsx(DataTable.FilterMenu, { tooltip: "
|
|
201
|
-
/* @__PURE__ */ jsx(DataTable.SortingMenu, { tooltip: "
|
|
207
|
+
enableFiltering && /* @__PURE__ */ jsx(DataTable.FilterMenu, { tooltip: t("filters.filterLabel") }),
|
|
208
|
+
/* @__PURE__ */ jsx(DataTable.SortingMenu, { tooltip: t("filters.sortLabel") }),
|
|
202
209
|
actionMenu && /* @__PURE__ */ jsx(ActionMenu, {
|
|
203
210
|
variant: "primary",
|
|
204
211
|
...actionMenu
|
|
@@ -212,14 +219,14 @@ var DataTable$1 = ({ data = [], columns, filters, commands, action, actionMenu,
|
|
|
212
219
|
className: "w-full md:w-auto",
|
|
213
220
|
children: /* @__PURE__ */ jsx(DataTable.Search, {
|
|
214
221
|
"data-modal-id": "modal-search-input",
|
|
215
|
-
placeholder: "
|
|
222
|
+
placeholder: t("filters.searchLabel"),
|
|
216
223
|
autoFocus: autoFocusSearch
|
|
217
224
|
})
|
|
218
225
|
}), /* @__PURE__ */ jsxs("div", {
|
|
219
226
|
className: "hidden items-center gap-x-2 md:flex",
|
|
220
227
|
children: [
|
|
221
|
-
enableFiltering && /* @__PURE__ */ jsx(DataTable.FilterMenu, { tooltip: "
|
|
222
|
-
/* @__PURE__ */ jsx(DataTable.SortingMenu, { tooltip: "
|
|
228
|
+
enableFiltering && /* @__PURE__ */ jsx(DataTable.FilterMenu, { tooltip: t("filters.filterLabel") }),
|
|
229
|
+
/* @__PURE__ */ jsx(DataTable.SortingMenu, { tooltip: t("filters.sortLabel") }),
|
|
223
230
|
actionMenu && /* @__PURE__ */ jsx(ActionMenu, {
|
|
224
231
|
variant: "primary",
|
|
225
232
|
...actionMenu
|
|
@@ -230,7 +237,13 @@ var DataTable$1 = ({ data = [], columns, filters, commands, action, actionMenu,
|
|
|
230
237
|
})]
|
|
231
238
|
}),
|
|
232
239
|
/* @__PURE__ */ jsx(DataTable.Table, { emptyState }),
|
|
233
|
-
enablePagination && /* @__PURE__ */ jsx(DataTable.Pagination, {
|
|
240
|
+
enablePagination && /* @__PURE__ */ jsx(DataTable.Pagination, { translations: {
|
|
241
|
+
of: t("general.of"),
|
|
242
|
+
results: t("general.results"),
|
|
243
|
+
pages: t("general.pages"),
|
|
244
|
+
prev: t("general.prev"),
|
|
245
|
+
next: t("general.next")
|
|
246
|
+
} }),
|
|
234
247
|
enableCommands && /* @__PURE__ */ jsx(DataTable.CommandBar, { selectedLabel: (count) => `${count} selected` })
|
|
235
248
|
]
|
|
236
249
|
});
|
|
@@ -782,6 +795,7 @@ var getFullDate = ({ date, includeTime = false }) => {
|
|
|
782
795
|
// src/admin/hooks/common/use-data-table-date-filters.tsx
|
|
783
796
|
var filterHelper = createDataTableFilterHelper();
|
|
784
797
|
var useDateFilterOptions = () => {
|
|
798
|
+
const { t } = useTranslation();
|
|
785
799
|
const today = useMemo(() => {
|
|
786
800
|
const date = /* @__PURE__ */ new Date();
|
|
787
801
|
date.setHours(0, 0, 0, 0);
|
|
@@ -790,56 +804,62 @@ var useDateFilterOptions = () => {
|
|
|
790
804
|
return useMemo(() => {
|
|
791
805
|
return [
|
|
792
806
|
{
|
|
793
|
-
label: "
|
|
807
|
+
label: t("filters.date.today"),
|
|
794
808
|
value: { $gte: today.toISOString() }
|
|
795
809
|
},
|
|
796
810
|
{
|
|
797
|
-
label: "
|
|
811
|
+
label: t("filters.date.lastSevenDays"),
|
|
798
812
|
value: { $gte: subDays(today, 7).toISOString() }
|
|
799
813
|
},
|
|
800
814
|
{
|
|
801
|
-
label: "
|
|
815
|
+
label: t("filters.date.lastThirtyDays"),
|
|
802
816
|
value: { $gte: subDays(today, 30).toISOString() }
|
|
803
817
|
},
|
|
804
818
|
{
|
|
805
|
-
label: "
|
|
819
|
+
label: t("filters.date.lastNinetyDays"),
|
|
806
820
|
value: { $gte: subDays(today, 90).toISOString() }
|
|
807
821
|
},
|
|
808
822
|
{
|
|
809
|
-
label: "
|
|
823
|
+
label: t("filters.date.lastTwelveMonths"),
|
|
810
824
|
value: { $gte: subMonths(today, 12).toISOString() }
|
|
811
825
|
}
|
|
812
826
|
];
|
|
813
|
-
}, [today]);
|
|
827
|
+
}, [today, t]);
|
|
814
828
|
};
|
|
815
829
|
var useDataTableDateFilters = (disableRangeOption) => {
|
|
830
|
+
const { t } = useTranslation();
|
|
816
831
|
const dateFilterOptions = useDateFilterOptions();
|
|
817
832
|
const rangeOptions = useMemo(() => {
|
|
818
833
|
if (disableRangeOption) return { disableRangeOption: true };
|
|
819
834
|
return {
|
|
820
|
-
rangeOptionStartLabel: "
|
|
821
|
-
rangeOptionEndLabel: "
|
|
822
|
-
rangeOptionLabel: "
|
|
835
|
+
rangeOptionStartLabel: t("filters.date.starting"),
|
|
836
|
+
rangeOptionEndLabel: t("filters.date.ending"),
|
|
837
|
+
rangeOptionLabel: t("filters.date.custom"),
|
|
823
838
|
options: dateFilterOptions
|
|
824
839
|
};
|
|
825
|
-
}, [
|
|
840
|
+
}, [
|
|
841
|
+
disableRangeOption,
|
|
842
|
+
t,
|
|
843
|
+
dateFilterOptions
|
|
844
|
+
]);
|
|
826
845
|
return useMemo(() => {
|
|
827
846
|
return [filterHelper.accessor("created_at", {
|
|
828
847
|
type: "date",
|
|
829
|
-
label: "
|
|
848
|
+
label: t("fields.createdAt"),
|
|
830
849
|
format: "date",
|
|
831
850
|
formatDateValue: (date) => getFullDate({ date }),
|
|
832
851
|
options: dateFilterOptions,
|
|
833
852
|
...rangeOptions
|
|
834
853
|
}), filterHelper.accessor("updated_at", {
|
|
835
854
|
type: "date",
|
|
836
|
-
label: "
|
|
855
|
+
label: t("fields.updatedAt"),
|
|
837
856
|
format: "date",
|
|
838
857
|
formatDateValue: (date) => getFullDate({ date }),
|
|
839
858
|
options: dateFilterOptions,
|
|
840
859
|
...rangeOptions
|
|
841
860
|
})];
|
|
842
861
|
}, [
|
|
862
|
+
t,
|
|
843
863
|
dateFilterOptions,
|
|
844
864
|
getFullDate,
|
|
845
865
|
rangeOptions
|
|
@@ -904,7 +924,11 @@ var EDIT_DRAFT_ORDER_SHIPPING_PERMISSIONS = [
|
|
|
904
924
|
];
|
|
905
925
|
// src/admin/routes/draft-orders/page.tsx
|
|
906
926
|
var PAGE_SIZE = 20;
|
|
907
|
-
var
|
|
927
|
+
var Breadcrumb = () => {
|
|
928
|
+
const { t } = useTranslation();
|
|
929
|
+
return /* @__PURE__ */ jsx(Fragment$1, { children: t("draftOrders.domain") });
|
|
930
|
+
};
|
|
931
|
+
var handle$12 = { breadcrumb: () => /* @__PURE__ */ jsx(Breadcrumb, {}) };
|
|
908
932
|
var List = () => {
|
|
909
933
|
const { t } = useTranslation();
|
|
910
934
|
const queryParams = useDraftOrderTableQuery({ pageSize: PAGE_SIZE });
|
|
@@ -955,22 +979,24 @@ var List = () => {
|
|
|
955
979
|
});
|
|
956
980
|
};
|
|
957
981
|
var config = defineRouteConfig({
|
|
958
|
-
label: "
|
|
982
|
+
label: "draftOrders.domain",
|
|
983
|
+
translationNs: "translation",
|
|
959
984
|
nested: "/orders",
|
|
960
985
|
permissions: VIEW_DRAFT_ORDER_PERMISSIONS
|
|
961
986
|
});
|
|
962
987
|
var columnHelper$1 = createDataTableColumnHelper();
|
|
963
988
|
var useColumns$1 = () => {
|
|
989
|
+
const { t } = useTranslation();
|
|
964
990
|
return useMemo(() => [
|
|
965
991
|
columnHelper$1.accessor("display_id", {
|
|
966
|
-
header: "
|
|
992
|
+
header: t("orders.fields.displayId"),
|
|
967
993
|
cell: ({ getValue }) => {
|
|
968
994
|
return `#${getValue()}`;
|
|
969
995
|
},
|
|
970
996
|
enableSorting: true
|
|
971
997
|
}),
|
|
972
998
|
columnHelper$1.accessor("created_at", {
|
|
973
|
-
header: "
|
|
999
|
+
header: t("fields.date"),
|
|
974
1000
|
cell: ({ getValue }) => {
|
|
975
1001
|
return /* @__PURE__ */ jsx(Tooltip, {
|
|
976
1002
|
content: getFullDate({
|
|
@@ -983,29 +1009,30 @@ var useColumns$1 = () => {
|
|
|
983
1009
|
enableSorting: true
|
|
984
1010
|
}),
|
|
985
1011
|
columnHelper$1.accessor("customer_id", {
|
|
986
|
-
header: "
|
|
1012
|
+
header: t("fields.customer"),
|
|
987
1013
|
cell: ({ row }) => {
|
|
988
1014
|
return row.original.customer?.email || "-";
|
|
989
1015
|
},
|
|
990
1016
|
enableSorting: true
|
|
991
1017
|
}),
|
|
992
1018
|
columnHelper$1.accessor("sales_channel_id", {
|
|
993
|
-
header: "
|
|
1019
|
+
header: t("fields.salesChannel"),
|
|
994
1020
|
cell: ({ row }) => {
|
|
995
1021
|
return row.original.sales_channel?.name || "-";
|
|
996
1022
|
},
|
|
997
1023
|
enableSorting: true
|
|
998
1024
|
}),
|
|
999
1025
|
columnHelper$1.accessor("region_id", {
|
|
1000
|
-
header: "
|
|
1026
|
+
header: t("fields.region"),
|
|
1001
1027
|
cell: ({ row }) => {
|
|
1002
1028
|
return row.original.region?.name || "-";
|
|
1003
1029
|
},
|
|
1004
1030
|
enableSorting: true
|
|
1005
1031
|
})
|
|
1006
|
-
], []);
|
|
1032
|
+
], [t]);
|
|
1007
1033
|
};
|
|
1008
1034
|
var useFilters = () => {
|
|
1035
|
+
const { t } = useTranslation();
|
|
1009
1036
|
const dateFilterOptions = useDataTableDateFilters();
|
|
1010
1037
|
const { hasPermission } = usePermissions();
|
|
1011
1038
|
const canReadCustomers = hasPermission("customer:read");
|
|
@@ -1036,7 +1063,7 @@ var useFilters = () => {
|
|
|
1036
1063
|
const filters = [];
|
|
1037
1064
|
if (canReadCustomers) filters.push({
|
|
1038
1065
|
id: "customer_id",
|
|
1039
|
-
label: "
|
|
1066
|
+
label: t("fields.customer"),
|
|
1040
1067
|
options: customers?.filter((customer) => customer !== null).map((customer) => ({
|
|
1041
1068
|
label: customer.email,
|
|
1042
1069
|
value: customer.id
|
|
@@ -1045,7 +1072,7 @@ var useFilters = () => {
|
|
|
1045
1072
|
});
|
|
1046
1073
|
if (canReadSalesChannels) filters.push({
|
|
1047
1074
|
id: "sales_channel_id",
|
|
1048
|
-
label: "
|
|
1075
|
+
label: t("fields.salesChannel"),
|
|
1049
1076
|
options: sales_channels?.map((sales_channel) => ({
|
|
1050
1077
|
label: sales_channel.name,
|
|
1051
1078
|
value: sales_channel.id
|
|
@@ -1054,7 +1081,7 @@ var useFilters = () => {
|
|
|
1054
1081
|
});
|
|
1055
1082
|
if (canReadRegions) filters.push({
|
|
1056
1083
|
id: "region_id",
|
|
1057
|
-
label: "
|
|
1084
|
+
label: t("fields.region"),
|
|
1058
1085
|
options: regions?.map((region) => ({
|
|
1059
1086
|
label: region.name,
|
|
1060
1087
|
value: region.id
|
|
@@ -1063,6 +1090,7 @@ var useFilters = () => {
|
|
|
1063
1090
|
});
|
|
1064
1091
|
return [...filters, ...dateFilterOptions];
|
|
1065
1092
|
}, [
|
|
1093
|
+
t,
|
|
1066
1094
|
canReadCustomers,
|
|
1067
1095
|
canReadSalesChannels,
|
|
1068
1096
|
canReadRegions,
|
|
@@ -7147,6 +7175,32 @@ var InlineTip = forwardRef(({ variant = "tip", label, className, children, ...pr
|
|
|
7147
7175
|
});
|
|
7148
7176
|
});
|
|
7149
7177
|
InlineTip.displayName = "InlineTip";
|
|
7178
|
+
// src/admin/lib/utils/metadata-utils.ts
|
|
7179
|
+
function parseValues(values, original) {
|
|
7180
|
+
const metadata = values.metadata;
|
|
7181
|
+
if (!metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value) return null;
|
|
7182
|
+
const update = {};
|
|
7183
|
+
if (original) Object.keys(original).forEach((originalKey) => {
|
|
7184
|
+
if (!metadata.some((field) => field.key === originalKey)) update[originalKey] = "";
|
|
7185
|
+
});
|
|
7186
|
+
metadata.forEach((field) => {
|
|
7187
|
+
let key = field.key;
|
|
7188
|
+
let value = field.value;
|
|
7189
|
+
const disabled = field.disabled;
|
|
7190
|
+
if (!key) return;
|
|
7191
|
+
if (disabled) {
|
|
7192
|
+
update[key] = value;
|
|
7193
|
+
return;
|
|
7194
|
+
}
|
|
7195
|
+
key = key.trim();
|
|
7196
|
+
value = value?.trim() ?? "";
|
|
7197
|
+
if (value === "true") update[key] = true;
|
|
7198
|
+
else if (value === "false") update[key] = false;
|
|
7199
|
+
else if (/^-?\d*\.?\d+$/.test(value)) update[key] = parseFloat(value);
|
|
7200
|
+
else update[key] = value;
|
|
7201
|
+
});
|
|
7202
|
+
return update;
|
|
7203
|
+
}
|
|
7150
7204
|
// src/admin/routes/draft-orders/[id]/@metadata/page.tsx
|
|
7151
7205
|
var MetadataFieldSchema = z.object({
|
|
7152
7206
|
key: z.string(),
|
|
@@ -7184,7 +7238,7 @@ var MetadataForm = ({ orderId, metadata }) => {
|
|
|
7184
7238
|
resolver: zodResolver(MetadataSchema)
|
|
7185
7239
|
});
|
|
7186
7240
|
const handleSubmit = form.handleSubmit(async (data) => {
|
|
7187
|
-
const parsedData = parseValues(data);
|
|
7241
|
+
const parsedData = parseValues(data, metadata);
|
|
7188
7242
|
await mutateAsync({ metadata: parsedData }, {
|
|
7189
7243
|
onSuccess: () => {
|
|
7190
7244
|
toast.success("Metadata updated");
|
|
@@ -7372,31 +7426,6 @@ function getDefaultValues(metadata) {
|
|
|
7372
7426
|
};
|
|
7373
7427
|
});
|
|
7374
7428
|
}
|
|
7375
|
-
function parseValues(values) {
|
|
7376
|
-
const metadata = values.metadata;
|
|
7377
|
-
if (!metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value) return null;
|
|
7378
|
-
const update = {};
|
|
7379
|
-
metadata.forEach((field) => {
|
|
7380
|
-
let key = field.key;
|
|
7381
|
-
let value = field.value;
|
|
7382
|
-
const disabled = field.disabled;
|
|
7383
|
-
if (!key || !value) return;
|
|
7384
|
-
if (disabled) {
|
|
7385
|
-
update[key] = value;
|
|
7386
|
-
return;
|
|
7387
|
-
}
|
|
7388
|
-
key = key.trim();
|
|
7389
|
-
value = value.trim();
|
|
7390
|
-
if (value === "true") update[key] = true;
|
|
7391
|
-
else if (value === "false") update[key] = false;
|
|
7392
|
-
else {
|
|
7393
|
-
const parsedNumber = parseFloat(value);
|
|
7394
|
-
if (!isNaN(parsedNumber)) update[key] = parsedNumber;
|
|
7395
|
-
else update[key] = value;
|
|
7396
|
-
}
|
|
7397
|
-
});
|
|
7398
|
-
return update;
|
|
7399
|
-
}
|
|
7400
7429
|
function getHasUneditableRows(metadata) {
|
|
7401
7430
|
if (!metadata) return false;
|
|
7402
7431
|
return Object.values(metadata).some((value) => !EDITABLE_TYPES.includes(typeof value));
|
|
@@ -9388,6 +9417,7 @@ var LEGACY_POLICY_INJECTION_ZONES = [
|
|
|
9388
9417
|
"policy.list.after"
|
|
9389
9418
|
];
|
|
9390
9419
|
var POLICY_INJECTION_ZONES = ["policy.details", "policy.list"];
|
|
9420
|
+
var AUDIT_LOG_INJECTION_ZONES = ["audit_log.details", "audit_log.list"];
|
|
9391
9421
|
var LEGACY_DRAFT_ORDER_INJECTION_ZONES = [
|
|
9392
9422
|
"draft_order.details.before",
|
|
9393
9423
|
"draft_order.details.after",
|
|
@@ -9511,6 +9541,7 @@ var SIDEBAR_INJECTION_ZONES = ["sidebar.settings.before"];
|
|
|
9511
9541
|
...ROLE_INJECTION_ZONES,
|
|
9512
9542
|
...LEGACY_POLICY_INJECTION_ZONES,
|
|
9513
9543
|
...POLICY_INJECTION_ZONES,
|
|
9544
|
+
...AUDIT_LOG_INJECTION_ZONES,
|
|
9514
9545
|
...LEGACY_DRAFT_ORDER_INJECTION_ZONES,
|
|
9515
9546
|
...DRAFT_ORDER_INJECTION_ZONES,
|
|
9516
9547
|
...LEGACY_STORE_CREDIT_ACCOUNT_INJECTION_ZONES,
|
|
@@ -9603,7 +9634,7 @@ var plugin = {
|
|
|
9603
9634
|
path: "/draft-orders",
|
|
9604
9635
|
nested: "/orders",
|
|
9605
9636
|
rank: void 0,
|
|
9606
|
-
translationNs:
|
|
9637
|
+
translationNs: config.translationNs,
|
|
9607
9638
|
permissions: config.permissions
|
|
9608
9639
|
}] },
|
|
9609
9640
|
formModule: { customFields: {} },
|
package/AGENTS.md
CHANGED
|
@@ -19,7 +19,7 @@ module.exports = defineConfig({
|
|
|
19
19
|
|
|
20
20
|
## Architecture
|
|
21
21
|
|
|
22
|
-
- `src/admin/routes/draft-orders/`: list page (`page.tsx`, `defineRouteConfig({ label: "
|
|
22
|
+
- `src/admin/routes/draft-orders/`: list page (`page.tsx`, `defineRouteConfig({ label: "draftOrders.domain", translationNs: "translation", nested: "/orders" })`), `@create` modal, and `[id]` detail with parallel `@<section>` routes (items, shipping, addresses, promotions, email, metadata, sales-channel, transfer-ownership, custom-items).
|
|
23
23
|
- RBAC: the core `/admin/draft-orders` routes are guarded by the `order` resource. Every page declares its permissions (`config.permissions` on the list, `export const handle = { permissions }` on the others) and actions are gated with `usePermissions` from `@medusajs/dashboard/hooks`. Shared permission sets live in `src/admin/lib/permissions.ts`, so an action and the route it opens check the same list. Child routes repeat `order:read`, since the deepest route's permissions replace the parent's.
|
|
24
24
|
- `src/admin/hooks/api/`: React Query hooks wrapping `sdk.admin.*` calls; `draft-orders.tsx` covers the edit flow (`beginEdit`, `requestEdit`, `cancelEdit`, `convertToOrder`, action-item updates).
|
|
25
25
|
- `src/admin/lib/queries/sdk.ts`: JS SDK client configured from the admin build globals `__BACKEND_URL__`, `__AUTH_TYPE__`, `__JWT_TOKEN_STORAGE_KEY__` (declared in `src/admin/vite-env.d.ts`).
|
|
@@ -34,7 +34,7 @@ yarn build:plugin # medusa plugin:build -> .medusa/server (the only pub
|
|
|
34
34
|
yarn dev # medusa plugin:develop (watch + publish to local registry)
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
-
|
|
37
|
+
- Pure admin helpers (e.g. `src/admin/lib/utils/metadata-utils.ts`) and admin components (`.spec.tsx`, rendered with `react-dom/server`) have Jest unit tests in `__tests__/` beside them; run them with `npx jest` from the package directory (there's no `test` script). Draft-order behaviour is covered by HTTP integration tests in `integration-tests/http/__tests__/draft-order/admin/`, which exercise the core routes.
|
|
38
38
|
- Root `yarn build` runs `build:plugin` through turbo, after `@medusajs/medusa#build`.
|
|
39
39
|
- Plugin docs: https://docs.medusajs.com/learn/fundamentals/plugins.md
|
|
40
40
|
|
|
@@ -44,4 +44,5 @@ yarn dev # medusa plugin:develop (watch + publish to local reg
|
|
|
44
44
|
- `tsconfig.json` excludes `src/admin`; admin code is type-checked with `src/admin/tsconfig.json` (bundler resolution, `noEmit`, strict) and bundled by `plugin:build`.
|
|
45
45
|
- There is no Tailwind config: the app's admin build compiles the plugin's classes with Tailwind 4, so use v4 class names.
|
|
46
46
|
- The `exports` map lists `./workflows`, `./modules/*` and `./providers/*` from the plugin template, but none exist in `src/`. Only `./admin` resolves to real code.
|
|
47
|
+
- UI strings come from the dashboard's i18n resources: use `useTranslation()` from `react-i18next` with keys from `packages/admin/dashboard/src/i18n/translations/en.json` instead of hardcoded English.
|
|
47
48
|
- A UI change that needs new backend behaviour usually means changing the core route, workflow, JS SDK method and `HttpTypes` together, and adding changesets for those packages too.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/draft-order",
|
|
3
|
-
"version": "2.23.0
|
|
3
|
+
"version": "2.23.0",
|
|
4
4
|
"description": "A draft order plugin for Medusa.",
|
|
5
5
|
"author": "Medusa (https://medusajs.com)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@ariakit/react": "^0.4.15",
|
|
51
51
|
"@babel/runtime": "^8.0.10",
|
|
52
52
|
"@hookform/resolvers": "6.0.0",
|
|
53
|
-
"@medusajs/js-sdk": "2.23.0
|
|
53
|
+
"@medusajs/js-sdk": "2.23.0",
|
|
54
54
|
"@tanstack/react-query": "5.107.1",
|
|
55
55
|
"@uiw/react-json-view": "^2.0.0-alpha.17",
|
|
56
56
|
"date-fns": "^4.4.0",
|
|
@@ -62,25 +62,25 @@
|
|
|
62
62
|
"zod": "4.6.7"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@medusajs/admin-sdk": "2.23.0
|
|
66
|
-
"@medusajs/cli": "2.23.0
|
|
67
|
-
"@medusajs/dashboard": "2.23.0
|
|
68
|
-
"@medusajs/framework": "2.23.0
|
|
69
|
-
"@medusajs/icons": "2.23.0
|
|
70
|
-
"@medusajs/test-utils": "2.23.0
|
|
71
|
-
"@medusajs/types": "2.23.0
|
|
72
|
-
"@medusajs/ui": "4.3.0
|
|
73
|
-
"@medusajs/ui-preset": "2.23.0
|
|
65
|
+
"@medusajs/admin-sdk": "2.23.0",
|
|
66
|
+
"@medusajs/cli": "2.23.0",
|
|
67
|
+
"@medusajs/dashboard": "2.23.0",
|
|
68
|
+
"@medusajs/framework": "2.23.0",
|
|
69
|
+
"@medusajs/icons": "2.23.0",
|
|
70
|
+
"@medusajs/test-utils": "2.23.0",
|
|
71
|
+
"@medusajs/types": "2.23.0",
|
|
72
|
+
"@medusajs/ui": "4.3.0",
|
|
73
|
+
"@medusajs/ui-preset": "2.23.0",
|
|
74
74
|
"cross-env": "^10.1.0"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"@medusajs/admin-sdk": "2.23.0
|
|
78
|
-
"@medusajs/cli": "2.23.0
|
|
79
|
-
"@medusajs/dashboard": "2.23.0
|
|
80
|
-
"@medusajs/framework": "2.23.0
|
|
81
|
-
"@medusajs/icons": "2.23.0
|
|
82
|
-
"@medusajs/test-utils": "2.23.0
|
|
83
|
-
"@medusajs/ui": "4.3.0
|
|
77
|
+
"@medusajs/admin-sdk": "2.23.0",
|
|
78
|
+
"@medusajs/cli": "2.23.0",
|
|
79
|
+
"@medusajs/dashboard": "2.23.0",
|
|
80
|
+
"@medusajs/framework": "2.23.0",
|
|
81
|
+
"@medusajs/icons": "2.23.0",
|
|
82
|
+
"@medusajs/test-utils": "2.23.0",
|
|
83
|
+
"@medusajs/ui": "4.3.0",
|
|
84
84
|
"react": "^19.3.1",
|
|
85
85
|
"react-dom": "^19.3.1",
|
|
86
86
|
"react-router-dom": "^6.30.4 || ^7.0.0"
|