@medusajs/draft-order 2.11.4-preview-20251121180139 → 2.11.4-preview-20251122000259
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 +404 -404
- package/.medusa/server/src/admin/index.mjs +404 -404
- package/package.json +16 -16
|
@@ -9755,74 +9755,6 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9755
9755
|
) });
|
|
9756
9756
|
};
|
|
9757
9757
|
const schema$5 = addressSchema;
|
|
9758
|
-
const Email = () => {
|
|
9759
|
-
const { id } = useParams();
|
|
9760
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
9761
|
-
fields: "+email"
|
|
9762
|
-
});
|
|
9763
|
-
if (isError) {
|
|
9764
|
-
throw error;
|
|
9765
|
-
}
|
|
9766
|
-
const isReady = !isPending && !!order;
|
|
9767
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9768
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
9769
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
|
|
9770
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
9771
|
-
] }),
|
|
9772
|
-
isReady && /* @__PURE__ */ jsx(EmailForm, { order })
|
|
9773
|
-
] });
|
|
9774
|
-
};
|
|
9775
|
-
const EmailForm = ({ order }) => {
|
|
9776
|
-
const form = useForm({
|
|
9777
|
-
defaultValues: {
|
|
9778
|
-
email: order.email ?? ""
|
|
9779
|
-
},
|
|
9780
|
-
resolver: zodResolver(schema$4)
|
|
9781
|
-
});
|
|
9782
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9783
|
-
const { handleSuccess } = useRouteModal();
|
|
9784
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
9785
|
-
await mutateAsync(
|
|
9786
|
-
{ email: data.email },
|
|
9787
|
-
{
|
|
9788
|
-
onSuccess: () => {
|
|
9789
|
-
handleSuccess();
|
|
9790
|
-
},
|
|
9791
|
-
onError: (error) => {
|
|
9792
|
-
toast.error(error.message);
|
|
9793
|
-
}
|
|
9794
|
-
}
|
|
9795
|
-
);
|
|
9796
|
-
});
|
|
9797
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
9798
|
-
KeyboundForm,
|
|
9799
|
-
{
|
|
9800
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
9801
|
-
onSubmit,
|
|
9802
|
-
children: [
|
|
9803
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
9804
|
-
Form$2.Field,
|
|
9805
|
-
{
|
|
9806
|
-
control: form.control,
|
|
9807
|
-
name: "email",
|
|
9808
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9809
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
|
|
9810
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9811
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9812
|
-
] })
|
|
9813
|
-
}
|
|
9814
|
-
) }),
|
|
9815
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9816
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9817
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9818
|
-
] }) })
|
|
9819
|
-
]
|
|
9820
|
-
}
|
|
9821
|
-
) });
|
|
9822
|
-
};
|
|
9823
|
-
const schema$4 = objectType({
|
|
9824
|
-
email: stringType().email()
|
|
9825
|
-
});
|
|
9826
9758
|
const CustomItems = () => {
|
|
9827
9759
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9828
9760
|
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
@@ -9831,7 +9763,7 @@ const CustomItems = () => {
|
|
|
9831
9763
|
};
|
|
9832
9764
|
const CustomItemsForm = () => {
|
|
9833
9765
|
const form = useForm({
|
|
9834
|
-
resolver: zodResolver(schema$
|
|
9766
|
+
resolver: zodResolver(schema$4)
|
|
9835
9767
|
});
|
|
9836
9768
|
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9837
9769
|
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
@@ -9841,7 +9773,7 @@ const CustomItemsForm = () => {
|
|
|
9841
9773
|
] }) })
|
|
9842
9774
|
] }) });
|
|
9843
9775
|
};
|
|
9844
|
-
const schema$
|
|
9776
|
+
const schema$4 = objectType({
|
|
9845
9777
|
email: stringType().email()
|
|
9846
9778
|
});
|
|
9847
9779
|
const NumberInput = forwardRef(
|
|
@@ -11473,7 +11405,7 @@ const SalesChannelForm = ({ order }) => {
|
|
|
11473
11405
|
defaultValues: {
|
|
11474
11406
|
sales_channel_id: order.sales_channel_id || ""
|
|
11475
11407
|
},
|
|
11476
|
-
resolver: zodResolver(schema$
|
|
11408
|
+
resolver: zodResolver(schema$3)
|
|
11477
11409
|
});
|
|
11478
11410
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11479
11411
|
const { handleSuccess } = useRouteModal();
|
|
@@ -11548,334 +11480,131 @@ const SalesChannelField = ({ control, order }) => {
|
|
|
11548
11480
|
}
|
|
11549
11481
|
);
|
|
11550
11482
|
};
|
|
11551
|
-
const schema$
|
|
11483
|
+
const schema$3 = objectType({
|
|
11552
11484
|
sales_channel_id: stringType().min(1)
|
|
11553
11485
|
});
|
|
11554
|
-
const
|
|
11486
|
+
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11487
|
+
const Shipping = () => {
|
|
11488
|
+
var _a;
|
|
11555
11489
|
const { id } = useParams();
|
|
11556
11490
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
11557
|
-
fields: "+
|
|
11491
|
+
fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
|
|
11558
11492
|
});
|
|
11493
|
+
const {
|
|
11494
|
+
order: preview,
|
|
11495
|
+
isPending: isPreviewPending,
|
|
11496
|
+
isError: isPreviewError,
|
|
11497
|
+
error: previewError
|
|
11498
|
+
} = useOrderPreview(id);
|
|
11499
|
+
useInitiateOrderEdit({ preview });
|
|
11500
|
+
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11559
11501
|
if (isError) {
|
|
11560
11502
|
throw error;
|
|
11561
11503
|
}
|
|
11562
|
-
|
|
11563
|
-
|
|
11564
|
-
|
|
11565
|
-
|
|
11566
|
-
|
|
11567
|
-
|
|
11568
|
-
|
|
11569
|
-
|
|
11504
|
+
if (isPreviewError) {
|
|
11505
|
+
throw previewError;
|
|
11506
|
+
}
|
|
11507
|
+
const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
|
|
11508
|
+
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
11509
|
+
return /* @__PURE__ */ jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
11510
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
|
|
11511
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 px-6 py-16", children: [
|
|
11512
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
|
|
11513
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
|
|
11514
|
+
] }) }) }),
|
|
11515
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
|
|
11516
|
+
] }) : isReady ? /* @__PURE__ */ jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxs("div", { children: [
|
|
11517
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
11518
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
11519
|
+
] }) });
|
|
11570
11520
|
};
|
|
11571
|
-
const
|
|
11572
|
-
var _a
|
|
11573
|
-
const
|
|
11574
|
-
|
|
11575
|
-
|
|
11576
|
-
|
|
11577
|
-
|
|
11578
|
-
|
|
11579
|
-
|
|
11580
|
-
|
|
11581
|
-
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
11582
|
-
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
11583
|
-
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
11584
|
-
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
11521
|
+
const ShippingForm = ({ preview, order }) => {
|
|
11522
|
+
var _a;
|
|
11523
|
+
const { setIsOpen } = useStackedModal();
|
|
11524
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
11525
|
+
const [data, setData] = useState(null);
|
|
11526
|
+
const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
|
|
11527
|
+
const { shipping_options } = useShippingOptions(
|
|
11528
|
+
{
|
|
11529
|
+
id: appliedShippingOptionIds,
|
|
11530
|
+
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
11585
11531
|
},
|
|
11586
|
-
|
|
11587
|
-
|
|
11588
|
-
|
|
11532
|
+
{
|
|
11533
|
+
enabled: appliedShippingOptionIds.length > 0
|
|
11534
|
+
}
|
|
11535
|
+
);
|
|
11536
|
+
const uniqueShippingProfiles = useMemo(() => {
|
|
11537
|
+
const profiles = /* @__PURE__ */ new Map();
|
|
11538
|
+
getUniqueShippingProfiles(order.items).forEach((profile) => {
|
|
11539
|
+
profiles.set(profile.id, profile);
|
|
11540
|
+
});
|
|
11541
|
+
shipping_options == null ? void 0 : shipping_options.forEach((option) => {
|
|
11542
|
+
profiles.set(option.shipping_profile_id, option.shipping_profile);
|
|
11543
|
+
});
|
|
11544
|
+
return Array.from(profiles.values());
|
|
11545
|
+
}, [order.items, shipping_options]);
|
|
11589
11546
|
const { handleSuccess } = useRouteModal();
|
|
11590
|
-
const
|
|
11591
|
-
|
|
11592
|
-
|
|
11593
|
-
|
|
11594
|
-
|
|
11595
|
-
|
|
11596
|
-
|
|
11597
|
-
|
|
11598
|
-
|
|
11599
|
-
|
|
11600
|
-
province: data.province,
|
|
11601
|
-
country_code: data.country_code,
|
|
11602
|
-
postal_code: data.postal_code,
|
|
11603
|
-
phone: data.phone
|
|
11604
|
-
}
|
|
11547
|
+
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
11548
|
+
const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
|
|
11549
|
+
const { mutateAsync: removeShippingMethod } = useDraftOrderRemoveShippingMethod(preview.id);
|
|
11550
|
+
const { mutateAsync: removeActionShippingMethod } = useDraftOrderRemoveActionShippingMethod(preview.id);
|
|
11551
|
+
const onSubmit = async () => {
|
|
11552
|
+
setIsSubmitting(true);
|
|
11553
|
+
let requestSucceeded = false;
|
|
11554
|
+
await requestOrderEdit(void 0, {
|
|
11555
|
+
onError: (e) => {
|
|
11556
|
+
toast.error(`Failed to request order edit: ${e.message}`);
|
|
11605
11557
|
},
|
|
11606
|
-
{
|
|
11607
|
-
|
|
11608
|
-
|
|
11609
|
-
|
|
11610
|
-
|
|
11611
|
-
|
|
11558
|
+
onSuccess: () => {
|
|
11559
|
+
requestSucceeded = true;
|
|
11560
|
+
}
|
|
11561
|
+
});
|
|
11562
|
+
if (!requestSucceeded) {
|
|
11563
|
+
setIsSubmitting(false);
|
|
11564
|
+
return;
|
|
11565
|
+
}
|
|
11566
|
+
await confirmOrderEdit(void 0, {
|
|
11567
|
+
onError: (e) => {
|
|
11568
|
+
toast.error(`Failed to confirm order edit: ${e.message}`);
|
|
11569
|
+
},
|
|
11570
|
+
onSuccess: () => {
|
|
11571
|
+
handleSuccess();
|
|
11572
|
+
},
|
|
11573
|
+
onSettled: () => {
|
|
11574
|
+
setIsSubmitting(false);
|
|
11575
|
+
}
|
|
11576
|
+
});
|
|
11577
|
+
};
|
|
11578
|
+
const onKeydown = useCallback(
|
|
11579
|
+
(e) => {
|
|
11580
|
+
if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
|
|
11581
|
+
if (data || isSubmitting) {
|
|
11582
|
+
return;
|
|
11612
11583
|
}
|
|
11584
|
+
onSubmit();
|
|
11613
11585
|
}
|
|
11614
|
-
|
|
11615
|
-
|
|
11616
|
-
|
|
11617
|
-
|
|
11618
|
-
|
|
11619
|
-
|
|
11620
|
-
|
|
11621
|
-
|
|
11622
|
-
|
|
11623
|
-
|
|
11624
|
-
|
|
11625
|
-
|
|
11626
|
-
|
|
11627
|
-
|
|
11628
|
-
|
|
11629
|
-
|
|
11630
|
-
|
|
11631
|
-
|
|
11632
|
-
|
|
11633
|
-
|
|
11634
|
-
),
|
|
11635
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11586
|
+
},
|
|
11587
|
+
[data, isSubmitting, onSubmit]
|
|
11588
|
+
);
|
|
11589
|
+
useEffect(() => {
|
|
11590
|
+
document.addEventListener("keydown", onKeydown);
|
|
11591
|
+
return () => {
|
|
11592
|
+
document.removeEventListener("keydown", onKeydown);
|
|
11593
|
+
};
|
|
11594
|
+
}, [onKeydown]);
|
|
11595
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
|
|
11596
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
|
|
11597
|
+
/* @__PURE__ */ jsxs(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
11598
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 px-6 py-16", children: [
|
|
11599
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
11600
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
|
|
11601
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Choose which shipping method(s) to use for the items in the order." }) })
|
|
11602
|
+
] }),
|
|
11603
|
+
/* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
|
|
11604
|
+
/* @__PURE__ */ jsx(Accordion.Root, { type: "multiple", children: /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
|
|
11605
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-4 py-2", children: [
|
|
11636
11606
|
/* @__PURE__ */ jsx(
|
|
11637
|
-
|
|
11638
|
-
{
|
|
11639
|
-
control: form.control,
|
|
11640
|
-
name: "first_name",
|
|
11641
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11642
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
11643
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11644
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11645
|
-
] })
|
|
11646
|
-
}
|
|
11647
|
-
),
|
|
11648
|
-
/* @__PURE__ */ jsx(
|
|
11649
|
-
Form$2.Field,
|
|
11650
|
-
{
|
|
11651
|
-
control: form.control,
|
|
11652
|
-
name: "last_name",
|
|
11653
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11654
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
11655
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11656
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11657
|
-
] })
|
|
11658
|
-
}
|
|
11659
|
-
)
|
|
11660
|
-
] }),
|
|
11661
|
-
/* @__PURE__ */ jsx(
|
|
11662
|
-
Form$2.Field,
|
|
11663
|
-
{
|
|
11664
|
-
control: form.control,
|
|
11665
|
-
name: "company",
|
|
11666
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11667
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
11668
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11669
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11670
|
-
] })
|
|
11671
|
-
}
|
|
11672
|
-
),
|
|
11673
|
-
/* @__PURE__ */ jsx(
|
|
11674
|
-
Form$2.Field,
|
|
11675
|
-
{
|
|
11676
|
-
control: form.control,
|
|
11677
|
-
name: "address_1",
|
|
11678
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11679
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
11680
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11681
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11682
|
-
] })
|
|
11683
|
-
}
|
|
11684
|
-
),
|
|
11685
|
-
/* @__PURE__ */ jsx(
|
|
11686
|
-
Form$2.Field,
|
|
11687
|
-
{
|
|
11688
|
-
control: form.control,
|
|
11689
|
-
name: "address_2",
|
|
11690
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11691
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
11692
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11693
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11694
|
-
] })
|
|
11695
|
-
}
|
|
11696
|
-
),
|
|
11697
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11698
|
-
/* @__PURE__ */ jsx(
|
|
11699
|
-
Form$2.Field,
|
|
11700
|
-
{
|
|
11701
|
-
control: form.control,
|
|
11702
|
-
name: "postal_code",
|
|
11703
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11704
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
11705
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11706
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11707
|
-
] })
|
|
11708
|
-
}
|
|
11709
|
-
),
|
|
11710
|
-
/* @__PURE__ */ jsx(
|
|
11711
|
-
Form$2.Field,
|
|
11712
|
-
{
|
|
11713
|
-
control: form.control,
|
|
11714
|
-
name: "city",
|
|
11715
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11716
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
11717
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11718
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11719
|
-
] })
|
|
11720
|
-
}
|
|
11721
|
-
)
|
|
11722
|
-
] }),
|
|
11723
|
-
/* @__PURE__ */ jsx(
|
|
11724
|
-
Form$2.Field,
|
|
11725
|
-
{
|
|
11726
|
-
control: form.control,
|
|
11727
|
-
name: "province",
|
|
11728
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11729
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
11730
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11731
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11732
|
-
] })
|
|
11733
|
-
}
|
|
11734
|
-
),
|
|
11735
|
-
/* @__PURE__ */ jsx(
|
|
11736
|
-
Form$2.Field,
|
|
11737
|
-
{
|
|
11738
|
-
control: form.control,
|
|
11739
|
-
name: "phone",
|
|
11740
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11741
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
11742
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11743
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11744
|
-
] })
|
|
11745
|
-
}
|
|
11746
|
-
)
|
|
11747
|
-
] }) }),
|
|
11748
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11749
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11750
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11751
|
-
] }) })
|
|
11752
|
-
]
|
|
11753
|
-
}
|
|
11754
|
-
) });
|
|
11755
|
-
};
|
|
11756
|
-
const schema$1 = addressSchema;
|
|
11757
|
-
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11758
|
-
const Shipping = () => {
|
|
11759
|
-
var _a;
|
|
11760
|
-
const { id } = useParams();
|
|
11761
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
11762
|
-
fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
|
|
11763
|
-
});
|
|
11764
|
-
const {
|
|
11765
|
-
order: preview,
|
|
11766
|
-
isPending: isPreviewPending,
|
|
11767
|
-
isError: isPreviewError,
|
|
11768
|
-
error: previewError
|
|
11769
|
-
} = useOrderPreview(id);
|
|
11770
|
-
useInitiateOrderEdit({ preview });
|
|
11771
|
-
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11772
|
-
if (isError) {
|
|
11773
|
-
throw error;
|
|
11774
|
-
}
|
|
11775
|
-
if (isPreviewError) {
|
|
11776
|
-
throw previewError;
|
|
11777
|
-
}
|
|
11778
|
-
const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
|
|
11779
|
-
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
11780
|
-
return /* @__PURE__ */ jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
11781
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
|
|
11782
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 px-6 py-16", children: [
|
|
11783
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
|
|
11784
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
|
|
11785
|
-
] }) }) }),
|
|
11786
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
|
|
11787
|
-
] }) : isReady ? /* @__PURE__ */ jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxs("div", { children: [
|
|
11788
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
11789
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
11790
|
-
] }) });
|
|
11791
|
-
};
|
|
11792
|
-
const ShippingForm = ({ preview, order }) => {
|
|
11793
|
-
var _a;
|
|
11794
|
-
const { setIsOpen } = useStackedModal();
|
|
11795
|
-
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
11796
|
-
const [data, setData] = useState(null);
|
|
11797
|
-
const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
|
|
11798
|
-
const { shipping_options } = useShippingOptions(
|
|
11799
|
-
{
|
|
11800
|
-
id: appliedShippingOptionIds,
|
|
11801
|
-
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
11802
|
-
},
|
|
11803
|
-
{
|
|
11804
|
-
enabled: appliedShippingOptionIds.length > 0
|
|
11805
|
-
}
|
|
11806
|
-
);
|
|
11807
|
-
const uniqueShippingProfiles = useMemo(() => {
|
|
11808
|
-
const profiles = /* @__PURE__ */ new Map();
|
|
11809
|
-
getUniqueShippingProfiles(order.items).forEach((profile) => {
|
|
11810
|
-
profiles.set(profile.id, profile);
|
|
11811
|
-
});
|
|
11812
|
-
shipping_options == null ? void 0 : shipping_options.forEach((option) => {
|
|
11813
|
-
profiles.set(option.shipping_profile_id, option.shipping_profile);
|
|
11814
|
-
});
|
|
11815
|
-
return Array.from(profiles.values());
|
|
11816
|
-
}, [order.items, shipping_options]);
|
|
11817
|
-
const { handleSuccess } = useRouteModal();
|
|
11818
|
-
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
11819
|
-
const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
|
|
11820
|
-
const { mutateAsync: removeShippingMethod } = useDraftOrderRemoveShippingMethod(preview.id);
|
|
11821
|
-
const { mutateAsync: removeActionShippingMethod } = useDraftOrderRemoveActionShippingMethod(preview.id);
|
|
11822
|
-
const onSubmit = async () => {
|
|
11823
|
-
setIsSubmitting(true);
|
|
11824
|
-
let requestSucceeded = false;
|
|
11825
|
-
await requestOrderEdit(void 0, {
|
|
11826
|
-
onError: (e) => {
|
|
11827
|
-
toast.error(`Failed to request order edit: ${e.message}`);
|
|
11828
|
-
},
|
|
11829
|
-
onSuccess: () => {
|
|
11830
|
-
requestSucceeded = true;
|
|
11831
|
-
}
|
|
11832
|
-
});
|
|
11833
|
-
if (!requestSucceeded) {
|
|
11834
|
-
setIsSubmitting(false);
|
|
11835
|
-
return;
|
|
11836
|
-
}
|
|
11837
|
-
await confirmOrderEdit(void 0, {
|
|
11838
|
-
onError: (e) => {
|
|
11839
|
-
toast.error(`Failed to confirm order edit: ${e.message}`);
|
|
11840
|
-
},
|
|
11841
|
-
onSuccess: () => {
|
|
11842
|
-
handleSuccess();
|
|
11843
|
-
},
|
|
11844
|
-
onSettled: () => {
|
|
11845
|
-
setIsSubmitting(false);
|
|
11846
|
-
}
|
|
11847
|
-
});
|
|
11848
|
-
};
|
|
11849
|
-
const onKeydown = useCallback(
|
|
11850
|
-
(e) => {
|
|
11851
|
-
if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
|
|
11852
|
-
if (data || isSubmitting) {
|
|
11853
|
-
return;
|
|
11854
|
-
}
|
|
11855
|
-
onSubmit();
|
|
11856
|
-
}
|
|
11857
|
-
},
|
|
11858
|
-
[data, isSubmitting, onSubmit]
|
|
11859
|
-
);
|
|
11860
|
-
useEffect(() => {
|
|
11861
|
-
document.addEventListener("keydown", onKeydown);
|
|
11862
|
-
return () => {
|
|
11863
|
-
document.removeEventListener("keydown", onKeydown);
|
|
11864
|
-
};
|
|
11865
|
-
}, [onKeydown]);
|
|
11866
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
|
|
11867
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
|
|
11868
|
-
/* @__PURE__ */ jsxs(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
11869
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 px-6 py-16", children: [
|
|
11870
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
11871
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
|
|
11872
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Choose which shipping method(s) to use for the items in the order." }) })
|
|
11873
|
-
] }),
|
|
11874
|
-
/* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
|
|
11875
|
-
/* @__PURE__ */ jsx(Accordion.Root, { type: "multiple", children: /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
|
|
11876
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-4 py-2", children: [
|
|
11877
|
-
/* @__PURE__ */ jsx(
|
|
11878
|
-
Text,
|
|
11607
|
+
Text,
|
|
11879
11608
|
{
|
|
11880
11609
|
size: "xsmall",
|
|
11881
11610
|
weight: "plus",
|
|
@@ -12561,30 +12290,233 @@ const CustomAmountField = ({
|
|
|
12561
12290
|
}
|
|
12562
12291
|
);
|
|
12563
12292
|
};
|
|
12564
|
-
const
|
|
12293
|
+
const ShippingAddress = () => {
|
|
12565
12294
|
const { id } = useParams();
|
|
12566
|
-
const {
|
|
12567
|
-
fields: "
|
|
12295
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
12296
|
+
fields: "+shipping_address"
|
|
12568
12297
|
});
|
|
12569
12298
|
if (isError) {
|
|
12570
12299
|
throw error;
|
|
12571
12300
|
}
|
|
12572
|
-
const isReady = !isPending && !!
|
|
12301
|
+
const isReady = !isPending && !!order;
|
|
12573
12302
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12574
12303
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12575
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "
|
|
12576
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "
|
|
12304
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
|
|
12305
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
12577
12306
|
] }),
|
|
12578
|
-
isReady && /* @__PURE__ */ jsx(
|
|
12307
|
+
isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
|
|
12579
12308
|
] });
|
|
12580
12309
|
};
|
|
12581
|
-
const
|
|
12582
|
-
var _a, _b;
|
|
12583
|
-
const form = useForm({
|
|
12310
|
+
const ShippingAddressForm = ({ order }) => {
|
|
12311
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12312
|
+
const form = useForm({
|
|
12313
|
+
defaultValues: {
|
|
12314
|
+
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12315
|
+
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12316
|
+
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12317
|
+
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12318
|
+
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12319
|
+
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12320
|
+
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12321
|
+
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12322
|
+
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12323
|
+
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12324
|
+
},
|
|
12325
|
+
resolver: zodResolver(schema$2)
|
|
12326
|
+
});
|
|
12327
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12328
|
+
const { handleSuccess } = useRouteModal();
|
|
12329
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12330
|
+
await mutateAsync(
|
|
12331
|
+
{
|
|
12332
|
+
shipping_address: {
|
|
12333
|
+
first_name: data.first_name,
|
|
12334
|
+
last_name: data.last_name,
|
|
12335
|
+
company: data.company,
|
|
12336
|
+
address_1: data.address_1,
|
|
12337
|
+
address_2: data.address_2,
|
|
12338
|
+
city: data.city,
|
|
12339
|
+
province: data.province,
|
|
12340
|
+
country_code: data.country_code,
|
|
12341
|
+
postal_code: data.postal_code,
|
|
12342
|
+
phone: data.phone
|
|
12343
|
+
}
|
|
12344
|
+
},
|
|
12345
|
+
{
|
|
12346
|
+
onSuccess: () => {
|
|
12347
|
+
handleSuccess();
|
|
12348
|
+
},
|
|
12349
|
+
onError: (error) => {
|
|
12350
|
+
toast.error(error.message);
|
|
12351
|
+
}
|
|
12352
|
+
}
|
|
12353
|
+
);
|
|
12354
|
+
});
|
|
12355
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12356
|
+
KeyboundForm,
|
|
12357
|
+
{
|
|
12358
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12359
|
+
onSubmit,
|
|
12360
|
+
children: [
|
|
12361
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
|
|
12362
|
+
/* @__PURE__ */ jsx(
|
|
12363
|
+
Form$2.Field,
|
|
12364
|
+
{
|
|
12365
|
+
control: form.control,
|
|
12366
|
+
name: "country_code",
|
|
12367
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12368
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
12369
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
12370
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12371
|
+
] })
|
|
12372
|
+
}
|
|
12373
|
+
),
|
|
12374
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12375
|
+
/* @__PURE__ */ jsx(
|
|
12376
|
+
Form$2.Field,
|
|
12377
|
+
{
|
|
12378
|
+
control: form.control,
|
|
12379
|
+
name: "first_name",
|
|
12380
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12381
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
12382
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12383
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12384
|
+
] })
|
|
12385
|
+
}
|
|
12386
|
+
),
|
|
12387
|
+
/* @__PURE__ */ jsx(
|
|
12388
|
+
Form$2.Field,
|
|
12389
|
+
{
|
|
12390
|
+
control: form.control,
|
|
12391
|
+
name: "last_name",
|
|
12392
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12393
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
12394
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12395
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12396
|
+
] })
|
|
12397
|
+
}
|
|
12398
|
+
)
|
|
12399
|
+
] }),
|
|
12400
|
+
/* @__PURE__ */ jsx(
|
|
12401
|
+
Form$2.Field,
|
|
12402
|
+
{
|
|
12403
|
+
control: form.control,
|
|
12404
|
+
name: "company",
|
|
12405
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12406
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12407
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12408
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12409
|
+
] })
|
|
12410
|
+
}
|
|
12411
|
+
),
|
|
12412
|
+
/* @__PURE__ */ jsx(
|
|
12413
|
+
Form$2.Field,
|
|
12414
|
+
{
|
|
12415
|
+
control: form.control,
|
|
12416
|
+
name: "address_1",
|
|
12417
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12418
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
12419
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12420
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12421
|
+
] })
|
|
12422
|
+
}
|
|
12423
|
+
),
|
|
12424
|
+
/* @__PURE__ */ jsx(
|
|
12425
|
+
Form$2.Field,
|
|
12426
|
+
{
|
|
12427
|
+
control: form.control,
|
|
12428
|
+
name: "address_2",
|
|
12429
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12430
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12431
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12432
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12433
|
+
] })
|
|
12434
|
+
}
|
|
12435
|
+
),
|
|
12436
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12437
|
+
/* @__PURE__ */ jsx(
|
|
12438
|
+
Form$2.Field,
|
|
12439
|
+
{
|
|
12440
|
+
control: form.control,
|
|
12441
|
+
name: "postal_code",
|
|
12442
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12443
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
12444
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12445
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12446
|
+
] })
|
|
12447
|
+
}
|
|
12448
|
+
),
|
|
12449
|
+
/* @__PURE__ */ jsx(
|
|
12450
|
+
Form$2.Field,
|
|
12451
|
+
{
|
|
12452
|
+
control: form.control,
|
|
12453
|
+
name: "city",
|
|
12454
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12455
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
12456
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12457
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12458
|
+
] })
|
|
12459
|
+
}
|
|
12460
|
+
)
|
|
12461
|
+
] }),
|
|
12462
|
+
/* @__PURE__ */ jsx(
|
|
12463
|
+
Form$2.Field,
|
|
12464
|
+
{
|
|
12465
|
+
control: form.control,
|
|
12466
|
+
name: "province",
|
|
12467
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12468
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
12469
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12470
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12471
|
+
] })
|
|
12472
|
+
}
|
|
12473
|
+
),
|
|
12474
|
+
/* @__PURE__ */ jsx(
|
|
12475
|
+
Form$2.Field,
|
|
12476
|
+
{
|
|
12477
|
+
control: form.control,
|
|
12478
|
+
name: "phone",
|
|
12479
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12480
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
12481
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12482
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12483
|
+
] })
|
|
12484
|
+
}
|
|
12485
|
+
)
|
|
12486
|
+
] }) }),
|
|
12487
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12488
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12489
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12490
|
+
] }) })
|
|
12491
|
+
]
|
|
12492
|
+
}
|
|
12493
|
+
) });
|
|
12494
|
+
};
|
|
12495
|
+
const schema$2 = addressSchema;
|
|
12496
|
+
const TransferOwnership = () => {
|
|
12497
|
+
const { id } = useParams();
|
|
12498
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
12499
|
+
fields: "id,customer_id,customer.*"
|
|
12500
|
+
});
|
|
12501
|
+
if (isError) {
|
|
12502
|
+
throw error;
|
|
12503
|
+
}
|
|
12504
|
+
const isReady = !isPending && !!draft_order;
|
|
12505
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12506
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12507
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Ownership" }) }),
|
|
12508
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Transfer the ownership of this draft order to a new customer" }) })
|
|
12509
|
+
] }),
|
|
12510
|
+
isReady && /* @__PURE__ */ jsx(TransferOwnershipForm, { order: draft_order })
|
|
12511
|
+
] });
|
|
12512
|
+
};
|
|
12513
|
+
const TransferOwnershipForm = ({ order }) => {
|
|
12514
|
+
var _a, _b;
|
|
12515
|
+
const form = useForm({
|
|
12584
12516
|
defaultValues: {
|
|
12585
12517
|
customer_id: order.customer_id || ""
|
|
12586
12518
|
},
|
|
12587
|
-
resolver: zodResolver(schema)
|
|
12519
|
+
resolver: zodResolver(schema$1)
|
|
12588
12520
|
});
|
|
12589
12521
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12590
12522
|
const { handleSuccess } = useRouteModal();
|
|
@@ -13034,9 +12966,77 @@ const Illustration = () => {
|
|
|
13034
12966
|
}
|
|
13035
12967
|
);
|
|
13036
12968
|
};
|
|
13037
|
-
const schema = objectType({
|
|
12969
|
+
const schema$1 = objectType({
|
|
13038
12970
|
customer_id: stringType().min(1)
|
|
13039
12971
|
});
|
|
12972
|
+
const Email = () => {
|
|
12973
|
+
const { id } = useParams();
|
|
12974
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
12975
|
+
fields: "+email"
|
|
12976
|
+
});
|
|
12977
|
+
if (isError) {
|
|
12978
|
+
throw error;
|
|
12979
|
+
}
|
|
12980
|
+
const isReady = !isPending && !!order;
|
|
12981
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12982
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12983
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
|
|
12984
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
12985
|
+
] }),
|
|
12986
|
+
isReady && /* @__PURE__ */ jsx(EmailForm, { order })
|
|
12987
|
+
] });
|
|
12988
|
+
};
|
|
12989
|
+
const EmailForm = ({ order }) => {
|
|
12990
|
+
const form = useForm({
|
|
12991
|
+
defaultValues: {
|
|
12992
|
+
email: order.email ?? ""
|
|
12993
|
+
},
|
|
12994
|
+
resolver: zodResolver(schema)
|
|
12995
|
+
});
|
|
12996
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12997
|
+
const { handleSuccess } = useRouteModal();
|
|
12998
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12999
|
+
await mutateAsync(
|
|
13000
|
+
{ email: data.email },
|
|
13001
|
+
{
|
|
13002
|
+
onSuccess: () => {
|
|
13003
|
+
handleSuccess();
|
|
13004
|
+
},
|
|
13005
|
+
onError: (error) => {
|
|
13006
|
+
toast.error(error.message);
|
|
13007
|
+
}
|
|
13008
|
+
}
|
|
13009
|
+
);
|
|
13010
|
+
});
|
|
13011
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
13012
|
+
KeyboundForm,
|
|
13013
|
+
{
|
|
13014
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
13015
|
+
onSubmit,
|
|
13016
|
+
children: [
|
|
13017
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
13018
|
+
Form$2.Field,
|
|
13019
|
+
{
|
|
13020
|
+
control: form.control,
|
|
13021
|
+
name: "email",
|
|
13022
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13023
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
|
|
13024
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13025
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13026
|
+
] })
|
|
13027
|
+
}
|
|
13028
|
+
) }),
|
|
13029
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13030
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
13031
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
13032
|
+
] }) })
|
|
13033
|
+
]
|
|
13034
|
+
}
|
|
13035
|
+
) });
|
|
13036
|
+
};
|
|
13037
|
+
const schema = objectType({
|
|
13038
|
+
email: stringType().email()
|
|
13039
|
+
});
|
|
13040
13040
|
const widgetModule = { widgets: [] };
|
|
13041
13041
|
const routeModule = {
|
|
13042
13042
|
routes: [
|
|
@@ -13061,10 +13061,6 @@ const routeModule = {
|
|
|
13061
13061
|
Component: BillingAddress,
|
|
13062
13062
|
path: "/draft-orders/:id/billing-address"
|
|
13063
13063
|
},
|
|
13064
|
-
{
|
|
13065
|
-
Component: Email,
|
|
13066
|
-
path: "/draft-orders/:id/email"
|
|
13067
|
-
},
|
|
13068
13064
|
{
|
|
13069
13065
|
Component: CustomItems,
|
|
13070
13066
|
path: "/draft-orders/:id/custom-items"
|
|
@@ -13085,17 +13081,21 @@ const routeModule = {
|
|
|
13085
13081
|
Component: SalesChannel,
|
|
13086
13082
|
path: "/draft-orders/:id/sales-channel"
|
|
13087
13083
|
},
|
|
13088
|
-
{
|
|
13089
|
-
Component: ShippingAddress,
|
|
13090
|
-
path: "/draft-orders/:id/shipping-address"
|
|
13091
|
-
},
|
|
13092
13084
|
{
|
|
13093
13085
|
Component: Shipping,
|
|
13094
13086
|
path: "/draft-orders/:id/shipping"
|
|
13095
13087
|
},
|
|
13088
|
+
{
|
|
13089
|
+
Component: ShippingAddress,
|
|
13090
|
+
path: "/draft-orders/:id/shipping-address"
|
|
13091
|
+
},
|
|
13096
13092
|
{
|
|
13097
13093
|
Component: TransferOwnership,
|
|
13098
13094
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13095
|
+
},
|
|
13096
|
+
{
|
|
13097
|
+
Component: Email,
|
|
13098
|
+
path: "/draft-orders/:id/email"
|
|
13099
13099
|
}
|
|
13100
13100
|
]
|
|
13101
13101
|
}
|