@medusajs/draft-order 2.10.2-snapshot-20250903100537 → 2.10.2-snapshot-20250903132457
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 +1095 -1095
- package/.medusa/server/src/admin/index.mjs +1095 -1095
- package/package.json +24 -23
|
@@ -9560,27 +9560,6 @@ const ID = () => {
|
|
|
9560
9560
|
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
9561
9561
|
] });
|
|
9562
9562
|
};
|
|
9563
|
-
const CustomItems = () => {
|
|
9564
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9565
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
9566
|
-
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
9567
|
-
] });
|
|
9568
|
-
};
|
|
9569
|
-
const CustomItemsForm = () => {
|
|
9570
|
-
const form = reactHookForm.useForm({
|
|
9571
|
-
resolver: zod.zodResolver(schema$5)
|
|
9572
|
-
});
|
|
9573
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9574
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
9575
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9576
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9577
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
9578
|
-
] }) })
|
|
9579
|
-
] }) });
|
|
9580
|
-
};
|
|
9581
|
-
const schema$5 = objectType({
|
|
9582
|
-
email: stringType().email()
|
|
9583
|
-
});
|
|
9584
9563
|
const BillingAddress = () => {
|
|
9585
9564
|
const { id } = reactRouterDom.useParams();
|
|
9586
9565
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -9613,7 +9592,7 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9613
9592
|
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9614
9593
|
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9615
9594
|
},
|
|
9616
|
-
resolver: zod.zodResolver(schema$
|
|
9595
|
+
resolver: zod.zodResolver(schema$5)
|
|
9617
9596
|
});
|
|
9618
9597
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9619
9598
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9770,7 +9749,7 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9770
9749
|
}
|
|
9771
9750
|
) });
|
|
9772
9751
|
};
|
|
9773
|
-
const schema$
|
|
9752
|
+
const schema$5 = addressSchema;
|
|
9774
9753
|
const Email = () => {
|
|
9775
9754
|
const { id } = reactRouterDom.useParams();
|
|
9776
9755
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -9793,7 +9772,7 @@ const EmailForm = ({ order }) => {
|
|
|
9793
9772
|
defaultValues: {
|
|
9794
9773
|
email: order.email ?? ""
|
|
9795
9774
|
},
|
|
9796
|
-
resolver: zod.zodResolver(schema$
|
|
9775
|
+
resolver: zod.zodResolver(schema$4)
|
|
9797
9776
|
});
|
|
9798
9777
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9799
9778
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9836,7 +9815,7 @@ const EmailForm = ({ order }) => {
|
|
|
9836
9815
|
}
|
|
9837
9816
|
) });
|
|
9838
9817
|
};
|
|
9839
|
-
const schema$
|
|
9818
|
+
const schema$4 = objectType({
|
|
9840
9819
|
email: stringType().email()
|
|
9841
9820
|
});
|
|
9842
9821
|
const InlineTip = React.forwardRef(
|
|
@@ -10189,6 +10168,26 @@ function getHasUneditableRows(metadata) {
|
|
|
10189
10168
|
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
10190
10169
|
);
|
|
10191
10170
|
}
|
|
10171
|
+
const PROMOTION_QUERY_KEY = "promotions";
|
|
10172
|
+
const promotionsQueryKeys = {
|
|
10173
|
+
list: (query2) => [
|
|
10174
|
+
PROMOTION_QUERY_KEY,
|
|
10175
|
+
query2 ? query2 : void 0
|
|
10176
|
+
],
|
|
10177
|
+
detail: (id, query2) => [
|
|
10178
|
+
PROMOTION_QUERY_KEY,
|
|
10179
|
+
id,
|
|
10180
|
+
query2 ? query2 : void 0
|
|
10181
|
+
]
|
|
10182
|
+
};
|
|
10183
|
+
const usePromotions = (query2, options) => {
|
|
10184
|
+
const { data, ...rest } = reactQuery.useQuery({
|
|
10185
|
+
queryKey: promotionsQueryKeys.list(query2),
|
|
10186
|
+
queryFn: async () => sdk.admin.promotion.list(query2),
|
|
10187
|
+
...options
|
|
10188
|
+
});
|
|
10189
|
+
return { ...data, ...rest };
|
|
10190
|
+
};
|
|
10192
10191
|
const useCancelOrderEdit = ({ preview }) => {
|
|
10193
10192
|
const { mutateAsync: cancelOrderEdit } = useDraftOrderCancelEdit(preview == null ? void 0 : preview.id);
|
|
10194
10193
|
const onCancel = React.useCallback(async () => {
|
|
@@ -10235,80 +10234,85 @@ const useInitiateOrderEdit = ({
|
|
|
10235
10234
|
run();
|
|
10236
10235
|
}, [preview, navigate, mutateAsync]);
|
|
10237
10236
|
};
|
|
10238
|
-
|
|
10239
|
-
return typeof value === "string" ? Number(value.replace(",", ".")) : value;
|
|
10240
|
-
}
|
|
10241
|
-
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
10242
|
-
const Shipping = () => {
|
|
10243
|
-
var _a;
|
|
10237
|
+
const Promotions = () => {
|
|
10244
10238
|
const { id } = reactRouterDom.useParams();
|
|
10245
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
10246
|
-
fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
|
|
10247
|
-
});
|
|
10248
10239
|
const {
|
|
10249
10240
|
order: preview,
|
|
10250
|
-
isPending: isPreviewPending,
|
|
10251
10241
|
isError: isPreviewError,
|
|
10252
10242
|
error: previewError
|
|
10253
|
-
} = useOrderPreview(id);
|
|
10243
|
+
} = useOrderPreview(id, void 0);
|
|
10254
10244
|
useInitiateOrderEdit({ preview });
|
|
10255
10245
|
const { onCancel } = useCancelOrderEdit({ preview });
|
|
10256
|
-
if (isError) {
|
|
10257
|
-
throw error;
|
|
10258
|
-
}
|
|
10259
10246
|
if (isPreviewError) {
|
|
10260
10247
|
throw previewError;
|
|
10261
10248
|
}
|
|
10262
|
-
const
|
|
10263
|
-
|
|
10264
|
-
|
|
10265
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10266
|
-
|
|
10267
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
10268
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
|
|
10269
|
-
] }) }) }),
|
|
10270
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
|
|
10271
|
-
] }) : isReady ? /* @__PURE__ */ jsxRuntime.jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
10272
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
10273
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
10274
|
-
] }) });
|
|
10249
|
+
const isReady = !!preview;
|
|
10250
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { onClose: onCancel, children: [
|
|
10251
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Promotions" }) }) }),
|
|
10252
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(PromotionForm, { preview })
|
|
10253
|
+
] });
|
|
10275
10254
|
};
|
|
10276
|
-
const
|
|
10277
|
-
|
|
10278
|
-
const { setIsOpen } = useStackedModal();
|
|
10255
|
+
const PromotionForm = ({ preview }) => {
|
|
10256
|
+
const { items, shipping_methods } = preview;
|
|
10279
10257
|
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
10280
|
-
const [
|
|
10281
|
-
const
|
|
10282
|
-
const {
|
|
10258
|
+
const [comboboxValue, setComboboxValue] = React.useState("");
|
|
10259
|
+
const { handleSuccess } = useRouteModal();
|
|
10260
|
+
const { mutateAsync: addPromotions, isPending: isAddingPromotions } = useDraftOrderAddPromotions(preview.id);
|
|
10261
|
+
const promoCodes = getPromotionCodes(items, shipping_methods);
|
|
10262
|
+
const { promotions, isPending, isError, error } = usePromotions(
|
|
10283
10263
|
{
|
|
10284
|
-
|
|
10285
|
-
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
10264
|
+
code: promoCodes
|
|
10286
10265
|
},
|
|
10287
10266
|
{
|
|
10288
|
-
enabled:
|
|
10267
|
+
enabled: !!promoCodes.length
|
|
10289
10268
|
}
|
|
10290
10269
|
);
|
|
10291
|
-
const
|
|
10292
|
-
|
|
10293
|
-
|
|
10294
|
-
|
|
10295
|
-
|
|
10296
|
-
|
|
10297
|
-
|
|
10298
|
-
|
|
10299
|
-
|
|
10300
|
-
|
|
10301
|
-
|
|
10270
|
+
const comboboxData = useComboboxData({
|
|
10271
|
+
queryKey: ["promotions", "combobox", promoCodes],
|
|
10272
|
+
queryFn: async (params) => {
|
|
10273
|
+
return await sdk.admin.promotion.list({
|
|
10274
|
+
...params,
|
|
10275
|
+
code: {
|
|
10276
|
+
$nin: promoCodes
|
|
10277
|
+
}
|
|
10278
|
+
});
|
|
10279
|
+
},
|
|
10280
|
+
getOptions: (data) => {
|
|
10281
|
+
return data.promotions.map((promotion) => ({
|
|
10282
|
+
label: promotion.code,
|
|
10283
|
+
value: promotion.code
|
|
10284
|
+
}));
|
|
10285
|
+
}
|
|
10286
|
+
});
|
|
10287
|
+
const add = async (value) => {
|
|
10288
|
+
if (!value) {
|
|
10289
|
+
return;
|
|
10290
|
+
}
|
|
10291
|
+
addPromotions(
|
|
10292
|
+
{
|
|
10293
|
+
promo_codes: [value]
|
|
10294
|
+
},
|
|
10295
|
+
{
|
|
10296
|
+
onError: (e) => {
|
|
10297
|
+
ui.toast.error(e.message);
|
|
10298
|
+
comboboxData.onSearchValueChange("");
|
|
10299
|
+
setComboboxValue("");
|
|
10300
|
+
},
|
|
10301
|
+
onSuccess: () => {
|
|
10302
|
+
comboboxData.onSearchValueChange("");
|
|
10303
|
+
setComboboxValue("");
|
|
10304
|
+
}
|
|
10305
|
+
}
|
|
10306
|
+
);
|
|
10307
|
+
};
|
|
10302
10308
|
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
10303
|
-
const { mutateAsync: requestOrderEdit } =
|
|
10304
|
-
const { mutateAsync: removeShippingMethod } = useDraftOrderRemoveShippingMethod(preview.id);
|
|
10305
|
-
const { mutateAsync: removeActionShippingMethod } = useDraftOrderRemoveActionShippingMethod(preview.id);
|
|
10309
|
+
const { mutateAsync: requestOrderEdit } = useOrderEditRequest(preview.id);
|
|
10306
10310
|
const onSubmit = async () => {
|
|
10307
10311
|
setIsSubmitting(true);
|
|
10308
10312
|
let requestSucceeded = false;
|
|
10309
10313
|
await requestOrderEdit(void 0, {
|
|
10310
10314
|
onError: (e) => {
|
|
10311
|
-
ui.toast.error(
|
|
10315
|
+
ui.toast.error(e.message);
|
|
10312
10316
|
},
|
|
10313
10317
|
onSuccess: () => {
|
|
10314
10318
|
requestSucceeded = true;
|
|
@@ -10320,7 +10324,7 @@ const ShippingForm = ({ preview, order }) => {
|
|
|
10320
10324
|
}
|
|
10321
10325
|
await confirmOrderEdit(void 0, {
|
|
10322
10326
|
onError: (e) => {
|
|
10323
|
-
ui.toast.error(
|
|
10327
|
+
ui.toast.error(e.message);
|
|
10324
10328
|
},
|
|
10325
10329
|
onSuccess: () => {
|
|
10326
10330
|
handleSuccess();
|
|
@@ -10330,1104 +10334,1079 @@ const ShippingForm = ({ preview, order }) => {
|
|
|
10330
10334
|
}
|
|
10331
10335
|
});
|
|
10332
10336
|
};
|
|
10333
|
-
|
|
10334
|
-
|
|
10335
|
-
|
|
10336
|
-
|
|
10337
|
-
|
|
10337
|
+
if (isError) {
|
|
10338
|
+
throw error;
|
|
10339
|
+
}
|
|
10340
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", onSubmit, children: [
|
|
10341
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
10342
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
10343
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
10344
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "promotion-combobox", children: "Apply promotions" }),
|
|
10345
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { id: "promotion-combobox-hint", children: "Manage promotions that should be applied to the order." })
|
|
10346
|
+
] }),
|
|
10347
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10348
|
+
Combobox,
|
|
10349
|
+
{
|
|
10350
|
+
id: "promotion-combobox",
|
|
10351
|
+
"aria-describedby": "promotion-combobox-hint",
|
|
10352
|
+
isFetchingNextPage: comboboxData.isFetchingNextPage,
|
|
10353
|
+
fetchNextPage: comboboxData.fetchNextPage,
|
|
10354
|
+
options: comboboxData.options,
|
|
10355
|
+
onSearchValueChange: comboboxData.onSearchValueChange,
|
|
10356
|
+
searchValue: comboboxData.searchValue,
|
|
10357
|
+
disabled: comboboxData.disabled || isAddingPromotions,
|
|
10358
|
+
onChange: add,
|
|
10359
|
+
value: comboboxValue
|
|
10360
|
+
}
|
|
10361
|
+
)
|
|
10362
|
+
] }),
|
|
10363
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
10364
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-2", children: promotions == null ? void 0 : promotions.map((promotion) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
10365
|
+
PromotionItem,
|
|
10366
|
+
{
|
|
10367
|
+
promotion,
|
|
10368
|
+
orderId: preview.id,
|
|
10369
|
+
isLoading: isPending
|
|
10370
|
+
},
|
|
10371
|
+
promotion.id
|
|
10372
|
+
)) })
|
|
10373
|
+
] }) }),
|
|
10374
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
10375
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
10376
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10377
|
+
ui.Button,
|
|
10378
|
+
{
|
|
10379
|
+
size: "small",
|
|
10380
|
+
type: "submit",
|
|
10381
|
+
isLoading: isSubmitting || isAddingPromotions,
|
|
10382
|
+
children: "Save"
|
|
10383
|
+
}
|
|
10384
|
+
)
|
|
10385
|
+
] }) })
|
|
10386
|
+
] });
|
|
10387
|
+
};
|
|
10388
|
+
const PromotionItem = ({
|
|
10389
|
+
promotion,
|
|
10390
|
+
orderId,
|
|
10391
|
+
isLoading
|
|
10392
|
+
}) => {
|
|
10393
|
+
var _a;
|
|
10394
|
+
const { mutateAsync: removePromotions, isPending } = useDraftOrderRemovePromotions(orderId);
|
|
10395
|
+
const onRemove = async () => {
|
|
10396
|
+
removePromotions(
|
|
10397
|
+
{
|
|
10398
|
+
promo_codes: [promotion.code]
|
|
10399
|
+
},
|
|
10400
|
+
{
|
|
10401
|
+
onError: (e) => {
|
|
10402
|
+
ui.toast.error(e.message);
|
|
10338
10403
|
}
|
|
10339
|
-
onSubmit();
|
|
10340
10404
|
}
|
|
10341
|
-
|
|
10342
|
-
|
|
10343
|
-
);
|
|
10344
|
-
|
|
10345
|
-
|
|
10346
|
-
|
|
10347
|
-
|
|
10348
|
-
|
|
10349
|
-
|
|
10350
|
-
|
|
10351
|
-
|
|
10352
|
-
|
|
10353
|
-
|
|
10405
|
+
);
|
|
10406
|
+
};
|
|
10407
|
+
const displayValue = getDisplayValue(promotion);
|
|
10408
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10409
|
+
"div",
|
|
10410
|
+
{
|
|
10411
|
+
className: ui.clx(
|
|
10412
|
+
"px-3 py-2 rounded-lg bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between",
|
|
10413
|
+
{
|
|
10414
|
+
"animate-pulse": isLoading
|
|
10415
|
+
}
|
|
10416
|
+
),
|
|
10417
|
+
children: [
|
|
10354
10418
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
10355
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10356
|
-
/* @__PURE__ */ jsxRuntime.
|
|
10357
|
-
|
|
10358
|
-
|
|
10359
|
-
|
|
10360
|
-
|
|
10361
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10362
|
-
|
|
10363
|
-
|
|
10364
|
-
|
|
10365
|
-
|
|
10366
|
-
|
|
10367
|
-
|
|
10368
|
-
|
|
10369
|
-
|
|
10370
|
-
|
|
10371
|
-
|
|
10372
|
-
|
|
10373
|
-
|
|
10374
|
-
|
|
10375
|
-
|
|
10376
|
-
|
|
10377
|
-
|
|
10378
|
-
|
|
10379
|
-
] }),
|
|
10380
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-[5px] pb-[5px]", children: uniqueShippingProfiles.map((profile) => {
|
|
10381
|
-
var _a2, _b, _c, _d, _e, _f, _g;
|
|
10382
|
-
const items = getItemsWithShippingProfile(
|
|
10383
|
-
profile.id,
|
|
10384
|
-
order.items
|
|
10385
|
-
);
|
|
10386
|
-
const hasItems = items.length > 0;
|
|
10387
|
-
const shippingOption = shipping_options == null ? void 0 : shipping_options.find(
|
|
10388
|
-
(option) => option.shipping_profile_id === profile.id
|
|
10389
|
-
);
|
|
10390
|
-
const shippingMethod = preview.shipping_methods.find(
|
|
10391
|
-
(method) => method.shipping_option_id === (shippingOption == null ? void 0 : shippingOption.id)
|
|
10392
|
-
);
|
|
10393
|
-
const addShippingMethodAction = (_a2 = shippingMethod == null ? void 0 : shippingMethod.actions) == null ? void 0 : _a2.find(
|
|
10394
|
-
(action) => action.action === "SHIPPING_ADD"
|
|
10395
|
-
);
|
|
10396
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10397
|
-
radixUi.Accordion.Item,
|
|
10398
|
-
{
|
|
10399
|
-
value: profile.id,
|
|
10400
|
-
className: "bg-ui-bg-base shadow-elevation-card-rest rounded-lg",
|
|
10401
|
-
children: [
|
|
10402
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-3 py-2 flex items-center justify-between gap-3", children: [
|
|
10403
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3 w-full overflow-hidden", children: [
|
|
10404
|
-
/* @__PURE__ */ jsxRuntime.jsx(radixUi.Accordion.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10405
|
-
ui.IconButton,
|
|
10406
|
-
{
|
|
10407
|
-
size: "2xsmall",
|
|
10408
|
-
variant: "transparent",
|
|
10409
|
-
className: "group/trigger",
|
|
10410
|
-
disabled: !hasItems,
|
|
10411
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(icons.TriangleRightMini, { className: "group-data-[state=open]/trigger:rotate-90 transition-transform" })
|
|
10412
|
-
}
|
|
10413
|
-
) }),
|
|
10414
|
-
!shippingOption ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3", children: [
|
|
10415
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "size-7 rounded-md shadow-borders-base flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "size-6 rounded bg-ui-bg-component-hover flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(icons.Shopping, { className: "text-ui-fg-subtle" }) }) }),
|
|
10416
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col flex-1", children: [
|
|
10417
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10418
|
-
ui.Text,
|
|
10419
|
-
{
|
|
10420
|
-
size: "small",
|
|
10421
|
-
weight: "plus",
|
|
10422
|
-
leading: "compact",
|
|
10423
|
-
children: profile.name
|
|
10424
|
-
}
|
|
10425
|
-
),
|
|
10426
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10427
|
-
ui.Text,
|
|
10428
|
-
{
|
|
10429
|
-
size: "small",
|
|
10430
|
-
leading: "compact",
|
|
10431
|
-
className: "text-ui-fg-subtle",
|
|
10432
|
-
children: [
|
|
10433
|
-
items.length,
|
|
10434
|
-
" ",
|
|
10435
|
-
pluralize(items.length, "items", "item")
|
|
10436
|
-
]
|
|
10437
|
-
}
|
|
10438
|
-
)
|
|
10439
|
-
] })
|
|
10440
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-[5px] max-sm:flex-col max-sm:items-start flex-1 w-full overflow-hidden", children: [
|
|
10441
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10442
|
-
ui.Tooltip,
|
|
10443
|
-
{
|
|
10444
|
-
content: /* @__PURE__ */ jsxRuntime.jsx("ul", { children: items.map((item) => {
|
|
10445
|
-
var _a3, _b2, _c2;
|
|
10446
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10447
|
-
"li",
|
|
10448
|
-
{
|
|
10449
|
-
children: `${item.quantity}x ${(_b2 = (_a3 = item.variant) == null ? void 0 : _a3.product) == null ? void 0 : _b2.title} (${(_c2 = item.variant) == null ? void 0 : _c2.title})`
|
|
10450
|
-
},
|
|
10451
|
-
item.id
|
|
10452
|
-
);
|
|
10453
|
-
}) }),
|
|
10454
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10455
|
-
ui.Badge,
|
|
10456
|
-
{
|
|
10457
|
-
className: "flex items-center gap-x-[3px] overflow-hidden cursor-default",
|
|
10458
|
-
size: "xsmall",
|
|
10459
|
-
children: [
|
|
10460
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.Shopping, { className: "shrink-0" }),
|
|
10461
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "truncate", children: [
|
|
10462
|
-
items.reduce(
|
|
10463
|
-
(acc, item) => acc + item.quantity,
|
|
10464
|
-
0
|
|
10465
|
-
),
|
|
10466
|
-
"x",
|
|
10467
|
-
" ",
|
|
10468
|
-
pluralize(items.length, "items", "item")
|
|
10469
|
-
] })
|
|
10470
|
-
]
|
|
10471
|
-
}
|
|
10472
|
-
)
|
|
10473
|
-
}
|
|
10474
|
-
),
|
|
10475
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10476
|
-
ui.Tooltip,
|
|
10477
|
-
{
|
|
10478
|
-
content: (_d = (_c = (_b = shippingOption.service_zone) == null ? void 0 : _b.fulfillment_set) == null ? void 0 : _c.location) == null ? void 0 : _d.name,
|
|
10479
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10480
|
-
ui.Badge,
|
|
10481
|
-
{
|
|
10482
|
-
className: "flex items-center gap-x-[3px] overflow-hidden cursor-default",
|
|
10483
|
-
size: "xsmall",
|
|
10484
|
-
children: [
|
|
10485
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.Buildings, { className: "shrink-0" }),
|
|
10486
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: (_g = (_f = (_e = shippingOption.service_zone) == null ? void 0 : _e.fulfillment_set) == null ? void 0 : _f.location) == null ? void 0 : _g.name })
|
|
10487
|
-
]
|
|
10488
|
-
}
|
|
10489
|
-
)
|
|
10490
|
-
}
|
|
10491
|
-
),
|
|
10492
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { content: shippingOption.name, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10493
|
-
ui.Badge,
|
|
10494
|
-
{
|
|
10495
|
-
className: "flex items-center gap-x-[3px] overflow-hidden cursor-default",
|
|
10496
|
-
size: "xsmall",
|
|
10497
|
-
children: [
|
|
10498
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.TruckFast, { className: "shrink-0" }),
|
|
10499
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: shippingOption.name })
|
|
10500
|
-
]
|
|
10501
|
-
}
|
|
10502
|
-
) })
|
|
10503
|
-
] })
|
|
10504
|
-
] }),
|
|
10505
|
-
shippingOption ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
10506
|
-
ActionMenu,
|
|
10507
|
-
{
|
|
10508
|
-
groups: [
|
|
10509
|
-
{
|
|
10510
|
-
actions: [
|
|
10511
|
-
hasItems ? {
|
|
10512
|
-
label: "Edit shipping option",
|
|
10513
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Channels, {}),
|
|
10514
|
-
onClick: () => {
|
|
10515
|
-
setIsOpen(
|
|
10516
|
-
STACKED_FOCUS_MODAL_ID,
|
|
10517
|
-
true
|
|
10518
|
-
);
|
|
10519
|
-
setData({
|
|
10520
|
-
shippingProfileId: profile.id,
|
|
10521
|
-
shippingOption,
|
|
10522
|
-
shippingMethod
|
|
10523
|
-
});
|
|
10524
|
-
}
|
|
10525
|
-
} : void 0,
|
|
10526
|
-
{
|
|
10527
|
-
label: "Remove shipping option",
|
|
10528
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, {}),
|
|
10529
|
-
onClick: () => {
|
|
10530
|
-
if (shippingMethod) {
|
|
10531
|
-
if (addShippingMethodAction) {
|
|
10532
|
-
removeActionShippingMethod(
|
|
10533
|
-
addShippingMethodAction.id
|
|
10534
|
-
);
|
|
10535
|
-
} else {
|
|
10536
|
-
removeShippingMethod(
|
|
10537
|
-
shippingMethod.id
|
|
10538
|
-
);
|
|
10539
|
-
}
|
|
10540
|
-
}
|
|
10541
|
-
}
|
|
10542
|
-
}
|
|
10543
|
-
].filter(Boolean)
|
|
10544
|
-
}
|
|
10545
|
-
]
|
|
10546
|
-
}
|
|
10547
|
-
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
10548
|
-
StackedModalTrigger$1,
|
|
10549
|
-
{
|
|
10550
|
-
shippingProfileId: profile.id,
|
|
10551
|
-
shippingOption,
|
|
10552
|
-
shippingMethod,
|
|
10553
|
-
setData,
|
|
10554
|
-
children: "Add shipping option"
|
|
10555
|
-
}
|
|
10556
|
-
)
|
|
10557
|
-
] }),
|
|
10558
|
-
/* @__PURE__ */ jsxRuntime.jsxs(radixUi.Accordion.Content, { children: [
|
|
10559
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
10560
|
-
items.map((item, idx) => {
|
|
10561
|
-
var _a3, _b2, _c2, _d2, _e2;
|
|
10562
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
10563
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10564
|
-
"div",
|
|
10565
|
-
{
|
|
10566
|
-
className: "px-3 flex items-center gap-x-3",
|
|
10567
|
-
children: [
|
|
10568
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-5 h-[56px] flex flex-col justify-center items-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10569
|
-
ui.Divider,
|
|
10570
|
-
{
|
|
10571
|
-
variant: "dashed",
|
|
10572
|
-
orientation: "vertical"
|
|
10573
|
-
}
|
|
10574
|
-
) }),
|
|
10575
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "py-2 flex items-center gap-x-3", children: [
|
|
10576
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "size-7 flex items-center justify-center tabular-nums", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10577
|
-
ui.Text,
|
|
10578
|
-
{
|
|
10579
|
-
size: "small",
|
|
10580
|
-
leading: "compact",
|
|
10581
|
-
className: "text-ui-fg-subtle",
|
|
10582
|
-
children: [
|
|
10583
|
-
item.quantity,
|
|
10584
|
-
"x"
|
|
10585
|
-
]
|
|
10586
|
-
}
|
|
10587
|
-
) }),
|
|
10588
|
-
/* @__PURE__ */ jsxRuntime.jsx(Thumbnail, { thumbnail: item.thumbnail }),
|
|
10589
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
10590
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10591
|
-
ui.Text,
|
|
10592
|
-
{
|
|
10593
|
-
size: "small",
|
|
10594
|
-
leading: "compact",
|
|
10595
|
-
weight: "plus",
|
|
10596
|
-
children: [
|
|
10597
|
-
(_b2 = (_a3 = item.variant) == null ? void 0 : _a3.product) == null ? void 0 : _b2.title,
|
|
10598
|
-
" (",
|
|
10599
|
-
(_c2 = item.variant) == null ? void 0 : _c2.title,
|
|
10600
|
-
")"
|
|
10601
|
-
]
|
|
10602
|
-
}
|
|
10603
|
-
),
|
|
10604
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10605
|
-
ui.Text,
|
|
10606
|
-
{
|
|
10607
|
-
size: "small",
|
|
10608
|
-
leading: "compact",
|
|
10609
|
-
className: "text-ui-fg-subtle",
|
|
10610
|
-
children: (_e2 = (_d2 = item.variant) == null ? void 0 : _d2.options) == null ? void 0 : _e2.map((option) => option.value).join(" · ")
|
|
10611
|
-
}
|
|
10612
|
-
)
|
|
10613
|
-
] })
|
|
10614
|
-
] })
|
|
10615
|
-
]
|
|
10616
|
-
},
|
|
10617
|
-
item.id
|
|
10618
|
-
),
|
|
10619
|
-
idx !== items.length - 1 && /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" })
|
|
10620
|
-
] }, item.id);
|
|
10621
|
-
})
|
|
10622
|
-
] })
|
|
10623
|
-
]
|
|
10624
|
-
},
|
|
10625
|
-
profile.id
|
|
10626
|
-
);
|
|
10627
|
-
}) })
|
|
10628
|
-
] }) })
|
|
10629
|
-
] }) }),
|
|
10630
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10631
|
-
StackedFocusModal,
|
|
10632
|
-
{
|
|
10633
|
-
id: STACKED_FOCUS_MODAL_ID,
|
|
10634
|
-
onOpenChangeCallback: (open) => {
|
|
10635
|
-
if (!open) {
|
|
10636
|
-
setData(null);
|
|
10637
|
-
}
|
|
10638
|
-
return open;
|
|
10639
|
-
},
|
|
10640
|
-
children: data && /* @__PURE__ */ jsxRuntime.jsx(ShippingProfileForm, { data, order, preview })
|
|
10641
|
-
}
|
|
10642
|
-
)
|
|
10643
|
-
] }),
|
|
10644
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-x-2", children: [
|
|
10645
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
10646
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10647
|
-
ui.Button,
|
|
10648
|
-
{
|
|
10649
|
-
size: "small",
|
|
10650
|
-
type: "button",
|
|
10651
|
-
isLoading: isSubmitting,
|
|
10652
|
-
onClick: onSubmit,
|
|
10653
|
-
children: "Save"
|
|
10654
|
-
}
|
|
10655
|
-
)
|
|
10656
|
-
] }) })
|
|
10657
|
-
] });
|
|
10419
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: promotion.code }),
|
|
10420
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5 text-ui-fg-subtle", children: [
|
|
10421
|
+
displayValue && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
10422
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: displayValue }),
|
|
10423
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: "·" })
|
|
10424
|
+
] }),
|
|
10425
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", className: "capitalize", children: (_a = promotion.application_method) == null ? void 0 : _a.allocation })
|
|
10426
|
+
] })
|
|
10427
|
+
] }),
|
|
10428
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10429
|
+
ui.IconButton,
|
|
10430
|
+
{
|
|
10431
|
+
size: "small",
|
|
10432
|
+
type: "button",
|
|
10433
|
+
variant: "transparent",
|
|
10434
|
+
onClick: onRemove,
|
|
10435
|
+
isLoading: isPending || isLoading,
|
|
10436
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.XMark, {})
|
|
10437
|
+
}
|
|
10438
|
+
)
|
|
10439
|
+
]
|
|
10440
|
+
},
|
|
10441
|
+
promotion.id
|
|
10442
|
+
);
|
|
10658
10443
|
};
|
|
10659
|
-
|
|
10660
|
-
|
|
10661
|
-
|
|
10662
|
-
|
|
10663
|
-
|
|
10664
|
-
|
|
10665
|
-
|
|
10666
|
-
|
|
10667
|
-
|
|
10668
|
-
|
|
10669
|
-
if (isOpen) {
|
|
10670
|
-
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
10671
|
-
setData(null);
|
|
10672
|
-
} else {
|
|
10673
|
-
setIsOpen(STACKED_FOCUS_MODAL_ID, true);
|
|
10674
|
-
setData({
|
|
10675
|
-
shippingProfileId,
|
|
10676
|
-
shippingOption,
|
|
10677
|
-
shippingMethod
|
|
10678
|
-
});
|
|
10444
|
+
function getDisplayValue(promotion) {
|
|
10445
|
+
var _a, _b, _c, _d;
|
|
10446
|
+
const value = (_a = promotion.application_method) == null ? void 0 : _a.value;
|
|
10447
|
+
if (!value) {
|
|
10448
|
+
return null;
|
|
10449
|
+
}
|
|
10450
|
+
if (((_b = promotion.application_method) == null ? void 0 : _b.type) === "fixed") {
|
|
10451
|
+
const currency = (_c = promotion.application_method) == null ? void 0 : _c.currency_code;
|
|
10452
|
+
if (!currency) {
|
|
10453
|
+
return null;
|
|
10679
10454
|
}
|
|
10680
|
-
|
|
10681
|
-
|
|
10682
|
-
|
|
10455
|
+
return getLocaleAmount(value, currency);
|
|
10456
|
+
} else if (((_d = promotion.application_method) == null ? void 0 : _d.type) === "percentage") {
|
|
10457
|
+
return formatPercentage(value);
|
|
10458
|
+
}
|
|
10459
|
+
return null;
|
|
10460
|
+
}
|
|
10461
|
+
const formatter = new Intl.NumberFormat([], {
|
|
10462
|
+
style: "percent",
|
|
10463
|
+
minimumFractionDigits: 2
|
|
10464
|
+
});
|
|
10465
|
+
const formatPercentage = (value, isPercentageValue = false) => {
|
|
10466
|
+
let val = value || 0;
|
|
10467
|
+
if (!isPercentageValue) {
|
|
10468
|
+
val = val / 100;
|
|
10469
|
+
}
|
|
10470
|
+
return formatter.format(val);
|
|
10471
|
+
};
|
|
10472
|
+
function getPromotionCodes(items, shippingMethods) {
|
|
10473
|
+
const codes = /* @__PURE__ */ new Set();
|
|
10474
|
+
for (const item of items) {
|
|
10475
|
+
if (item.adjustments) {
|
|
10476
|
+
for (const adjustment of item.adjustments) {
|
|
10477
|
+
if (adjustment.code) {
|
|
10478
|
+
codes.add(adjustment.code);
|
|
10479
|
+
}
|
|
10480
|
+
}
|
|
10481
|
+
}
|
|
10482
|
+
}
|
|
10483
|
+
for (const shippingMethod of shippingMethods) {
|
|
10484
|
+
if (shippingMethod.adjustments) {
|
|
10485
|
+
for (const adjustment of shippingMethod.adjustments) {
|
|
10486
|
+
if (adjustment.code) {
|
|
10487
|
+
codes.add(adjustment.code);
|
|
10488
|
+
}
|
|
10489
|
+
}
|
|
10490
|
+
}
|
|
10491
|
+
}
|
|
10492
|
+
return Array.from(codes);
|
|
10493
|
+
}
|
|
10494
|
+
const SalesChannel = () => {
|
|
10495
|
+
const { id } = reactRouterDom.useParams();
|
|
10496
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
10497
|
+
id,
|
|
10683
10498
|
{
|
|
10684
|
-
|
|
10685
|
-
|
|
10686
|
-
|
|
10687
|
-
|
|
10688
|
-
children
|
|
10499
|
+
fields: "+sales_channel_id"
|
|
10500
|
+
},
|
|
10501
|
+
{
|
|
10502
|
+
enabled: !!id
|
|
10689
10503
|
}
|
|
10690
10504
|
);
|
|
10505
|
+
if (isError) {
|
|
10506
|
+
throw error;
|
|
10507
|
+
}
|
|
10508
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
10509
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
10510
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
10511
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
10512
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
10513
|
+
] }),
|
|
10514
|
+
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
10515
|
+
] });
|
|
10691
10516
|
};
|
|
10692
|
-
const
|
|
10693
|
-
data,
|
|
10694
|
-
order,
|
|
10695
|
-
preview
|
|
10696
|
-
}) => {
|
|
10697
|
-
var _a, _b, _c, _d, _e, _f;
|
|
10698
|
-
const { setIsOpen } = useStackedModal();
|
|
10517
|
+
const SalesChannelForm = ({ order }) => {
|
|
10699
10518
|
const form = reactHookForm.useForm({
|
|
10700
|
-
resolver: zod.zodResolver(shippingMethodSchema),
|
|
10701
10519
|
defaultValues: {
|
|
10702
|
-
|
|
10703
|
-
|
|
10704
|
-
|
|
10705
|
-
}
|
|
10520
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
10521
|
+
},
|
|
10522
|
+
resolver: zod.zodResolver(schema$3)
|
|
10706
10523
|
});
|
|
10707
|
-
const { mutateAsync
|
|
10708
|
-
const {
|
|
10709
|
-
|
|
10710
|
-
|
|
10711
|
-
} = useDraftOrderUpdateShippingMethod(order.id);
|
|
10712
|
-
const onSubmit = form.handleSubmit(async (values) => {
|
|
10713
|
-
if (lodash.isEqual(values, form.formState.defaultValues)) {
|
|
10714
|
-
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
10715
|
-
return;
|
|
10716
|
-
}
|
|
10717
|
-
if (data.shippingMethod) {
|
|
10718
|
-
await updateShippingMethod(
|
|
10719
|
-
{
|
|
10720
|
-
method_id: data.shippingMethod.id,
|
|
10721
|
-
shipping_option_id: values.shipping_option_id,
|
|
10722
|
-
custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
|
|
10723
|
-
},
|
|
10724
|
-
{
|
|
10725
|
-
onError: (e) => {
|
|
10726
|
-
ui.toast.error(e.message);
|
|
10727
|
-
},
|
|
10728
|
-
onSuccess: () => {
|
|
10729
|
-
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
10730
|
-
}
|
|
10731
|
-
}
|
|
10732
|
-
);
|
|
10733
|
-
return;
|
|
10734
|
-
}
|
|
10735
|
-
await addShippingMethod(
|
|
10524
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
10525
|
+
const { handleSuccess } = useRouteModal();
|
|
10526
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
10527
|
+
await mutateAsync(
|
|
10736
10528
|
{
|
|
10737
|
-
|
|
10738
|
-
custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
|
|
10529
|
+
sales_channel_id: data.sales_channel_id
|
|
10739
10530
|
},
|
|
10740
10531
|
{
|
|
10741
|
-
onError: (e) => {
|
|
10742
|
-
ui.toast.error(e.message);
|
|
10743
|
-
},
|
|
10744
10532
|
onSuccess: () => {
|
|
10745
|
-
|
|
10533
|
+
ui.toast.success("Sales channel updated");
|
|
10534
|
+
handleSuccess();
|
|
10535
|
+
},
|
|
10536
|
+
onError: (error) => {
|
|
10537
|
+
ui.toast.error(error.message);
|
|
10746
10538
|
}
|
|
10747
10539
|
}
|
|
10748
10540
|
);
|
|
10749
10541
|
});
|
|
10750
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10542
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10751
10543
|
KeyboundForm,
|
|
10752
10544
|
{
|
|
10753
|
-
className: "flex
|
|
10545
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
10754
10546
|
onSubmit,
|
|
10755
10547
|
children: [
|
|
10756
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10757
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10758
|
-
/* @__PURE__ */ jsxRuntime.
|
|
10759
|
-
|
|
10760
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Add a shipping method for the selected shipping profile. You can see the items that will be shipped using this method in the preview below." }) })
|
|
10761
|
-
] }),
|
|
10762
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
10763
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10764
|
-
LocationField,
|
|
10765
|
-
{
|
|
10766
|
-
control: form.control,
|
|
10767
|
-
setValue: form.setValue
|
|
10768
|
-
}
|
|
10769
|
-
),
|
|
10770
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
10771
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10772
|
-
ShippingOptionField,
|
|
10773
|
-
{
|
|
10774
|
-
shippingProfileId: data.shippingProfileId,
|
|
10775
|
-
preview,
|
|
10776
|
-
control: form.control
|
|
10777
|
-
}
|
|
10778
|
-
),
|
|
10779
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
10780
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10781
|
-
CustomAmountField,
|
|
10782
|
-
{
|
|
10783
|
-
control: form.control,
|
|
10784
|
-
currencyCode: order.currency_code
|
|
10785
|
-
}
|
|
10786
|
-
),
|
|
10787
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
10788
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10789
|
-
ItemsPreview,
|
|
10790
|
-
{
|
|
10791
|
-
order,
|
|
10792
|
-
shippingProfileId: data.shippingProfileId
|
|
10793
|
-
}
|
|
10794
|
-
)
|
|
10795
|
-
] }) }) }),
|
|
10796
|
-
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-x-2", children: [
|
|
10797
|
-
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
10798
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10799
|
-
ui.Button,
|
|
10800
|
-
{
|
|
10801
|
-
size: "small",
|
|
10802
|
-
type: "submit",
|
|
10803
|
-
isLoading: isPending || isUpdatingShippingMethod,
|
|
10804
|
-
children: data.shippingMethod ? "Update" : "Add"
|
|
10805
|
-
}
|
|
10806
|
-
)
|
|
10548
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
10549
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
10550
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
10551
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
10807
10552
|
] }) })
|
|
10808
10553
|
]
|
|
10809
10554
|
}
|
|
10810
|
-
) })
|
|
10555
|
+
) });
|
|
10811
10556
|
};
|
|
10812
|
-
const
|
|
10813
|
-
|
|
10814
|
-
|
|
10815
|
-
|
|
10557
|
+
const SalesChannelField = ({ control, order }) => {
|
|
10558
|
+
const salesChannels = useComboboxData({
|
|
10559
|
+
queryFn: async (params) => {
|
|
10560
|
+
return await sdk.admin.salesChannel.list(params);
|
|
10561
|
+
},
|
|
10562
|
+
queryKey: ["sales-channels"],
|
|
10563
|
+
getOptions: (data) => {
|
|
10564
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
10565
|
+
label: salesChannel.name,
|
|
10566
|
+
value: salesChannel.id
|
|
10567
|
+
}));
|
|
10568
|
+
},
|
|
10569
|
+
defaultValue: order.sales_channel_id || void 0
|
|
10570
|
+
});
|
|
10571
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10572
|
+
Form$2.Field,
|
|
10573
|
+
{
|
|
10574
|
+
control,
|
|
10575
|
+
name: "sales_channel_id",
|
|
10576
|
+
render: ({ field }) => {
|
|
10577
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
10578
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
10579
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10580
|
+
Combobox,
|
|
10581
|
+
{
|
|
10582
|
+
options: salesChannels.options,
|
|
10583
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
10584
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
10585
|
+
searchValue: salesChannels.searchValue,
|
|
10586
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
10587
|
+
placeholder: "Select sales channel",
|
|
10588
|
+
...field
|
|
10589
|
+
}
|
|
10590
|
+
) }),
|
|
10591
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
10592
|
+
] });
|
|
10593
|
+
}
|
|
10594
|
+
}
|
|
10595
|
+
);
|
|
10596
|
+
};
|
|
10597
|
+
const schema$3 = objectType({
|
|
10598
|
+
sales_channel_id: stringType().min(1)
|
|
10816
10599
|
});
|
|
10817
|
-
|
|
10818
|
-
|
|
10819
|
-
|
|
10820
|
-
|
|
10821
|
-
|
|
10600
|
+
function convertNumber(value) {
|
|
10601
|
+
return typeof value === "string" ? Number(value.replace(",", ".")) : value;
|
|
10602
|
+
}
|
|
10603
|
+
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
10604
|
+
const Shipping = () => {
|
|
10605
|
+
var _a;
|
|
10606
|
+
const { id } = reactRouterDom.useParams();
|
|
10607
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
10608
|
+
fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
|
|
10609
|
+
});
|
|
10610
|
+
const {
|
|
10611
|
+
order: preview,
|
|
10612
|
+
isPending: isPreviewPending,
|
|
10613
|
+
isError: isPreviewError,
|
|
10614
|
+
error: previewError
|
|
10615
|
+
} = useOrderPreview(id);
|
|
10616
|
+
useInitiateOrderEdit({ preview });
|
|
10617
|
+
const { onCancel } = useCancelOrderEdit({ preview });
|
|
10618
|
+
if (isError) {
|
|
10619
|
+
throw error;
|
|
10620
|
+
}
|
|
10621
|
+
if (isPreviewError) {
|
|
10622
|
+
throw previewError;
|
|
10623
|
+
}
|
|
10624
|
+
const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
|
|
10625
|
+
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
10626
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
10627
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
10628
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 py-16 px-6", children: [
|
|
10629
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
10630
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
|
|
10631
|
+
] }) }) }),
|
|
10632
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
|
|
10633
|
+
] }) : isReady ? /* @__PURE__ */ jsxRuntime.jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
10634
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
10635
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
10636
|
+
] }) });
|
|
10637
|
+
};
|
|
10638
|
+
const ShippingForm = ({ preview, order }) => {
|
|
10639
|
+
var _a;
|
|
10640
|
+
const { setIsOpen } = useStackedModal();
|
|
10641
|
+
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
10642
|
+
const [data, setData] = React.useState(null);
|
|
10643
|
+
const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
|
|
10644
|
+
const { shipping_options } = useShippingOptions(
|
|
10645
|
+
{
|
|
10646
|
+
id: appliedShippingOptionIds,
|
|
10647
|
+
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
10648
|
+
},
|
|
10649
|
+
{
|
|
10650
|
+
enabled: appliedShippingOptionIds.length > 0
|
|
10651
|
+
}
|
|
10652
|
+
);
|
|
10653
|
+
const uniqueShippingProfiles = React.useMemo(() => {
|
|
10654
|
+
const profiles = /* @__PURE__ */ new Map();
|
|
10655
|
+
getUniqueShippingProfiles(order.items).forEach((profile) => {
|
|
10656
|
+
profiles.set(profile.id, profile);
|
|
10657
|
+
});
|
|
10658
|
+
shipping_options == null ? void 0 : shipping_options.forEach((option) => {
|
|
10659
|
+
profiles.set(option.shipping_profile_id, option.shipping_profile);
|
|
10660
|
+
});
|
|
10661
|
+
return Array.from(profiles.values());
|
|
10662
|
+
}, [order.items, shipping_options]);
|
|
10663
|
+
const { handleSuccess } = useRouteModal();
|
|
10664
|
+
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
10665
|
+
const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
|
|
10666
|
+
const { mutateAsync: removeShippingMethod } = useDraftOrderRemoveShippingMethod(preview.id);
|
|
10667
|
+
const { mutateAsync: removeActionShippingMethod } = useDraftOrderRemoveActionShippingMethod(preview.id);
|
|
10668
|
+
const onSubmit = async () => {
|
|
10669
|
+
setIsSubmitting(true);
|
|
10670
|
+
let requestSucceeded = false;
|
|
10671
|
+
await requestOrderEdit(void 0, {
|
|
10672
|
+
onError: (e) => {
|
|
10673
|
+
ui.toast.error(`Failed to request order edit: ${e.message}`);
|
|
10674
|
+
},
|
|
10675
|
+
onSuccess: () => {
|
|
10676
|
+
requestSucceeded = true;
|
|
10677
|
+
}
|
|
10678
|
+
});
|
|
10679
|
+
if (!requestSucceeded) {
|
|
10680
|
+
setIsSubmitting(false);
|
|
10681
|
+
return;
|
|
10822
10682
|
}
|
|
10683
|
+
await confirmOrderEdit(void 0, {
|
|
10684
|
+
onError: (e) => {
|
|
10685
|
+
ui.toast.error(`Failed to confirm order edit: ${e.message}`);
|
|
10686
|
+
},
|
|
10687
|
+
onSuccess: () => {
|
|
10688
|
+
handleSuccess();
|
|
10689
|
+
},
|
|
10690
|
+
onSettled: () => {
|
|
10691
|
+
setIsSubmitting(false);
|
|
10692
|
+
}
|
|
10693
|
+
});
|
|
10694
|
+
};
|
|
10695
|
+
const onKeydown = React.useCallback(
|
|
10696
|
+
(e) => {
|
|
10697
|
+
if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
|
|
10698
|
+
if (data || isSubmitting) {
|
|
10699
|
+
return;
|
|
10700
|
+
}
|
|
10701
|
+
onSubmit();
|
|
10702
|
+
}
|
|
10703
|
+
},
|
|
10704
|
+
[data, isSubmitting, onSubmit]
|
|
10823
10705
|
);
|
|
10824
|
-
|
|
10825
|
-
|
|
10826
|
-
|
|
10827
|
-
|
|
10828
|
-
|
|
10829
|
-
|
|
10830
|
-
|
|
10831
|
-
|
|
10832
|
-
|
|
10833
|
-
]
|
|
10834
|
-
|
|
10835
|
-
|
|
10836
|
-
|
|
10837
|
-
|
|
10838
|
-
|
|
10839
|
-
|
|
10840
|
-
|
|
10841
|
-
|
|
10842
|
-
{
|
|
10843
|
-
thumbnail: item.thumbnail,
|
|
10844
|
-
alt: item.product_title ?? void 0
|
|
10845
|
-
}
|
|
10846
|
-
),
|
|
10847
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
10848
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-1", children: [
|
|
10849
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: item.product_title }),
|
|
10850
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10851
|
-
ui.Text,
|
|
10852
|
-
{
|
|
10853
|
-
size: "small",
|
|
10854
|
-
leading: "compact",
|
|
10855
|
-
className: "text-ui-fg-subtle",
|
|
10856
|
-
children: [
|
|
10857
|
-
"(",
|
|
10858
|
-
item.variant_title,
|
|
10859
|
-
")"
|
|
10860
|
-
]
|
|
10861
|
-
}
|
|
10862
|
-
)
|
|
10863
|
-
] }),
|
|
10864
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10865
|
-
ui.Text,
|
|
10866
|
-
{
|
|
10867
|
-
size: "small",
|
|
10868
|
-
leading: "compact",
|
|
10869
|
-
className: "text-ui-fg-subtle",
|
|
10870
|
-
children: item.variant_sku
|
|
10871
|
-
}
|
|
10872
|
-
)
|
|
10873
|
-
] })
|
|
10874
|
-
] }),
|
|
10875
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10706
|
+
React.useEffect(() => {
|
|
10707
|
+
document.addEventListener("keydown", onKeydown);
|
|
10708
|
+
return () => {
|
|
10709
|
+
document.removeEventListener("keydown", onKeydown);
|
|
10710
|
+
};
|
|
10711
|
+
}, [onKeydown]);
|
|
10712
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
|
|
10713
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
10714
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
10715
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 py-16 px-6", children: [
|
|
10716
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
10717
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
10718
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Choose which shipping method(s) to use for the items in the order." }) })
|
|
10719
|
+
] }),
|
|
10720
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
10721
|
+
/* @__PURE__ */ jsxRuntime.jsx(radixUi.Accordion.Root, { type: "multiple", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle rounded-xl shadow-elevation-card-rest", children: [
|
|
10722
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-4 py-2 flex items-center justify-between", children: [
|
|
10723
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10876
10724
|
ui.Text,
|
|
10877
10725
|
{
|
|
10878
|
-
size: "
|
|
10879
|
-
|
|
10880
|
-
className: "text-ui-fg-
|
|
10726
|
+
size: "xsmall",
|
|
10727
|
+
weight: "plus",
|
|
10728
|
+
className: "text-ui-fg-muted",
|
|
10729
|
+
children: "Shipping profile"
|
|
10730
|
+
}
|
|
10731
|
+
),
|
|
10732
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10733
|
+
ui.Text,
|
|
10734
|
+
{
|
|
10735
|
+
size: "xsmall",
|
|
10736
|
+
weight: "plus",
|
|
10737
|
+
className: "text-ui-fg-muted",
|
|
10738
|
+
children: "Action"
|
|
10739
|
+
}
|
|
10740
|
+
)
|
|
10741
|
+
] }),
|
|
10742
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-[5px] pb-[5px]", children: uniqueShippingProfiles.map((profile) => {
|
|
10743
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
|
10744
|
+
const items = getItemsWithShippingProfile(
|
|
10745
|
+
profile.id,
|
|
10746
|
+
order.items
|
|
10747
|
+
);
|
|
10748
|
+
const hasItems = items.length > 0;
|
|
10749
|
+
const shippingOption = shipping_options == null ? void 0 : shipping_options.find(
|
|
10750
|
+
(option) => option.shipping_profile_id === profile.id
|
|
10751
|
+
);
|
|
10752
|
+
const shippingMethod = preview.shipping_methods.find(
|
|
10753
|
+
(method) => method.shipping_option_id === (shippingOption == null ? void 0 : shippingOption.id)
|
|
10754
|
+
);
|
|
10755
|
+
const addShippingMethodAction = (_a2 = shippingMethod == null ? void 0 : shippingMethod.actions) == null ? void 0 : _a2.find(
|
|
10756
|
+
(action) => action.action === "SHIPPING_ADD"
|
|
10757
|
+
);
|
|
10758
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10759
|
+
radixUi.Accordion.Item,
|
|
10760
|
+
{
|
|
10761
|
+
value: profile.id,
|
|
10762
|
+
className: "bg-ui-bg-base shadow-elevation-card-rest rounded-lg",
|
|
10881
10763
|
children: [
|
|
10882
|
-
|
|
10883
|
-
|
|
10764
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-3 py-2 flex items-center justify-between gap-3", children: [
|
|
10765
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3 w-full overflow-hidden", children: [
|
|
10766
|
+
/* @__PURE__ */ jsxRuntime.jsx(radixUi.Accordion.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10767
|
+
ui.IconButton,
|
|
10768
|
+
{
|
|
10769
|
+
size: "2xsmall",
|
|
10770
|
+
variant: "transparent",
|
|
10771
|
+
className: "group/trigger",
|
|
10772
|
+
disabled: !hasItems,
|
|
10773
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.TriangleRightMini, { className: "group-data-[state=open]/trigger:rotate-90 transition-transform" })
|
|
10774
|
+
}
|
|
10775
|
+
) }),
|
|
10776
|
+
!shippingOption ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3", children: [
|
|
10777
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "size-7 rounded-md shadow-borders-base flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "size-6 rounded bg-ui-bg-component-hover flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(icons.Shopping, { className: "text-ui-fg-subtle" }) }) }),
|
|
10778
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col flex-1", children: [
|
|
10779
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10780
|
+
ui.Text,
|
|
10781
|
+
{
|
|
10782
|
+
size: "small",
|
|
10783
|
+
weight: "plus",
|
|
10784
|
+
leading: "compact",
|
|
10785
|
+
children: profile.name
|
|
10786
|
+
}
|
|
10787
|
+
),
|
|
10788
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10789
|
+
ui.Text,
|
|
10790
|
+
{
|
|
10791
|
+
size: "small",
|
|
10792
|
+
leading: "compact",
|
|
10793
|
+
className: "text-ui-fg-subtle",
|
|
10794
|
+
children: [
|
|
10795
|
+
items.length,
|
|
10796
|
+
" ",
|
|
10797
|
+
pluralize(items.length, "items", "item")
|
|
10798
|
+
]
|
|
10799
|
+
}
|
|
10800
|
+
)
|
|
10801
|
+
] })
|
|
10802
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-[5px] max-sm:flex-col max-sm:items-start flex-1 w-full overflow-hidden", children: [
|
|
10803
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10804
|
+
ui.Tooltip,
|
|
10805
|
+
{
|
|
10806
|
+
content: /* @__PURE__ */ jsxRuntime.jsx("ul", { children: items.map((item) => {
|
|
10807
|
+
var _a3, _b2, _c2;
|
|
10808
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10809
|
+
"li",
|
|
10810
|
+
{
|
|
10811
|
+
children: `${item.quantity}x ${(_b2 = (_a3 = item.variant) == null ? void 0 : _a3.product) == null ? void 0 : _b2.title} (${(_c2 = item.variant) == null ? void 0 : _c2.title})`
|
|
10812
|
+
},
|
|
10813
|
+
item.id
|
|
10814
|
+
);
|
|
10815
|
+
}) }),
|
|
10816
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10817
|
+
ui.Badge,
|
|
10818
|
+
{
|
|
10819
|
+
className: "flex items-center gap-x-[3px] overflow-hidden cursor-default",
|
|
10820
|
+
size: "xsmall",
|
|
10821
|
+
children: [
|
|
10822
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.Shopping, { className: "shrink-0" }),
|
|
10823
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "truncate", children: [
|
|
10824
|
+
items.reduce(
|
|
10825
|
+
(acc, item) => acc + item.quantity,
|
|
10826
|
+
0
|
|
10827
|
+
),
|
|
10828
|
+
"x",
|
|
10829
|
+
" ",
|
|
10830
|
+
pluralize(items.length, "items", "item")
|
|
10831
|
+
] })
|
|
10832
|
+
]
|
|
10833
|
+
}
|
|
10834
|
+
)
|
|
10835
|
+
}
|
|
10836
|
+
),
|
|
10837
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10838
|
+
ui.Tooltip,
|
|
10839
|
+
{
|
|
10840
|
+
content: (_d = (_c = (_b = shippingOption.service_zone) == null ? void 0 : _b.fulfillment_set) == null ? void 0 : _c.location) == null ? void 0 : _d.name,
|
|
10841
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10842
|
+
ui.Badge,
|
|
10843
|
+
{
|
|
10844
|
+
className: "flex items-center gap-x-[3px] overflow-hidden cursor-default",
|
|
10845
|
+
size: "xsmall",
|
|
10846
|
+
children: [
|
|
10847
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.Buildings, { className: "shrink-0" }),
|
|
10848
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: (_g = (_f = (_e = shippingOption.service_zone) == null ? void 0 : _e.fulfillment_set) == null ? void 0 : _f.location) == null ? void 0 : _g.name })
|
|
10849
|
+
]
|
|
10850
|
+
}
|
|
10851
|
+
)
|
|
10852
|
+
}
|
|
10853
|
+
),
|
|
10854
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { content: shippingOption.name, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10855
|
+
ui.Badge,
|
|
10856
|
+
{
|
|
10857
|
+
className: "flex items-center gap-x-[3px] overflow-hidden cursor-default",
|
|
10858
|
+
size: "xsmall",
|
|
10859
|
+
children: [
|
|
10860
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.TruckFast, { className: "shrink-0" }),
|
|
10861
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: shippingOption.name })
|
|
10862
|
+
]
|
|
10863
|
+
}
|
|
10864
|
+
) })
|
|
10865
|
+
] })
|
|
10866
|
+
] }),
|
|
10867
|
+
shippingOption ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
10868
|
+
ActionMenu,
|
|
10869
|
+
{
|
|
10870
|
+
groups: [
|
|
10871
|
+
{
|
|
10872
|
+
actions: [
|
|
10873
|
+
hasItems ? {
|
|
10874
|
+
label: "Edit shipping option",
|
|
10875
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Channels, {}),
|
|
10876
|
+
onClick: () => {
|
|
10877
|
+
setIsOpen(
|
|
10878
|
+
STACKED_FOCUS_MODAL_ID,
|
|
10879
|
+
true
|
|
10880
|
+
);
|
|
10881
|
+
setData({
|
|
10882
|
+
shippingProfileId: profile.id,
|
|
10883
|
+
shippingOption,
|
|
10884
|
+
shippingMethod
|
|
10885
|
+
});
|
|
10886
|
+
}
|
|
10887
|
+
} : void 0,
|
|
10888
|
+
{
|
|
10889
|
+
label: "Remove shipping option",
|
|
10890
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, {}),
|
|
10891
|
+
onClick: () => {
|
|
10892
|
+
if (shippingMethod) {
|
|
10893
|
+
if (addShippingMethodAction) {
|
|
10894
|
+
removeActionShippingMethod(
|
|
10895
|
+
addShippingMethodAction.id
|
|
10896
|
+
);
|
|
10897
|
+
} else {
|
|
10898
|
+
removeShippingMethod(
|
|
10899
|
+
shippingMethod.id
|
|
10900
|
+
);
|
|
10901
|
+
}
|
|
10902
|
+
}
|
|
10903
|
+
}
|
|
10904
|
+
}
|
|
10905
|
+
].filter(Boolean)
|
|
10906
|
+
}
|
|
10907
|
+
]
|
|
10908
|
+
}
|
|
10909
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
10910
|
+
StackedModalTrigger$1,
|
|
10911
|
+
{
|
|
10912
|
+
shippingProfileId: profile.id,
|
|
10913
|
+
shippingOption,
|
|
10914
|
+
shippingMethod,
|
|
10915
|
+
setData,
|
|
10916
|
+
children: "Add shipping option"
|
|
10917
|
+
}
|
|
10918
|
+
)
|
|
10919
|
+
] }),
|
|
10920
|
+
/* @__PURE__ */ jsxRuntime.jsxs(radixUi.Accordion.Content, { children: [
|
|
10921
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
10922
|
+
items.map((item, idx) => {
|
|
10923
|
+
var _a3, _b2, _c2, _d2, _e2;
|
|
10924
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
10925
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10926
|
+
"div",
|
|
10927
|
+
{
|
|
10928
|
+
className: "px-3 flex items-center gap-x-3",
|
|
10929
|
+
children: [
|
|
10930
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-5 h-[56px] flex flex-col justify-center items-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10931
|
+
ui.Divider,
|
|
10932
|
+
{
|
|
10933
|
+
variant: "dashed",
|
|
10934
|
+
orientation: "vertical"
|
|
10935
|
+
}
|
|
10936
|
+
) }),
|
|
10937
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "py-2 flex items-center gap-x-3", children: [
|
|
10938
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "size-7 flex items-center justify-center tabular-nums", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10939
|
+
ui.Text,
|
|
10940
|
+
{
|
|
10941
|
+
size: "small",
|
|
10942
|
+
leading: "compact",
|
|
10943
|
+
className: "text-ui-fg-subtle",
|
|
10944
|
+
children: [
|
|
10945
|
+
item.quantity,
|
|
10946
|
+
"x"
|
|
10947
|
+
]
|
|
10948
|
+
}
|
|
10949
|
+
) }),
|
|
10950
|
+
/* @__PURE__ */ jsxRuntime.jsx(Thumbnail, { thumbnail: item.thumbnail }),
|
|
10951
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
10952
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10953
|
+
ui.Text,
|
|
10954
|
+
{
|
|
10955
|
+
size: "small",
|
|
10956
|
+
leading: "compact",
|
|
10957
|
+
weight: "plus",
|
|
10958
|
+
children: [
|
|
10959
|
+
(_b2 = (_a3 = item.variant) == null ? void 0 : _a3.product) == null ? void 0 : _b2.title,
|
|
10960
|
+
" (",
|
|
10961
|
+
(_c2 = item.variant) == null ? void 0 : _c2.title,
|
|
10962
|
+
")"
|
|
10963
|
+
]
|
|
10964
|
+
}
|
|
10965
|
+
),
|
|
10966
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10967
|
+
ui.Text,
|
|
10968
|
+
{
|
|
10969
|
+
size: "small",
|
|
10970
|
+
leading: "compact",
|
|
10971
|
+
className: "text-ui-fg-subtle",
|
|
10972
|
+
children: (_e2 = (_d2 = item.variant) == null ? void 0 : _d2.options) == null ? void 0 : _e2.map((option) => option.value).join(" · ")
|
|
10973
|
+
}
|
|
10974
|
+
)
|
|
10975
|
+
] })
|
|
10976
|
+
] })
|
|
10977
|
+
]
|
|
10978
|
+
},
|
|
10979
|
+
item.id
|
|
10980
|
+
),
|
|
10981
|
+
idx !== items.length - 1 && /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" })
|
|
10982
|
+
] }, item.id);
|
|
10983
|
+
})
|
|
10984
|
+
] })
|
|
10884
10985
|
]
|
|
10885
|
-
}
|
|
10886
|
-
)
|
|
10887
|
-
]
|
|
10888
|
-
},
|
|
10889
|
-
item.id
|
|
10890
|
-
)) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center gap-x-3 bg-ui-bg-base rounded-lg p-4 shadow-elevation-card-rest flex-col gap-1", children: [
|
|
10891
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: "No items found" }),
|
|
10892
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
10893
|
-
'No items found for "',
|
|
10894
|
-
query,
|
|
10895
|
-
'".'
|
|
10896
|
-
] })
|
|
10897
|
-
] }) })
|
|
10898
|
-
] })
|
|
10899
|
-
] });
|
|
10900
|
-
};
|
|
10901
|
-
const LocationField = ({ control, setValue }) => {
|
|
10902
|
-
const locations = useComboboxData({
|
|
10903
|
-
queryKey: ["locations"],
|
|
10904
|
-
queryFn: async (params) => {
|
|
10905
|
-
return await sdk.admin.stockLocation.list(params);
|
|
10906
|
-
},
|
|
10907
|
-
getOptions: (data) => {
|
|
10908
|
-
return data.stock_locations.map((location) => ({
|
|
10909
|
-
label: location.name,
|
|
10910
|
-
value: location.id
|
|
10911
|
-
}));
|
|
10912
|
-
}
|
|
10913
|
-
});
|
|
10914
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10915
|
-
Form$2.Field,
|
|
10916
|
-
{
|
|
10917
|
-
control,
|
|
10918
|
-
name: "location_id",
|
|
10919
|
-
render: ({ field: { onChange, ...field } }) => {
|
|
10920
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
10921
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
10922
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Location" }),
|
|
10923
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Choose where you want to ship the items from." })
|
|
10924
|
-
] }),
|
|
10925
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10926
|
-
Combobox,
|
|
10927
|
-
{
|
|
10928
|
-
options: locations.options,
|
|
10929
|
-
fetchNextPage: locations.fetchNextPage,
|
|
10930
|
-
isFetchingNextPage: locations.isFetchingNextPage,
|
|
10931
|
-
searchValue: locations.searchValue,
|
|
10932
|
-
onSearchValueChange: locations.onSearchValueChange,
|
|
10933
|
-
placeholder: "Select location",
|
|
10934
|
-
onChange: (value) => {
|
|
10935
|
-
setValue("shipping_option_id", "", {
|
|
10936
|
-
shouldDirty: true,
|
|
10937
|
-
shouldTouch: true
|
|
10938
|
-
});
|
|
10939
|
-
onChange(value);
|
|
10940
10986
|
},
|
|
10941
|
-
|
|
10942
|
-
|
|
10943
|
-
) })
|
|
10944
|
-
] }) })
|
|
10945
|
-
}
|
|
10946
|
-
|
|
10947
|
-
|
|
10948
|
-
|
|
10949
|
-
|
|
10950
|
-
|
|
10951
|
-
|
|
10952
|
-
|
|
10953
|
-
}) => {
|
|
10954
|
-
var _a;
|
|
10955
|
-
const locationId = reactHookForm.useWatch({ control, name: "location_id" });
|
|
10956
|
-
const shippingOptions = useComboboxData({
|
|
10957
|
-
queryKey: ["shipping_options", locationId, shippingProfileId],
|
|
10958
|
-
queryFn: async (params) => {
|
|
10959
|
-
return await sdk.admin.shippingOption.list({
|
|
10960
|
-
...params,
|
|
10961
|
-
stock_location_id: locationId,
|
|
10962
|
-
shipping_profile_id: shippingProfileId
|
|
10963
|
-
});
|
|
10964
|
-
},
|
|
10965
|
-
getOptions: (data) => {
|
|
10966
|
-
return data.shipping_options.map((option) => {
|
|
10967
|
-
var _a2;
|
|
10968
|
-
if ((_a2 = option.rules) == null ? void 0 : _a2.find(
|
|
10969
|
-
(r) => r.attribute === "is_return" && r.value === "true"
|
|
10970
|
-
)) {
|
|
10971
|
-
return void 0;
|
|
10972
|
-
}
|
|
10973
|
-
return {
|
|
10974
|
-
label: option.name,
|
|
10975
|
-
value: option.id
|
|
10976
|
-
};
|
|
10977
|
-
}).filter(Boolean);
|
|
10978
|
-
},
|
|
10979
|
-
enabled: !!locationId && !!shippingProfileId,
|
|
10980
|
-
defaultValue: ((_a = preview.shipping_methods[0]) == null ? void 0 : _a.shipping_option_id) || void 0
|
|
10981
|
-
});
|
|
10982
|
-
const tooltipContent = !locationId && !shippingProfileId ? "Choose a location and shipping profile first." : !locationId ? "Choose a location first." : "Choose a shipping profile first.";
|
|
10983
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10984
|
-
Form$2.Field,
|
|
10985
|
-
{
|
|
10986
|
-
control,
|
|
10987
|
-
name: "shipping_option_id",
|
|
10988
|
-
render: ({ field }) => {
|
|
10989
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
10990
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
10991
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Shipping option" }),
|
|
10992
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Choose the shipping option to use." })
|
|
10993
|
-
] }),
|
|
10994
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10995
|
-
ConditionalTooltip,
|
|
10996
|
-
{
|
|
10997
|
-
content: tooltipContent,
|
|
10998
|
-
showTooltip: !locationId || !shippingProfileId,
|
|
10999
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11000
|
-
Combobox,
|
|
11001
|
-
{
|
|
11002
|
-
options: shippingOptions.options,
|
|
11003
|
-
fetchNextPage: shippingOptions.fetchNextPage,
|
|
11004
|
-
isFetchingNextPage: shippingOptions.isFetchingNextPage,
|
|
11005
|
-
searchValue: shippingOptions.searchValue,
|
|
11006
|
-
onSearchValueChange: shippingOptions.onSearchValueChange,
|
|
11007
|
-
placeholder: "Select shipping option",
|
|
11008
|
-
...field,
|
|
11009
|
-
disabled: !locationId || !shippingProfileId
|
|
11010
|
-
}
|
|
11011
|
-
) }) })
|
|
10987
|
+
profile.id
|
|
10988
|
+
);
|
|
10989
|
+
}) })
|
|
10990
|
+
] }) })
|
|
10991
|
+
] }) }),
|
|
10992
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10993
|
+
StackedFocusModal,
|
|
10994
|
+
{
|
|
10995
|
+
id: STACKED_FOCUS_MODAL_ID,
|
|
10996
|
+
onOpenChangeCallback: (open) => {
|
|
10997
|
+
if (!open) {
|
|
10998
|
+
setData(null);
|
|
11012
10999
|
}
|
|
11013
|
-
|
|
11014
|
-
|
|
11015
|
-
|
|
11016
|
-
|
|
11017
|
-
|
|
11000
|
+
return open;
|
|
11001
|
+
},
|
|
11002
|
+
children: data && /* @__PURE__ */ jsxRuntime.jsx(ShippingProfileForm, { data, order, preview })
|
|
11003
|
+
}
|
|
11004
|
+
)
|
|
11005
|
+
] }),
|
|
11006
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-x-2", children: [
|
|
11007
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
11008
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11009
|
+
ui.Button,
|
|
11010
|
+
{
|
|
11011
|
+
size: "small",
|
|
11012
|
+
type: "button",
|
|
11013
|
+
isLoading: isSubmitting,
|
|
11014
|
+
onClick: onSubmit,
|
|
11015
|
+
children: "Save"
|
|
11016
|
+
}
|
|
11017
|
+
)
|
|
11018
|
+
] }) })
|
|
11019
|
+
] });
|
|
11018
11020
|
};
|
|
11019
|
-
const
|
|
11020
|
-
|
|
11021
|
-
|
|
11021
|
+
const StackedModalTrigger$1 = ({
|
|
11022
|
+
shippingProfileId,
|
|
11023
|
+
shippingOption,
|
|
11024
|
+
shippingMethod,
|
|
11025
|
+
setData,
|
|
11026
|
+
children
|
|
11022
11027
|
}) => {
|
|
11028
|
+
const { setIsOpen, getIsOpen } = useStackedModal();
|
|
11029
|
+
const isOpen = getIsOpen(STACKED_FOCUS_MODAL_ID);
|
|
11030
|
+
const onToggle = () => {
|
|
11031
|
+
if (isOpen) {
|
|
11032
|
+
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
11033
|
+
setData(null);
|
|
11034
|
+
} else {
|
|
11035
|
+
setIsOpen(STACKED_FOCUS_MODAL_ID, true);
|
|
11036
|
+
setData({
|
|
11037
|
+
shippingProfileId,
|
|
11038
|
+
shippingOption,
|
|
11039
|
+
shippingMethod
|
|
11040
|
+
});
|
|
11041
|
+
}
|
|
11042
|
+
};
|
|
11023
11043
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11024
|
-
|
|
11044
|
+
ui.Button,
|
|
11025
11045
|
{
|
|
11026
|
-
|
|
11027
|
-
|
|
11028
|
-
|
|
11029
|
-
|
|
11030
|
-
|
|
11031
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Custom amount" }),
|
|
11032
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Set a custom amount for the shipping option." })
|
|
11033
|
-
] }),
|
|
11034
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11035
|
-
ui.CurrencyInput,
|
|
11036
|
-
{
|
|
11037
|
-
...field,
|
|
11038
|
-
onValueChange: (value) => onChange(value),
|
|
11039
|
-
symbol: getNativeSymbol(currencyCode),
|
|
11040
|
-
code: currencyCode
|
|
11041
|
-
}
|
|
11042
|
-
) })
|
|
11043
|
-
] });
|
|
11044
|
-
}
|
|
11046
|
+
size: "small",
|
|
11047
|
+
variant: "secondary",
|
|
11048
|
+
onClick: onToggle,
|
|
11049
|
+
className: "text-ui-fg-primary shrink-0",
|
|
11050
|
+
children
|
|
11045
11051
|
}
|
|
11046
11052
|
);
|
|
11047
11053
|
};
|
|
11048
|
-
const
|
|
11049
|
-
|
|
11050
|
-
|
|
11051
|
-
|
|
11052
|
-
|
|
11053
|
-
|
|
11054
|
-
|
|
11055
|
-
|
|
11056
|
-
|
|
11057
|
-
|
|
11058
|
-
|
|
11059
|
-
|
|
11060
|
-
|
|
11061
|
-
const { data, ...rest } = reactQuery.useQuery({
|
|
11062
|
-
queryKey: promotionsQueryKeys.list(query2),
|
|
11063
|
-
queryFn: async () => sdk.admin.promotion.list(query2),
|
|
11064
|
-
...options
|
|
11065
|
-
});
|
|
11066
|
-
return { ...data, ...rest };
|
|
11067
|
-
};
|
|
11068
|
-
const Promotions = () => {
|
|
11069
|
-
const { id } = reactRouterDom.useParams();
|
|
11070
|
-
const {
|
|
11071
|
-
order: preview,
|
|
11072
|
-
isError: isPreviewError,
|
|
11073
|
-
error: previewError
|
|
11074
|
-
} = useOrderPreview(id, void 0);
|
|
11075
|
-
useInitiateOrderEdit({ preview });
|
|
11076
|
-
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11077
|
-
if (isPreviewError) {
|
|
11078
|
-
throw previewError;
|
|
11079
|
-
}
|
|
11080
|
-
const isReady = !!preview;
|
|
11081
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { onClose: onCancel, children: [
|
|
11082
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Promotions" }) }) }),
|
|
11083
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(PromotionForm, { preview })
|
|
11084
|
-
] });
|
|
11085
|
-
};
|
|
11086
|
-
const PromotionForm = ({ preview }) => {
|
|
11087
|
-
const { items, shipping_methods } = preview;
|
|
11088
|
-
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
11089
|
-
const [comboboxValue, setComboboxValue] = React.useState("");
|
|
11090
|
-
const { handleSuccess } = useRouteModal();
|
|
11091
|
-
const { mutateAsync: addPromotions, isPending: isAddingPromotions } = useDraftOrderAddPromotions(preview.id);
|
|
11092
|
-
const promoCodes = getPromotionCodes(items, shipping_methods);
|
|
11093
|
-
const { promotions, isPending, isError, error } = usePromotions(
|
|
11094
|
-
{
|
|
11095
|
-
code: promoCodes
|
|
11096
|
-
},
|
|
11097
|
-
{
|
|
11098
|
-
enabled: !!promoCodes.length
|
|
11099
|
-
}
|
|
11100
|
-
);
|
|
11101
|
-
const comboboxData = useComboboxData({
|
|
11102
|
-
queryKey: ["promotions", "combobox", promoCodes],
|
|
11103
|
-
queryFn: async (params) => {
|
|
11104
|
-
return await sdk.admin.promotion.list({
|
|
11105
|
-
...params,
|
|
11106
|
-
code: {
|
|
11107
|
-
$nin: promoCodes
|
|
11108
|
-
}
|
|
11109
|
-
});
|
|
11110
|
-
},
|
|
11111
|
-
getOptions: (data) => {
|
|
11112
|
-
return data.promotions.map((promotion) => ({
|
|
11113
|
-
label: promotion.code,
|
|
11114
|
-
value: promotion.code
|
|
11115
|
-
}));
|
|
11054
|
+
const ShippingProfileForm = ({
|
|
11055
|
+
data,
|
|
11056
|
+
order,
|
|
11057
|
+
preview
|
|
11058
|
+
}) => {
|
|
11059
|
+
var _a, _b, _c, _d, _e, _f;
|
|
11060
|
+
const { setIsOpen } = useStackedModal();
|
|
11061
|
+
const form = reactHookForm.useForm({
|
|
11062
|
+
resolver: zod.zodResolver(shippingMethodSchema),
|
|
11063
|
+
defaultValues: {
|
|
11064
|
+
location_id: (_d = (_c = (_b = (_a = data.shippingOption) == null ? void 0 : _a.service_zone) == null ? void 0 : _b.fulfillment_set) == null ? void 0 : _c.location) == null ? void 0 : _d.id,
|
|
11065
|
+
shipping_option_id: (_e = data.shippingOption) == null ? void 0 : _e.id,
|
|
11066
|
+
custom_amount: (_f = data.shippingMethod) == null ? void 0 : _f.amount
|
|
11116
11067
|
}
|
|
11117
11068
|
});
|
|
11118
|
-
const
|
|
11119
|
-
|
|
11120
|
-
|
|
11121
|
-
|
|
11122
|
-
|
|
11123
|
-
|
|
11124
|
-
|
|
11125
|
-
|
|
11126
|
-
{
|
|
11127
|
-
onError: (e) => {
|
|
11128
|
-
ui.toast.error(e.message);
|
|
11129
|
-
comboboxData.onSearchValueChange("");
|
|
11130
|
-
setComboboxValue("");
|
|
11131
|
-
},
|
|
11132
|
-
onSuccess: () => {
|
|
11133
|
-
comboboxData.onSearchValueChange("");
|
|
11134
|
-
setComboboxValue("");
|
|
11135
|
-
}
|
|
11136
|
-
}
|
|
11137
|
-
);
|
|
11138
|
-
};
|
|
11139
|
-
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
11140
|
-
const { mutateAsync: requestOrderEdit } = useOrderEditRequest(preview.id);
|
|
11141
|
-
const onSubmit = async () => {
|
|
11142
|
-
setIsSubmitting(true);
|
|
11143
|
-
let requestSucceeded = false;
|
|
11144
|
-
await requestOrderEdit(void 0, {
|
|
11145
|
-
onError: (e) => {
|
|
11146
|
-
ui.toast.error(e.message);
|
|
11147
|
-
},
|
|
11148
|
-
onSuccess: () => {
|
|
11149
|
-
requestSucceeded = true;
|
|
11150
|
-
}
|
|
11151
|
-
});
|
|
11152
|
-
if (!requestSucceeded) {
|
|
11153
|
-
setIsSubmitting(false);
|
|
11069
|
+
const { mutateAsync: addShippingMethod, isPending } = useDraftOrderAddShippingMethod(order.id);
|
|
11070
|
+
const {
|
|
11071
|
+
mutateAsync: updateShippingMethod,
|
|
11072
|
+
isPending: isUpdatingShippingMethod
|
|
11073
|
+
} = useDraftOrderUpdateShippingMethod(order.id);
|
|
11074
|
+
const onSubmit = form.handleSubmit(async (values) => {
|
|
11075
|
+
if (lodash.isEqual(values, form.formState.defaultValues)) {
|
|
11076
|
+
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
11154
11077
|
return;
|
|
11155
11078
|
}
|
|
11156
|
-
|
|
11157
|
-
|
|
11158
|
-
ui.toast.error(e.message);
|
|
11159
|
-
},
|
|
11160
|
-
onSuccess: () => {
|
|
11161
|
-
handleSuccess();
|
|
11162
|
-
},
|
|
11163
|
-
onSettled: () => {
|
|
11164
|
-
setIsSubmitting(false);
|
|
11165
|
-
}
|
|
11166
|
-
});
|
|
11167
|
-
};
|
|
11168
|
-
if (isError) {
|
|
11169
|
-
throw error;
|
|
11170
|
-
}
|
|
11171
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", onSubmit, children: [
|
|
11172
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
11173
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
11174
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
11175
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "promotion-combobox", children: "Apply promotions" }),
|
|
11176
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { id: "promotion-combobox-hint", children: "Manage promotions that should be applied to the order." })
|
|
11177
|
-
] }),
|
|
11178
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11179
|
-
Combobox,
|
|
11180
|
-
{
|
|
11181
|
-
id: "promotion-combobox",
|
|
11182
|
-
"aria-describedby": "promotion-combobox-hint",
|
|
11183
|
-
isFetchingNextPage: comboboxData.isFetchingNextPage,
|
|
11184
|
-
fetchNextPage: comboboxData.fetchNextPage,
|
|
11185
|
-
options: comboboxData.options,
|
|
11186
|
-
onSearchValueChange: comboboxData.onSearchValueChange,
|
|
11187
|
-
searchValue: comboboxData.searchValue,
|
|
11188
|
-
disabled: comboboxData.disabled || isAddingPromotions,
|
|
11189
|
-
onChange: add,
|
|
11190
|
-
value: comboboxValue
|
|
11191
|
-
}
|
|
11192
|
-
)
|
|
11193
|
-
] }),
|
|
11194
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
11195
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-2", children: promotions == null ? void 0 : promotions.map((promotion) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
11196
|
-
PromotionItem,
|
|
11079
|
+
if (data.shippingMethod) {
|
|
11080
|
+
await updateShippingMethod(
|
|
11197
11081
|
{
|
|
11198
|
-
|
|
11199
|
-
|
|
11200
|
-
|
|
11082
|
+
method_id: data.shippingMethod.id,
|
|
11083
|
+
shipping_option_id: values.shipping_option_id,
|
|
11084
|
+
custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
|
|
11201
11085
|
},
|
|
11202
|
-
promotion.id
|
|
11203
|
-
)) })
|
|
11204
|
-
] }) }),
|
|
11205
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11206
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11207
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11208
|
-
ui.Button,
|
|
11209
11086
|
{
|
|
11210
|
-
|
|
11211
|
-
|
|
11212
|
-
|
|
11213
|
-
|
|
11087
|
+
onError: (e) => {
|
|
11088
|
+
ui.toast.error(e.message);
|
|
11089
|
+
},
|
|
11090
|
+
onSuccess: () => {
|
|
11091
|
+
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
11092
|
+
}
|
|
11214
11093
|
}
|
|
11215
|
-
)
|
|
11216
|
-
|
|
11217
|
-
|
|
11218
|
-
|
|
11219
|
-
const PromotionItem = ({
|
|
11220
|
-
promotion,
|
|
11221
|
-
orderId,
|
|
11222
|
-
isLoading
|
|
11223
|
-
}) => {
|
|
11224
|
-
var _a;
|
|
11225
|
-
const { mutateAsync: removePromotions, isPending } = useDraftOrderRemovePromotions(orderId);
|
|
11226
|
-
const onRemove = async () => {
|
|
11227
|
-
removePromotions(
|
|
11094
|
+
);
|
|
11095
|
+
return;
|
|
11096
|
+
}
|
|
11097
|
+
await addShippingMethod(
|
|
11228
11098
|
{
|
|
11229
|
-
|
|
11099
|
+
shipping_option_id: values.shipping_option_id,
|
|
11100
|
+
custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
|
|
11230
11101
|
},
|
|
11231
11102
|
{
|
|
11232
11103
|
onError: (e) => {
|
|
11233
11104
|
ui.toast.error(e.message);
|
|
11105
|
+
},
|
|
11106
|
+
onSuccess: () => {
|
|
11107
|
+
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
11234
11108
|
}
|
|
11235
11109
|
}
|
|
11236
11110
|
);
|
|
11237
|
-
};
|
|
11238
|
-
|
|
11239
|
-
|
|
11240
|
-
"div",
|
|
11111
|
+
});
|
|
11112
|
+
return /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2, { ...form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11113
|
+
KeyboundForm,
|
|
11241
11114
|
{
|
|
11242
|
-
className:
|
|
11243
|
-
|
|
11244
|
-
{
|
|
11245
|
-
"animate-pulse": isLoading
|
|
11246
|
-
}
|
|
11247
|
-
),
|
|
11115
|
+
className: "flex h-full flex-col overflow-hidden",
|
|
11116
|
+
onSubmit,
|
|
11248
11117
|
children: [
|
|
11249
|
-
/* @__PURE__ */ jsxRuntime.
|
|
11250
|
-
|
|
11251
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
11252
|
-
|
|
11253
|
-
|
|
11254
|
-
|
|
11255
|
-
|
|
11256
|
-
|
|
11257
|
-
|
|
11258
|
-
|
|
11259
|
-
|
|
11260
|
-
|
|
11261
|
-
|
|
11262
|
-
|
|
11263
|
-
|
|
11264
|
-
|
|
11265
|
-
|
|
11266
|
-
|
|
11267
|
-
|
|
11268
|
-
|
|
11269
|
-
|
|
11118
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Header, {}),
|
|
11119
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 py-16 px-6", children: [
|
|
11120
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11121
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
11122
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Add a shipping method for the selected shipping profile. You can see the items that will be shipped using this method in the preview below." }) })
|
|
11123
|
+
] }),
|
|
11124
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
11125
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11126
|
+
LocationField,
|
|
11127
|
+
{
|
|
11128
|
+
control: form.control,
|
|
11129
|
+
setValue: form.setValue
|
|
11130
|
+
}
|
|
11131
|
+
),
|
|
11132
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
11133
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11134
|
+
ShippingOptionField,
|
|
11135
|
+
{
|
|
11136
|
+
shippingProfileId: data.shippingProfileId,
|
|
11137
|
+
preview,
|
|
11138
|
+
control: form.control
|
|
11139
|
+
}
|
|
11140
|
+
),
|
|
11141
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
11142
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11143
|
+
CustomAmountField,
|
|
11144
|
+
{
|
|
11145
|
+
control: form.control,
|
|
11146
|
+
currencyCode: order.currency_code
|
|
11147
|
+
}
|
|
11148
|
+
),
|
|
11149
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
11150
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11151
|
+
ItemsPreview,
|
|
11152
|
+
{
|
|
11153
|
+
order,
|
|
11154
|
+
shippingProfileId: data.shippingProfileId
|
|
11155
|
+
}
|
|
11156
|
+
)
|
|
11157
|
+
] }) }) }),
|
|
11158
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-x-2", children: [
|
|
11159
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
11160
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11161
|
+
ui.Button,
|
|
11162
|
+
{
|
|
11163
|
+
size: "small",
|
|
11164
|
+
type: "submit",
|
|
11165
|
+
isLoading: isPending || isUpdatingShippingMethod,
|
|
11166
|
+
children: data.shippingMethod ? "Update" : "Add"
|
|
11167
|
+
}
|
|
11168
|
+
)
|
|
11169
|
+
] }) })
|
|
11270
11170
|
]
|
|
11271
|
-
},
|
|
11272
|
-
promotion.id
|
|
11273
|
-
);
|
|
11274
|
-
};
|
|
11275
|
-
function getDisplayValue(promotion) {
|
|
11276
|
-
var _a, _b, _c, _d;
|
|
11277
|
-
const value = (_a = promotion.application_method) == null ? void 0 : _a.value;
|
|
11278
|
-
if (!value) {
|
|
11279
|
-
return null;
|
|
11280
|
-
}
|
|
11281
|
-
if (((_b = promotion.application_method) == null ? void 0 : _b.type) === "fixed") {
|
|
11282
|
-
const currency = (_c = promotion.application_method) == null ? void 0 : _c.currency_code;
|
|
11283
|
-
if (!currency) {
|
|
11284
|
-
return null;
|
|
11285
11171
|
}
|
|
11286
|
-
|
|
11287
|
-
} else if (((_d = promotion.application_method) == null ? void 0 : _d.type) === "percentage") {
|
|
11288
|
-
return formatPercentage(value);
|
|
11289
|
-
}
|
|
11290
|
-
return null;
|
|
11291
|
-
}
|
|
11292
|
-
const formatter = new Intl.NumberFormat([], {
|
|
11293
|
-
style: "percent",
|
|
11294
|
-
minimumFractionDigits: 2
|
|
11295
|
-
});
|
|
11296
|
-
const formatPercentage = (value, isPercentageValue = false) => {
|
|
11297
|
-
let val = value || 0;
|
|
11298
|
-
if (!isPercentageValue) {
|
|
11299
|
-
val = val / 100;
|
|
11300
|
-
}
|
|
11301
|
-
return formatter.format(val);
|
|
11172
|
+
) }) });
|
|
11302
11173
|
};
|
|
11303
|
-
|
|
11304
|
-
|
|
11305
|
-
|
|
11306
|
-
|
|
11307
|
-
|
|
11308
|
-
|
|
11309
|
-
|
|
11310
|
-
|
|
11311
|
-
|
|
11312
|
-
|
|
11313
|
-
}
|
|
11314
|
-
for (const shippingMethod of shippingMethods) {
|
|
11315
|
-
if (shippingMethod.adjustments) {
|
|
11316
|
-
for (const adjustment of shippingMethod.adjustments) {
|
|
11317
|
-
if (adjustment.code) {
|
|
11318
|
-
codes.add(adjustment.code);
|
|
11319
|
-
}
|
|
11320
|
-
}
|
|
11321
|
-
}
|
|
11322
|
-
}
|
|
11323
|
-
return Array.from(codes);
|
|
11324
|
-
}
|
|
11325
|
-
const SalesChannel = () => {
|
|
11326
|
-
const { id } = reactRouterDom.useParams();
|
|
11327
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11328
|
-
id,
|
|
11329
|
-
{
|
|
11330
|
-
fields: "+sales_channel_id"
|
|
11331
|
-
},
|
|
11332
|
-
{
|
|
11333
|
-
enabled: !!id
|
|
11174
|
+
const shippingMethodSchema = objectType({
|
|
11175
|
+
location_id: stringType(),
|
|
11176
|
+
shipping_option_id: stringType(),
|
|
11177
|
+
custom_amount: unionType([numberType(), stringType()]).optional()
|
|
11178
|
+
});
|
|
11179
|
+
const ItemsPreview = ({ order, shippingProfileId }) => {
|
|
11180
|
+
const matches = order.items.filter(
|
|
11181
|
+
(item) => {
|
|
11182
|
+
var _a, _b, _c;
|
|
11183
|
+
return ((_c = (_b = (_a = item.variant) == null ? void 0 : _a.product) == null ? void 0 : _b.shipping_profile) == null ? void 0 : _c.id) === shippingProfileId;
|
|
11334
11184
|
}
|
|
11335
11185
|
);
|
|
11336
|
-
|
|
11337
|
-
|
|
11338
|
-
|
|
11339
|
-
|
|
11340
|
-
|
|
11341
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
11342
|
-
/* @__PURE__ */ jsxRuntime.
|
|
11343
|
-
|
|
11344
|
-
|
|
11345
|
-
|
|
11186
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-6", children: [
|
|
11187
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-2 items-center gap-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
11188
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: "Items to ship" }),
|
|
11189
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Items with the selected shipping profile." })
|
|
11190
|
+
] }) }),
|
|
11191
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
|
|
11192
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-3 px-4 py-2 text-ui-fg-muted", children: [
|
|
11193
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Item" }) }),
|
|
11194
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Quantity" }) })
|
|
11195
|
+
] }),
|
|
11196
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-y-1.5 px-[5px] pb-[5px]", children: matches.length > 0 ? matches == null ? void 0 : matches.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11197
|
+
"div",
|
|
11198
|
+
{
|
|
11199
|
+
className: "grid grid-cols-2 gap-3 px-4 py-2 bg-ui-bg-base shadow-elevation-card-rest rounded-lg items-center",
|
|
11200
|
+
children: [
|
|
11201
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3", children: [
|
|
11202
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11203
|
+
Thumbnail,
|
|
11204
|
+
{
|
|
11205
|
+
thumbnail: item.thumbnail,
|
|
11206
|
+
alt: item.product_title ?? void 0
|
|
11207
|
+
}
|
|
11208
|
+
),
|
|
11209
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
11210
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-1", children: [
|
|
11211
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: item.product_title }),
|
|
11212
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
11213
|
+
ui.Text,
|
|
11214
|
+
{
|
|
11215
|
+
size: "small",
|
|
11216
|
+
leading: "compact",
|
|
11217
|
+
className: "text-ui-fg-subtle",
|
|
11218
|
+
children: [
|
|
11219
|
+
"(",
|
|
11220
|
+
item.variant_title,
|
|
11221
|
+
")"
|
|
11222
|
+
]
|
|
11223
|
+
}
|
|
11224
|
+
)
|
|
11225
|
+
] }),
|
|
11226
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11227
|
+
ui.Text,
|
|
11228
|
+
{
|
|
11229
|
+
size: "small",
|
|
11230
|
+
leading: "compact",
|
|
11231
|
+
className: "text-ui-fg-subtle",
|
|
11232
|
+
children: item.variant_sku
|
|
11233
|
+
}
|
|
11234
|
+
)
|
|
11235
|
+
] })
|
|
11236
|
+
] }),
|
|
11237
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
11238
|
+
ui.Text,
|
|
11239
|
+
{
|
|
11240
|
+
size: "small",
|
|
11241
|
+
leading: "compact",
|
|
11242
|
+
className: "text-ui-fg-subtle",
|
|
11243
|
+
children: [
|
|
11244
|
+
item.quantity,
|
|
11245
|
+
"x"
|
|
11246
|
+
]
|
|
11247
|
+
}
|
|
11248
|
+
)
|
|
11249
|
+
]
|
|
11250
|
+
},
|
|
11251
|
+
item.id
|
|
11252
|
+
)) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center gap-x-3 bg-ui-bg-base rounded-lg p-4 shadow-elevation-card-rest flex-col gap-1", children: [
|
|
11253
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: "No items found" }),
|
|
11254
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
11255
|
+
'No items found for "',
|
|
11256
|
+
query,
|
|
11257
|
+
'".'
|
|
11258
|
+
] })
|
|
11259
|
+
] }) })
|
|
11260
|
+
] })
|
|
11346
11261
|
] });
|
|
11347
11262
|
};
|
|
11348
|
-
const
|
|
11349
|
-
const
|
|
11350
|
-
|
|
11351
|
-
|
|
11263
|
+
const LocationField = ({ control, setValue }) => {
|
|
11264
|
+
const locations = useComboboxData({
|
|
11265
|
+
queryKey: ["locations"],
|
|
11266
|
+
queryFn: async (params) => {
|
|
11267
|
+
return await sdk.admin.stockLocation.list(params);
|
|
11352
11268
|
},
|
|
11353
|
-
|
|
11354
|
-
|
|
11355
|
-
|
|
11356
|
-
|
|
11357
|
-
|
|
11358
|
-
|
|
11359
|
-
{
|
|
11360
|
-
sales_channel_id: data.sales_channel_id
|
|
11361
|
-
},
|
|
11362
|
-
{
|
|
11363
|
-
onSuccess: () => {
|
|
11364
|
-
ui.toast.success("Sales channel updated");
|
|
11365
|
-
handleSuccess();
|
|
11366
|
-
},
|
|
11367
|
-
onError: (error) => {
|
|
11368
|
-
ui.toast.error(error.message);
|
|
11369
|
-
}
|
|
11370
|
-
}
|
|
11371
|
-
);
|
|
11269
|
+
getOptions: (data) => {
|
|
11270
|
+
return data.stock_locations.map((location) => ({
|
|
11271
|
+
label: location.name,
|
|
11272
|
+
value: location.id
|
|
11273
|
+
}));
|
|
11274
|
+
}
|
|
11372
11275
|
});
|
|
11373
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11374
|
-
|
|
11276
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11277
|
+
Form$2.Field,
|
|
11375
11278
|
{
|
|
11376
|
-
|
|
11377
|
-
|
|
11378
|
-
|
|
11379
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11380
|
-
|
|
11381
|
-
|
|
11382
|
-
|
|
11383
|
-
|
|
11384
|
-
|
|
11279
|
+
control,
|
|
11280
|
+
name: "location_id",
|
|
11281
|
+
render: ({ field: { onChange, ...field } }) => {
|
|
11282
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
11283
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11284
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Location" }),
|
|
11285
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Choose where you want to ship the items from." })
|
|
11286
|
+
] }),
|
|
11287
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11288
|
+
Combobox,
|
|
11289
|
+
{
|
|
11290
|
+
options: locations.options,
|
|
11291
|
+
fetchNextPage: locations.fetchNextPage,
|
|
11292
|
+
isFetchingNextPage: locations.isFetchingNextPage,
|
|
11293
|
+
searchValue: locations.searchValue,
|
|
11294
|
+
onSearchValueChange: locations.onSearchValueChange,
|
|
11295
|
+
placeholder: "Select location",
|
|
11296
|
+
onChange: (value) => {
|
|
11297
|
+
setValue("shipping_option_id", "", {
|
|
11298
|
+
shouldDirty: true,
|
|
11299
|
+
shouldTouch: true
|
|
11300
|
+
});
|
|
11301
|
+
onChange(value);
|
|
11302
|
+
},
|
|
11303
|
+
...field
|
|
11304
|
+
}
|
|
11305
|
+
) })
|
|
11306
|
+
] }) });
|
|
11307
|
+
}
|
|
11385
11308
|
}
|
|
11386
|
-
)
|
|
11309
|
+
);
|
|
11387
11310
|
};
|
|
11388
|
-
const
|
|
11389
|
-
|
|
11311
|
+
const ShippingOptionField = ({
|
|
11312
|
+
shippingProfileId,
|
|
11313
|
+
preview,
|
|
11314
|
+
control
|
|
11315
|
+
}) => {
|
|
11316
|
+
var _a;
|
|
11317
|
+
const locationId = reactHookForm.useWatch({ control, name: "location_id" });
|
|
11318
|
+
const shippingOptions = useComboboxData({
|
|
11319
|
+
queryKey: ["shipping_options", locationId, shippingProfileId],
|
|
11390
11320
|
queryFn: async (params) => {
|
|
11391
|
-
return await sdk.admin.
|
|
11321
|
+
return await sdk.admin.shippingOption.list({
|
|
11322
|
+
...params,
|
|
11323
|
+
stock_location_id: locationId,
|
|
11324
|
+
shipping_profile_id: shippingProfileId
|
|
11325
|
+
});
|
|
11392
11326
|
},
|
|
11393
|
-
queryKey: ["sales-channels"],
|
|
11394
11327
|
getOptions: (data) => {
|
|
11395
|
-
return data.
|
|
11396
|
-
|
|
11397
|
-
|
|
11398
|
-
|
|
11328
|
+
return data.shipping_options.map((option) => {
|
|
11329
|
+
var _a2;
|
|
11330
|
+
if ((_a2 = option.rules) == null ? void 0 : _a2.find(
|
|
11331
|
+
(r) => r.attribute === "is_return" && r.value === "true"
|
|
11332
|
+
)) {
|
|
11333
|
+
return void 0;
|
|
11334
|
+
}
|
|
11335
|
+
return {
|
|
11336
|
+
label: option.name,
|
|
11337
|
+
value: option.id
|
|
11338
|
+
};
|
|
11339
|
+
}).filter(Boolean);
|
|
11399
11340
|
},
|
|
11400
|
-
|
|
11341
|
+
enabled: !!locationId && !!shippingProfileId,
|
|
11342
|
+
defaultValue: ((_a = preview.shipping_methods[0]) == null ? void 0 : _a.shipping_option_id) || void 0
|
|
11401
11343
|
});
|
|
11344
|
+
const tooltipContent = !locationId && !shippingProfileId ? "Choose a location and shipping profile first." : !locationId ? "Choose a location first." : "Choose a shipping profile first.";
|
|
11402
11345
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11403
11346
|
Form$2.Field,
|
|
11404
11347
|
{
|
|
11405
11348
|
control,
|
|
11406
|
-
name: "
|
|
11349
|
+
name: "shipping_option_id",
|
|
11407
11350
|
render: ({ field }) => {
|
|
11408
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
11409
|
-
/* @__PURE__ */ jsxRuntime.
|
|
11351
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
11352
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
11353
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Shipping option" }),
|
|
11354
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Choose the shipping option to use." })
|
|
11355
|
+
] }),
|
|
11356
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11357
|
+
ConditionalTooltip,
|
|
11358
|
+
{
|
|
11359
|
+
content: tooltipContent,
|
|
11360
|
+
showTooltip: !locationId || !shippingProfileId,
|
|
11361
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11362
|
+
Combobox,
|
|
11363
|
+
{
|
|
11364
|
+
options: shippingOptions.options,
|
|
11365
|
+
fetchNextPage: shippingOptions.fetchNextPage,
|
|
11366
|
+
isFetchingNextPage: shippingOptions.isFetchingNextPage,
|
|
11367
|
+
searchValue: shippingOptions.searchValue,
|
|
11368
|
+
onSearchValueChange: shippingOptions.onSearchValueChange,
|
|
11369
|
+
placeholder: "Select shipping option",
|
|
11370
|
+
...field,
|
|
11371
|
+
disabled: !locationId || !shippingProfileId
|
|
11372
|
+
}
|
|
11373
|
+
) }) })
|
|
11374
|
+
}
|
|
11375
|
+
)
|
|
11376
|
+
] }) });
|
|
11377
|
+
}
|
|
11378
|
+
}
|
|
11379
|
+
);
|
|
11380
|
+
};
|
|
11381
|
+
const CustomAmountField = ({
|
|
11382
|
+
control,
|
|
11383
|
+
currencyCode
|
|
11384
|
+
}) => {
|
|
11385
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11386
|
+
Form$2.Field,
|
|
11387
|
+
{
|
|
11388
|
+
control,
|
|
11389
|
+
name: "custom_amount",
|
|
11390
|
+
render: ({ field: { onChange, ...field } }) => {
|
|
11391
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
11392
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
11393
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Custom amount" }),
|
|
11394
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Set a custom amount for the shipping option." })
|
|
11395
|
+
] }),
|
|
11410
11396
|
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11411
|
-
|
|
11397
|
+
ui.CurrencyInput,
|
|
11412
11398
|
{
|
|
11413
|
-
|
|
11414
|
-
|
|
11415
|
-
|
|
11416
|
-
|
|
11417
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11418
|
-
placeholder: "Select sales channel",
|
|
11419
|
-
...field
|
|
11399
|
+
...field,
|
|
11400
|
+
onValueChange: (value) => onChange(value),
|
|
11401
|
+
symbol: getNativeSymbol(currencyCode),
|
|
11402
|
+
code: currencyCode
|
|
11420
11403
|
}
|
|
11421
|
-
) })
|
|
11422
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11404
|
+
) })
|
|
11423
11405
|
] });
|
|
11424
11406
|
}
|
|
11425
11407
|
}
|
|
11426
11408
|
);
|
|
11427
11409
|
};
|
|
11428
|
-
const schema$2 = objectType({
|
|
11429
|
-
sales_channel_id: stringType().min(1)
|
|
11430
|
-
});
|
|
11431
11410
|
const ShippingAddress = () => {
|
|
11432
11411
|
const { id } = reactRouterDom.useParams();
|
|
11433
11412
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -11460,7 +11439,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
11460
11439
|
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
11461
11440
|
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
11462
11441
|
},
|
|
11463
|
-
resolver: zod.zodResolver(schema$
|
|
11442
|
+
resolver: zod.zodResolver(schema$2)
|
|
11464
11443
|
});
|
|
11465
11444
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11466
11445
|
const { handleSuccess } = useRouteModal();
|
|
@@ -11630,7 +11609,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
11630
11609
|
}
|
|
11631
11610
|
) });
|
|
11632
11611
|
};
|
|
11633
|
-
const schema$
|
|
11612
|
+
const schema$2 = addressSchema;
|
|
11634
11613
|
const TransferOwnership = () => {
|
|
11635
11614
|
const { id } = reactRouterDom.useParams();
|
|
11636
11615
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -11654,7 +11633,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
11654
11633
|
defaultValues: {
|
|
11655
11634
|
customer_id: order.customer_id || ""
|
|
11656
11635
|
},
|
|
11657
|
-
resolver: zod.zodResolver(schema)
|
|
11636
|
+
resolver: zod.zodResolver(schema$1)
|
|
11658
11637
|
});
|
|
11659
11638
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11660
11639
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12104,7 +12083,7 @@ const Illustration = () => {
|
|
|
12104
12083
|
}
|
|
12105
12084
|
);
|
|
12106
12085
|
};
|
|
12107
|
-
const schema = objectType({
|
|
12086
|
+
const schema$1 = objectType({
|
|
12108
12087
|
customer_id: stringType().min(1)
|
|
12109
12088
|
});
|
|
12110
12089
|
const NumberInput = React.forwardRef(
|
|
@@ -13032,6 +13011,27 @@ const customItemSchema = objectType({
|
|
|
13032
13011
|
quantity: numberType(),
|
|
13033
13012
|
unit_price: unionType([numberType(), stringType()])
|
|
13034
13013
|
});
|
|
13014
|
+
const CustomItems = () => {
|
|
13015
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
13016
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
13017
|
+
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
13018
|
+
] });
|
|
13019
|
+
};
|
|
13020
|
+
const CustomItemsForm = () => {
|
|
13021
|
+
const form = reactHookForm.useForm({
|
|
13022
|
+
resolver: zod.zodResolver(schema)
|
|
13023
|
+
});
|
|
13024
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
13025
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
13026
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13027
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
13028
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
13029
|
+
] }) })
|
|
13030
|
+
] }) });
|
|
13031
|
+
};
|
|
13032
|
+
const schema = objectType({
|
|
13033
|
+
email: stringType().email()
|
|
13034
|
+
});
|
|
13035
13035
|
const widgetModule = { widgets: [] };
|
|
13036
13036
|
const routeModule = {
|
|
13037
13037
|
routes: [
|
|
@@ -13052,10 +13052,6 @@ const routeModule = {
|
|
|
13052
13052
|
handle,
|
|
13053
13053
|
loader,
|
|
13054
13054
|
children: [
|
|
13055
|
-
{
|
|
13056
|
-
Component: CustomItems,
|
|
13057
|
-
path: "/draft-orders/:id/custom-items"
|
|
13058
|
-
},
|
|
13059
13055
|
{
|
|
13060
13056
|
Component: BillingAddress,
|
|
13061
13057
|
path: "/draft-orders/:id/billing-address"
|
|
@@ -13068,10 +13064,6 @@ const routeModule = {
|
|
|
13068
13064
|
Component: Metadata,
|
|
13069
13065
|
path: "/draft-orders/:id/metadata"
|
|
13070
13066
|
},
|
|
13071
|
-
{
|
|
13072
|
-
Component: Shipping,
|
|
13073
|
-
path: "/draft-orders/:id/shipping"
|
|
13074
|
-
},
|
|
13075
13067
|
{
|
|
13076
13068
|
Component: Promotions,
|
|
13077
13069
|
path: "/draft-orders/:id/promotions"
|
|
@@ -13080,6 +13072,10 @@ const routeModule = {
|
|
|
13080
13072
|
Component: SalesChannel,
|
|
13081
13073
|
path: "/draft-orders/:id/sales-channel"
|
|
13082
13074
|
},
|
|
13075
|
+
{
|
|
13076
|
+
Component: Shipping,
|
|
13077
|
+
path: "/draft-orders/:id/shipping"
|
|
13078
|
+
},
|
|
13083
13079
|
{
|
|
13084
13080
|
Component: ShippingAddress,
|
|
13085
13081
|
path: "/draft-orders/:id/shipping-address"
|
|
@@ -13091,6 +13087,10 @@ const routeModule = {
|
|
|
13091
13087
|
{
|
|
13092
13088
|
Component: Items,
|
|
13093
13089
|
path: "/draft-orders/:id/items"
|
|
13090
|
+
},
|
|
13091
|
+
{
|
|
13092
|
+
Component: CustomItems,
|
|
13093
|
+
path: "/draft-orders/:id/custom-items"
|
|
13094
13094
|
}
|
|
13095
13095
|
]
|
|
13096
13096
|
}
|