@medusajs/draft-order 2.11.2-preview-20251027000324 → 2.11.2-preview-20251027032612
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 +374 -374
- package/.medusa/server/src/admin/index.mjs +374 -374
- package/package.json +16 -16
|
@@ -9571,10 +9571,31 @@ const ID = () => {
|
|
|
9571
9571
|
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
9572
9572
|
] });
|
|
9573
9573
|
};
|
|
9574
|
-
const
|
|
9574
|
+
const CustomItems = () => {
|
|
9575
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9576
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
9577
|
+
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
9578
|
+
] });
|
|
9579
|
+
};
|
|
9580
|
+
const CustomItemsForm = () => {
|
|
9581
|
+
const form = reactHookForm.useForm({
|
|
9582
|
+
resolver: zod.zodResolver(schema$5)
|
|
9583
|
+
});
|
|
9584
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9585
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
9586
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9587
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9588
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
9589
|
+
] }) })
|
|
9590
|
+
] }) });
|
|
9591
|
+
};
|
|
9592
|
+
const schema$5 = objectType({
|
|
9593
|
+
email: stringType().email()
|
|
9594
|
+
});
|
|
9595
|
+
const Email = () => {
|
|
9575
9596
|
const { id } = reactRouterDom.useParams();
|
|
9576
9597
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
9577
|
-
fields: "+
|
|
9598
|
+
fields: "+email"
|
|
9578
9599
|
});
|
|
9579
9600
|
if (isError) {
|
|
9580
9601
|
throw error;
|
|
@@ -9582,34 +9603,24 @@ const BillingAddress = () => {
|
|
|
9582
9603
|
const isReady = !isPending && !!order;
|
|
9583
9604
|
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9584
9605
|
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
9585
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit
|
|
9586
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the
|
|
9606
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
|
|
9607
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
9587
9608
|
] }),
|
|
9588
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(
|
|
9609
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
|
|
9589
9610
|
] });
|
|
9590
9611
|
};
|
|
9591
|
-
const
|
|
9592
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
9612
|
+
const EmailForm = ({ order }) => {
|
|
9593
9613
|
const form = reactHookForm.useForm({
|
|
9594
9614
|
defaultValues: {
|
|
9595
|
-
|
|
9596
|
-
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
9597
|
-
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
9598
|
-
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
9599
|
-
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
9600
|
-
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
9601
|
-
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
9602
|
-
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
9603
|
-
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9604
|
-
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9615
|
+
email: order.email ?? ""
|
|
9605
9616
|
},
|
|
9606
|
-
resolver: zod.zodResolver(schema$
|
|
9617
|
+
resolver: zod.zodResolver(schema$4)
|
|
9607
9618
|
});
|
|
9608
9619
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9609
9620
|
const { handleSuccess } = useRouteModal();
|
|
9610
9621
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
9611
9622
|
await mutateAsync(
|
|
9612
|
-
{
|
|
9623
|
+
{ email: data.email },
|
|
9613
9624
|
{
|
|
9614
9625
|
onSuccess: () => {
|
|
9615
9626
|
handleSuccess();
|
|
@@ -9626,132 +9637,18 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9626
9637
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
9627
9638
|
onSubmit,
|
|
9628
9639
|
children: [
|
|
9629
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.
|
|
9630
|
-
|
|
9631
|
-
|
|
9632
|
-
|
|
9633
|
-
|
|
9634
|
-
|
|
9635
|
-
|
|
9636
|
-
|
|
9637
|
-
|
|
9638
|
-
|
|
9639
|
-
|
|
9640
|
-
|
|
9641
|
-
),
|
|
9642
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9643
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9644
|
-
Form$2.Field,
|
|
9645
|
-
{
|
|
9646
|
-
control: form.control,
|
|
9647
|
-
name: "first_name",
|
|
9648
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9649
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
9650
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9651
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9652
|
-
] })
|
|
9653
|
-
}
|
|
9654
|
-
),
|
|
9655
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9656
|
-
Form$2.Field,
|
|
9657
|
-
{
|
|
9658
|
-
control: form.control,
|
|
9659
|
-
name: "last_name",
|
|
9660
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9661
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
9662
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9663
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9664
|
-
] })
|
|
9665
|
-
}
|
|
9666
|
-
)
|
|
9667
|
-
] }),
|
|
9668
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9669
|
-
Form$2.Field,
|
|
9670
|
-
{
|
|
9671
|
-
control: form.control,
|
|
9672
|
-
name: "company",
|
|
9673
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9674
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
9675
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9676
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9677
|
-
] })
|
|
9678
|
-
}
|
|
9679
|
-
),
|
|
9680
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9681
|
-
Form$2.Field,
|
|
9682
|
-
{
|
|
9683
|
-
control: form.control,
|
|
9684
|
-
name: "address_1",
|
|
9685
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9686
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
9687
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9688
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9689
|
-
] })
|
|
9690
|
-
}
|
|
9691
|
-
),
|
|
9692
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9693
|
-
Form$2.Field,
|
|
9694
|
-
{
|
|
9695
|
-
control: form.control,
|
|
9696
|
-
name: "address_2",
|
|
9697
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9698
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
9699
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9700
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9701
|
-
] })
|
|
9702
|
-
}
|
|
9703
|
-
),
|
|
9704
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9705
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9706
|
-
Form$2.Field,
|
|
9707
|
-
{
|
|
9708
|
-
control: form.control,
|
|
9709
|
-
name: "postal_code",
|
|
9710
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9711
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
9712
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9713
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9714
|
-
] })
|
|
9715
|
-
}
|
|
9716
|
-
),
|
|
9717
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9718
|
-
Form$2.Field,
|
|
9719
|
-
{
|
|
9720
|
-
control: form.control,
|
|
9721
|
-
name: "city",
|
|
9722
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9723
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
9724
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9725
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9726
|
-
] })
|
|
9727
|
-
}
|
|
9728
|
-
)
|
|
9729
|
-
] }),
|
|
9730
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9731
|
-
Form$2.Field,
|
|
9732
|
-
{
|
|
9733
|
-
control: form.control,
|
|
9734
|
-
name: "province",
|
|
9735
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9736
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
9737
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9738
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9739
|
-
] })
|
|
9740
|
-
}
|
|
9741
|
-
),
|
|
9742
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9743
|
-
Form$2.Field,
|
|
9744
|
-
{
|
|
9745
|
-
control: form.control,
|
|
9746
|
-
name: "phone",
|
|
9747
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9748
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
9749
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9750
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9751
|
-
] })
|
|
9752
|
-
}
|
|
9753
|
-
)
|
|
9754
|
-
] }) }),
|
|
9640
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9641
|
+
Form$2.Field,
|
|
9642
|
+
{
|
|
9643
|
+
control: form.control,
|
|
9644
|
+
name: "email",
|
|
9645
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9646
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
|
|
9647
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9648
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9649
|
+
] })
|
|
9650
|
+
}
|
|
9651
|
+
) }),
|
|
9755
9652
|
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9756
9653
|
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9757
9654
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
@@ -9760,7 +9657,9 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9760
9657
|
}
|
|
9761
9658
|
) });
|
|
9762
9659
|
};
|
|
9763
|
-
const schema$
|
|
9660
|
+
const schema$4 = objectType({
|
|
9661
|
+
email: stringType().email()
|
|
9662
|
+
});
|
|
9764
9663
|
const NumberInput = React.forwardRef(
|
|
9765
9664
|
({
|
|
9766
9665
|
value,
|
|
@@ -11362,74 +11261,180 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11362
11261
|
}
|
|
11363
11262
|
return Array.from(promotionIds);
|
|
11364
11263
|
}
|
|
11365
|
-
const
|
|
11366
|
-
const Shipping = () => {
|
|
11367
|
-
var _a;
|
|
11264
|
+
const SalesChannel = () => {
|
|
11368
11265
|
const { id } = reactRouterDom.useParams();
|
|
11369
|
-
const {
|
|
11370
|
-
|
|
11371
|
-
});
|
|
11372
|
-
const {
|
|
11373
|
-
order: preview,
|
|
11374
|
-
isPending: isPreviewPending,
|
|
11375
|
-
isError: isPreviewError,
|
|
11376
|
-
error: previewError
|
|
11377
|
-
} = useOrderPreview(id);
|
|
11378
|
-
useInitiateOrderEdit({ preview });
|
|
11379
|
-
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11380
|
-
if (isError) {
|
|
11381
|
-
throw error;
|
|
11382
|
-
}
|
|
11383
|
-
if (isPreviewError) {
|
|
11384
|
-
throw previewError;
|
|
11385
|
-
}
|
|
11386
|
-
const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
|
|
11387
|
-
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
11388
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
11389
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
11390
|
-
/* @__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: [
|
|
11391
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
11392
|
-
/* @__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." }) })
|
|
11393
|
-
] }) }) }),
|
|
11394
|
-
/* @__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" }) }) })
|
|
11395
|
-
] }) : isReady ? /* @__PURE__ */ jsxRuntime.jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11396
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
11397
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
11398
|
-
] }) });
|
|
11399
|
-
};
|
|
11400
|
-
const ShippingForm = ({ preview, order }) => {
|
|
11401
|
-
var _a;
|
|
11402
|
-
const { setIsOpen } = useStackedModal();
|
|
11403
|
-
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
11404
|
-
const [data, setData] = React.useState(null);
|
|
11405
|
-
const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
|
|
11406
|
-
const { shipping_options } = useShippingOptions(
|
|
11266
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11267
|
+
id,
|
|
11407
11268
|
{
|
|
11408
|
-
|
|
11409
|
-
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
11269
|
+
fields: "+sales_channel_id"
|
|
11410
11270
|
},
|
|
11411
11271
|
{
|
|
11412
|
-
enabled:
|
|
11272
|
+
enabled: !!id
|
|
11413
11273
|
}
|
|
11414
11274
|
);
|
|
11415
|
-
|
|
11416
|
-
|
|
11417
|
-
|
|
11418
|
-
|
|
11419
|
-
|
|
11420
|
-
|
|
11421
|
-
|
|
11422
|
-
|
|
11423
|
-
|
|
11424
|
-
|
|
11425
|
-
|
|
11426
|
-
|
|
11427
|
-
|
|
11428
|
-
const
|
|
11429
|
-
|
|
11430
|
-
|
|
11431
|
-
|
|
11432
|
-
|
|
11275
|
+
if (isError) {
|
|
11276
|
+
throw error;
|
|
11277
|
+
}
|
|
11278
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
11279
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11280
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
11281
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
11282
|
+
/* @__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" }) })
|
|
11283
|
+
] }),
|
|
11284
|
+
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
11285
|
+
] });
|
|
11286
|
+
};
|
|
11287
|
+
const SalesChannelForm = ({ order }) => {
|
|
11288
|
+
const form = reactHookForm.useForm({
|
|
11289
|
+
defaultValues: {
|
|
11290
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
11291
|
+
},
|
|
11292
|
+
resolver: zod.zodResolver(schema$3)
|
|
11293
|
+
});
|
|
11294
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11295
|
+
const { handleSuccess } = useRouteModal();
|
|
11296
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11297
|
+
await mutateAsync(
|
|
11298
|
+
{
|
|
11299
|
+
sales_channel_id: data.sales_channel_id
|
|
11300
|
+
},
|
|
11301
|
+
{
|
|
11302
|
+
onSuccess: () => {
|
|
11303
|
+
ui.toast.success("Sales channel updated");
|
|
11304
|
+
handleSuccess();
|
|
11305
|
+
},
|
|
11306
|
+
onError: (error) => {
|
|
11307
|
+
ui.toast.error(error.message);
|
|
11308
|
+
}
|
|
11309
|
+
}
|
|
11310
|
+
);
|
|
11311
|
+
});
|
|
11312
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11313
|
+
KeyboundForm,
|
|
11314
|
+
{
|
|
11315
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11316
|
+
onSubmit,
|
|
11317
|
+
children: [
|
|
11318
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11319
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11320
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11321
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11322
|
+
] }) })
|
|
11323
|
+
]
|
|
11324
|
+
}
|
|
11325
|
+
) });
|
|
11326
|
+
};
|
|
11327
|
+
const SalesChannelField = ({ control, order }) => {
|
|
11328
|
+
const salesChannels = useComboboxData({
|
|
11329
|
+
queryFn: async (params) => {
|
|
11330
|
+
return await sdk.admin.salesChannel.list(params);
|
|
11331
|
+
},
|
|
11332
|
+
queryKey: ["sales-channels"],
|
|
11333
|
+
getOptions: (data) => {
|
|
11334
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
11335
|
+
label: salesChannel.name,
|
|
11336
|
+
value: salesChannel.id
|
|
11337
|
+
}));
|
|
11338
|
+
},
|
|
11339
|
+
defaultValue: order.sales_channel_id || void 0
|
|
11340
|
+
});
|
|
11341
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11342
|
+
Form$2.Field,
|
|
11343
|
+
{
|
|
11344
|
+
control,
|
|
11345
|
+
name: "sales_channel_id",
|
|
11346
|
+
render: ({ field }) => {
|
|
11347
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11348
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11349
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11350
|
+
Combobox,
|
|
11351
|
+
{
|
|
11352
|
+
options: salesChannels.options,
|
|
11353
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
11354
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11355
|
+
searchValue: salesChannels.searchValue,
|
|
11356
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11357
|
+
placeholder: "Select sales channel",
|
|
11358
|
+
...field
|
|
11359
|
+
}
|
|
11360
|
+
) }),
|
|
11361
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11362
|
+
] });
|
|
11363
|
+
}
|
|
11364
|
+
}
|
|
11365
|
+
);
|
|
11366
|
+
};
|
|
11367
|
+
const schema$3 = objectType({
|
|
11368
|
+
sales_channel_id: stringType().min(1)
|
|
11369
|
+
});
|
|
11370
|
+
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11371
|
+
const Shipping = () => {
|
|
11372
|
+
var _a;
|
|
11373
|
+
const { id } = reactRouterDom.useParams();
|
|
11374
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
11375
|
+
fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
|
|
11376
|
+
});
|
|
11377
|
+
const {
|
|
11378
|
+
order: preview,
|
|
11379
|
+
isPending: isPreviewPending,
|
|
11380
|
+
isError: isPreviewError,
|
|
11381
|
+
error: previewError
|
|
11382
|
+
} = useOrderPreview(id);
|
|
11383
|
+
useInitiateOrderEdit({ preview });
|
|
11384
|
+
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11385
|
+
if (isError) {
|
|
11386
|
+
throw error;
|
|
11387
|
+
}
|
|
11388
|
+
if (isPreviewError) {
|
|
11389
|
+
throw previewError;
|
|
11390
|
+
}
|
|
11391
|
+
const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
|
|
11392
|
+
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
11393
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
11394
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
11395
|
+
/* @__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: [
|
|
11396
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
11397
|
+
/* @__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." }) })
|
|
11398
|
+
] }) }) }),
|
|
11399
|
+
/* @__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" }) }) })
|
|
11400
|
+
] }) : isReady ? /* @__PURE__ */ jsxRuntime.jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11401
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
11402
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
11403
|
+
] }) });
|
|
11404
|
+
};
|
|
11405
|
+
const ShippingForm = ({ preview, order }) => {
|
|
11406
|
+
var _a;
|
|
11407
|
+
const { setIsOpen } = useStackedModal();
|
|
11408
|
+
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
11409
|
+
const [data, setData] = React.useState(null);
|
|
11410
|
+
const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
|
|
11411
|
+
const { shipping_options } = useShippingOptions(
|
|
11412
|
+
{
|
|
11413
|
+
id: appliedShippingOptionIds,
|
|
11414
|
+
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
11415
|
+
},
|
|
11416
|
+
{
|
|
11417
|
+
enabled: appliedShippingOptionIds.length > 0
|
|
11418
|
+
}
|
|
11419
|
+
);
|
|
11420
|
+
const uniqueShippingProfiles = React.useMemo(() => {
|
|
11421
|
+
const profiles = /* @__PURE__ */ new Map();
|
|
11422
|
+
getUniqueShippingProfiles(order.items).forEach((profile) => {
|
|
11423
|
+
profiles.set(profile.id, profile);
|
|
11424
|
+
});
|
|
11425
|
+
shipping_options == null ? void 0 : shipping_options.forEach((option) => {
|
|
11426
|
+
profiles.set(option.shipping_profile_id, option.shipping_profile);
|
|
11427
|
+
});
|
|
11428
|
+
return Array.from(profiles.values());
|
|
11429
|
+
}, [order.items, shipping_options]);
|
|
11430
|
+
const { handleSuccess } = useRouteModal();
|
|
11431
|
+
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
11432
|
+
const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
|
|
11433
|
+
const { mutateAsync: removeShippingMethod } = useDraftOrderRemoveShippingMethod(preview.id);
|
|
11434
|
+
const { mutateAsync: removeActionShippingMethod } = useDraftOrderRemoveActionShippingMethod(preview.id);
|
|
11435
|
+
const onSubmit = async () => {
|
|
11436
|
+
setIsSubmitting(true);
|
|
11437
|
+
let requestSucceeded = false;
|
|
11433
11438
|
await requestOrderEdit(void 0, {
|
|
11434
11439
|
onError: (e) => {
|
|
11435
11440
|
ui.toast.error(`Failed to request order edit: ${e.message}`);
|
|
@@ -12169,112 +12174,6 @@ const CustomAmountField = ({
|
|
|
12169
12174
|
}
|
|
12170
12175
|
);
|
|
12171
12176
|
};
|
|
12172
|
-
const SalesChannel = () => {
|
|
12173
|
-
const { id } = reactRouterDom.useParams();
|
|
12174
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12175
|
-
id,
|
|
12176
|
-
{
|
|
12177
|
-
fields: "+sales_channel_id"
|
|
12178
|
-
},
|
|
12179
|
-
{
|
|
12180
|
-
enabled: !!id
|
|
12181
|
-
}
|
|
12182
|
-
);
|
|
12183
|
-
if (isError) {
|
|
12184
|
-
throw error;
|
|
12185
|
-
}
|
|
12186
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
12187
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12188
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12189
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
12190
|
-
/* @__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" }) })
|
|
12191
|
-
] }),
|
|
12192
|
-
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
12193
|
-
] });
|
|
12194
|
-
};
|
|
12195
|
-
const SalesChannelForm = ({ order }) => {
|
|
12196
|
-
const form = reactHookForm.useForm({
|
|
12197
|
-
defaultValues: {
|
|
12198
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
12199
|
-
},
|
|
12200
|
-
resolver: zod.zodResolver(schema$4)
|
|
12201
|
-
});
|
|
12202
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12203
|
-
const { handleSuccess } = useRouteModal();
|
|
12204
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12205
|
-
await mutateAsync(
|
|
12206
|
-
{
|
|
12207
|
-
sales_channel_id: data.sales_channel_id
|
|
12208
|
-
},
|
|
12209
|
-
{
|
|
12210
|
-
onSuccess: () => {
|
|
12211
|
-
ui.toast.success("Sales channel updated");
|
|
12212
|
-
handleSuccess();
|
|
12213
|
-
},
|
|
12214
|
-
onError: (error) => {
|
|
12215
|
-
ui.toast.error(error.message);
|
|
12216
|
-
}
|
|
12217
|
-
}
|
|
12218
|
-
);
|
|
12219
|
-
});
|
|
12220
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12221
|
-
KeyboundForm,
|
|
12222
|
-
{
|
|
12223
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12224
|
-
onSubmit,
|
|
12225
|
-
children: [
|
|
12226
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12227
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12228
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12229
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12230
|
-
] }) })
|
|
12231
|
-
]
|
|
12232
|
-
}
|
|
12233
|
-
) });
|
|
12234
|
-
};
|
|
12235
|
-
const SalesChannelField = ({ control, order }) => {
|
|
12236
|
-
const salesChannels = useComboboxData({
|
|
12237
|
-
queryFn: async (params) => {
|
|
12238
|
-
return await sdk.admin.salesChannel.list(params);
|
|
12239
|
-
},
|
|
12240
|
-
queryKey: ["sales-channels"],
|
|
12241
|
-
getOptions: (data) => {
|
|
12242
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
12243
|
-
label: salesChannel.name,
|
|
12244
|
-
value: salesChannel.id
|
|
12245
|
-
}));
|
|
12246
|
-
},
|
|
12247
|
-
defaultValue: order.sales_channel_id || void 0
|
|
12248
|
-
});
|
|
12249
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12250
|
-
Form$2.Field,
|
|
12251
|
-
{
|
|
12252
|
-
control,
|
|
12253
|
-
name: "sales_channel_id",
|
|
12254
|
-
render: ({ field }) => {
|
|
12255
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12256
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
12257
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12258
|
-
Combobox,
|
|
12259
|
-
{
|
|
12260
|
-
options: salesChannels.options,
|
|
12261
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
12262
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
12263
|
-
searchValue: salesChannels.searchValue,
|
|
12264
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
12265
|
-
placeholder: "Select sales channel",
|
|
12266
|
-
...field
|
|
12267
|
-
}
|
|
12268
|
-
) }),
|
|
12269
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12270
|
-
] });
|
|
12271
|
-
}
|
|
12272
|
-
}
|
|
12273
|
-
);
|
|
12274
|
-
};
|
|
12275
|
-
const schema$4 = objectType({
|
|
12276
|
-
sales_channel_id: stringType().min(1)
|
|
12277
|
-
});
|
|
12278
12177
|
const ShippingAddress = () => {
|
|
12279
12178
|
const { id } = reactRouterDom.useParams();
|
|
12280
12179
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -12307,7 +12206,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12307
12206
|
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12308
12207
|
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12309
12208
|
},
|
|
12310
|
-
resolver: zod.zodResolver(schema$
|
|
12209
|
+
resolver: zod.zodResolver(schema$2)
|
|
12311
12210
|
});
|
|
12312
12211
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12313
12212
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12477,7 +12376,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12477
12376
|
}
|
|
12478
12377
|
) });
|
|
12479
12378
|
};
|
|
12480
|
-
const schema$
|
|
12379
|
+
const schema$2 = addressSchema;
|
|
12481
12380
|
const TransferOwnership = () => {
|
|
12482
12381
|
const { id } = reactRouterDom.useParams();
|
|
12483
12382
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -12501,7 +12400,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12501
12400
|
defaultValues: {
|
|
12502
12401
|
customer_id: order.customer_id || ""
|
|
12503
12402
|
},
|
|
12504
|
-
resolver: zod.zodResolver(schema$
|
|
12403
|
+
resolver: zod.zodResolver(schema$1)
|
|
12505
12404
|
});
|
|
12506
12405
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12507
12406
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12951,34 +12850,13 @@ const Illustration = () => {
|
|
|
12951
12850
|
}
|
|
12952
12851
|
);
|
|
12953
12852
|
};
|
|
12954
|
-
const schema$2 = objectType({
|
|
12955
|
-
customer_id: stringType().min(1)
|
|
12956
|
-
});
|
|
12957
|
-
const CustomItems = () => {
|
|
12958
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12959
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
12960
|
-
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
12961
|
-
] });
|
|
12962
|
-
};
|
|
12963
|
-
const CustomItemsForm = () => {
|
|
12964
|
-
const form = reactHookForm.useForm({
|
|
12965
|
-
resolver: zod.zodResolver(schema$1)
|
|
12966
|
-
});
|
|
12967
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
12968
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
12969
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12970
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12971
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
12972
|
-
] }) })
|
|
12973
|
-
] }) });
|
|
12974
|
-
};
|
|
12975
12853
|
const schema$1 = objectType({
|
|
12976
|
-
|
|
12854
|
+
customer_id: stringType().min(1)
|
|
12977
12855
|
});
|
|
12978
|
-
const
|
|
12856
|
+
const BillingAddress = () => {
|
|
12979
12857
|
const { id } = reactRouterDom.useParams();
|
|
12980
12858
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
12981
|
-
fields: "+
|
|
12859
|
+
fields: "+billing_address"
|
|
12982
12860
|
});
|
|
12983
12861
|
if (isError) {
|
|
12984
12862
|
throw error;
|
|
@@ -12986,16 +12864,26 @@ const Email = () => {
|
|
|
12986
12864
|
const isReady = !isPending && !!order;
|
|
12987
12865
|
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12988
12866
|
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12989
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit
|
|
12990
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the
|
|
12867
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
|
|
12868
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
12991
12869
|
] }),
|
|
12992
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(
|
|
12870
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
|
|
12993
12871
|
] });
|
|
12994
12872
|
};
|
|
12995
|
-
const
|
|
12873
|
+
const BillingAddressForm = ({ order }) => {
|
|
12874
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12996
12875
|
const form = reactHookForm.useForm({
|
|
12997
12876
|
defaultValues: {
|
|
12998
|
-
|
|
12877
|
+
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12878
|
+
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12879
|
+
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
12880
|
+
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12881
|
+
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12882
|
+
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
12883
|
+
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
12884
|
+
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12885
|
+
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12886
|
+
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
12999
12887
|
},
|
|
13000
12888
|
resolver: zod.zodResolver(schema)
|
|
13001
12889
|
});
|
|
@@ -13003,7 +12891,7 @@ const EmailForm = ({ order }) => {
|
|
|
13003
12891
|
const { handleSuccess } = useRouteModal();
|
|
13004
12892
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
13005
12893
|
await mutateAsync(
|
|
13006
|
-
{
|
|
12894
|
+
{ billing_address: data },
|
|
13007
12895
|
{
|
|
13008
12896
|
onSuccess: () => {
|
|
13009
12897
|
handleSuccess();
|
|
@@ -13020,18 +12908,132 @@ const EmailForm = ({ order }) => {
|
|
|
13020
12908
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
13021
12909
|
onSubmit,
|
|
13022
12910
|
children: [
|
|
13023
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.
|
|
13024
|
-
|
|
13025
|
-
|
|
13026
|
-
|
|
13027
|
-
|
|
13028
|
-
|
|
13029
|
-
/* @__PURE__ */ jsxRuntime.
|
|
13030
|
-
|
|
13031
|
-
|
|
13032
|
-
|
|
13033
|
-
|
|
13034
|
-
|
|
12911
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
|
|
12912
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12913
|
+
Form$2.Field,
|
|
12914
|
+
{
|
|
12915
|
+
control: form.control,
|
|
12916
|
+
name: "country_code",
|
|
12917
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12918
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
|
|
12919
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
12920
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12921
|
+
] })
|
|
12922
|
+
}
|
|
12923
|
+
),
|
|
12924
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12925
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12926
|
+
Form$2.Field,
|
|
12927
|
+
{
|
|
12928
|
+
control: form.control,
|
|
12929
|
+
name: "first_name",
|
|
12930
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12931
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
12932
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12933
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12934
|
+
] })
|
|
12935
|
+
}
|
|
12936
|
+
),
|
|
12937
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12938
|
+
Form$2.Field,
|
|
12939
|
+
{
|
|
12940
|
+
control: form.control,
|
|
12941
|
+
name: "last_name",
|
|
12942
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12943
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
12944
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12945
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12946
|
+
] })
|
|
12947
|
+
}
|
|
12948
|
+
)
|
|
12949
|
+
] }),
|
|
12950
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12951
|
+
Form$2.Field,
|
|
12952
|
+
{
|
|
12953
|
+
control: form.control,
|
|
12954
|
+
name: "company",
|
|
12955
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12956
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12957
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12958
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12959
|
+
] })
|
|
12960
|
+
}
|
|
12961
|
+
),
|
|
12962
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12963
|
+
Form$2.Field,
|
|
12964
|
+
{
|
|
12965
|
+
control: form.control,
|
|
12966
|
+
name: "address_1",
|
|
12967
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12968
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
12969
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12970
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12971
|
+
] })
|
|
12972
|
+
}
|
|
12973
|
+
),
|
|
12974
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12975
|
+
Form$2.Field,
|
|
12976
|
+
{
|
|
12977
|
+
control: form.control,
|
|
12978
|
+
name: "address_2",
|
|
12979
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12980
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12981
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12982
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12983
|
+
] })
|
|
12984
|
+
}
|
|
12985
|
+
),
|
|
12986
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12987
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12988
|
+
Form$2.Field,
|
|
12989
|
+
{
|
|
12990
|
+
control: form.control,
|
|
12991
|
+
name: "postal_code",
|
|
12992
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12993
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
12994
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12995
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12996
|
+
] })
|
|
12997
|
+
}
|
|
12998
|
+
),
|
|
12999
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13000
|
+
Form$2.Field,
|
|
13001
|
+
{
|
|
13002
|
+
control: form.control,
|
|
13003
|
+
name: "city",
|
|
13004
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
13005
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
13006
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
13007
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
13008
|
+
] })
|
|
13009
|
+
}
|
|
13010
|
+
)
|
|
13011
|
+
] }),
|
|
13012
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13013
|
+
Form$2.Field,
|
|
13014
|
+
{
|
|
13015
|
+
control: form.control,
|
|
13016
|
+
name: "province",
|
|
13017
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
13018
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
13019
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
13020
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
13021
|
+
] })
|
|
13022
|
+
}
|
|
13023
|
+
),
|
|
13024
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13025
|
+
Form$2.Field,
|
|
13026
|
+
{
|
|
13027
|
+
control: form.control,
|
|
13028
|
+
name: "phone",
|
|
13029
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
13030
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
13031
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
13032
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
13033
|
+
] })
|
|
13034
|
+
}
|
|
13035
|
+
)
|
|
13036
|
+
] }) }),
|
|
13035
13037
|
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13036
13038
|
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
13037
13039
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
@@ -13040,9 +13042,7 @@ const EmailForm = ({ order }) => {
|
|
|
13040
13042
|
}
|
|
13041
13043
|
) });
|
|
13042
13044
|
};
|
|
13043
|
-
const schema =
|
|
13044
|
-
email: stringType().email()
|
|
13045
|
-
});
|
|
13045
|
+
const schema = addressSchema;
|
|
13046
13046
|
const widgetModule = { widgets: [] };
|
|
13047
13047
|
const routeModule = {
|
|
13048
13048
|
routes: [
|
|
@@ -13064,8 +13064,12 @@ const routeModule = {
|
|
|
13064
13064
|
loader,
|
|
13065
13065
|
children: [
|
|
13066
13066
|
{
|
|
13067
|
-
Component:
|
|
13068
|
-
path: "/draft-orders/:id/
|
|
13067
|
+
Component: CustomItems,
|
|
13068
|
+
path: "/draft-orders/:id/custom-items"
|
|
13069
|
+
},
|
|
13070
|
+
{
|
|
13071
|
+
Component: Email,
|
|
13072
|
+
path: "/draft-orders/:id/email"
|
|
13069
13073
|
},
|
|
13070
13074
|
{
|
|
13071
13075
|
Component: Items,
|
|
@@ -13079,14 +13083,14 @@ const routeModule = {
|
|
|
13079
13083
|
Component: Promotions,
|
|
13080
13084
|
path: "/draft-orders/:id/promotions"
|
|
13081
13085
|
},
|
|
13082
|
-
{
|
|
13083
|
-
Component: Shipping,
|
|
13084
|
-
path: "/draft-orders/:id/shipping"
|
|
13085
|
-
},
|
|
13086
13086
|
{
|
|
13087
13087
|
Component: SalesChannel,
|
|
13088
13088
|
path: "/draft-orders/:id/sales-channel"
|
|
13089
13089
|
},
|
|
13090
|
+
{
|
|
13091
|
+
Component: Shipping,
|
|
13092
|
+
path: "/draft-orders/:id/shipping"
|
|
13093
|
+
},
|
|
13090
13094
|
{
|
|
13091
13095
|
Component: ShippingAddress,
|
|
13092
13096
|
path: "/draft-orders/:id/shipping-address"
|
|
@@ -13096,12 +13100,8 @@ const routeModule = {
|
|
|
13096
13100
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13097
13101
|
},
|
|
13098
13102
|
{
|
|
13099
|
-
Component:
|
|
13100
|
-
path: "/draft-orders/:id/
|
|
13101
|
-
},
|
|
13102
|
-
{
|
|
13103
|
-
Component: Email,
|
|
13104
|
-
path: "/draft-orders/:id/email"
|
|
13103
|
+
Component: BillingAddress,
|
|
13104
|
+
path: "/draft-orders/:id/billing-address"
|
|
13105
13105
|
}
|
|
13106
13106
|
]
|
|
13107
13107
|
}
|