@medusajs/draft-order 2.10.4-preview-20251011210159 → 2.10.4-preview-20251012000322
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 +400 -400
- package/.medusa/server/src/admin/index.mjs +400 -400
- package/package.json +16 -16
|
@@ -9567,31 +9567,10 @@ const ID = () => {
|
|
|
9567
9567
|
/* @__PURE__ */ jsx(Outlet, {})
|
|
9568
9568
|
] });
|
|
9569
9569
|
};
|
|
9570
|
-
const
|
|
9571
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9572
|
-
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
9573
|
-
/* @__PURE__ */ jsx(CustomItemsForm, {})
|
|
9574
|
-
] });
|
|
9575
|
-
};
|
|
9576
|
-
const CustomItemsForm = () => {
|
|
9577
|
-
const form = useForm({
|
|
9578
|
-
resolver: zodResolver(schema$5)
|
|
9579
|
-
});
|
|
9580
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9581
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
9582
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9583
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9584
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
|
|
9585
|
-
] }) })
|
|
9586
|
-
] }) });
|
|
9587
|
-
};
|
|
9588
|
-
const schema$5 = objectType({
|
|
9589
|
-
email: stringType().email()
|
|
9590
|
-
});
|
|
9591
|
-
const Email = () => {
|
|
9570
|
+
const BillingAddress = () => {
|
|
9592
9571
|
const { id } = useParams();
|
|
9593
9572
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
9594
|
-
fields: "+
|
|
9573
|
+
fields: "+billing_address"
|
|
9595
9574
|
});
|
|
9596
9575
|
if (isError) {
|
|
9597
9576
|
throw error;
|
|
@@ -9599,24 +9578,34 @@ const Email = () => {
|
|
|
9599
9578
|
const isReady = !isPending && !!order;
|
|
9600
9579
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9601
9580
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
9602
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit
|
|
9603
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the
|
|
9581
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
|
|
9582
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
9604
9583
|
] }),
|
|
9605
|
-
isReady && /* @__PURE__ */ jsx(
|
|
9584
|
+
isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
|
|
9606
9585
|
] });
|
|
9607
9586
|
};
|
|
9608
|
-
const
|
|
9587
|
+
const BillingAddressForm = ({ order }) => {
|
|
9588
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
9609
9589
|
const form = useForm({
|
|
9610
9590
|
defaultValues: {
|
|
9611
|
-
|
|
9591
|
+
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
9592
|
+
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
9593
|
+
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
9594
|
+
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
9595
|
+
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
9596
|
+
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
9597
|
+
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
9598
|
+
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
9599
|
+
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9600
|
+
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9612
9601
|
},
|
|
9613
|
-
resolver: zodResolver(schema$
|
|
9602
|
+
resolver: zodResolver(schema$5)
|
|
9614
9603
|
});
|
|
9615
9604
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9616
9605
|
const { handleSuccess } = useRouteModal();
|
|
9617
9606
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
9618
9607
|
await mutateAsync(
|
|
9619
|
-
{
|
|
9608
|
+
{ billing_address: data },
|
|
9620
9609
|
{
|
|
9621
9610
|
onSuccess: () => {
|
|
9622
9611
|
handleSuccess();
|
|
@@ -9633,18 +9622,132 @@ const EmailForm = ({ order }) => {
|
|
|
9633
9622
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
9634
9623
|
onSubmit,
|
|
9635
9624
|
children: [
|
|
9636
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */
|
|
9637
|
-
|
|
9638
|
-
|
|
9639
|
-
|
|
9640
|
-
|
|
9641
|
-
|
|
9642
|
-
/* @__PURE__ */
|
|
9643
|
-
|
|
9644
|
-
|
|
9645
|
-
|
|
9646
|
-
|
|
9647
|
-
|
|
9625
|
+
/* @__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: [
|
|
9626
|
+
/* @__PURE__ */ jsx(
|
|
9627
|
+
Form$2.Field,
|
|
9628
|
+
{
|
|
9629
|
+
control: form.control,
|
|
9630
|
+
name: "country_code",
|
|
9631
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9632
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
9633
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
9634
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9635
|
+
] })
|
|
9636
|
+
}
|
|
9637
|
+
),
|
|
9638
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9639
|
+
/* @__PURE__ */ jsx(
|
|
9640
|
+
Form$2.Field,
|
|
9641
|
+
{
|
|
9642
|
+
control: form.control,
|
|
9643
|
+
name: "first_name",
|
|
9644
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9645
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
9646
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9647
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9648
|
+
] })
|
|
9649
|
+
}
|
|
9650
|
+
),
|
|
9651
|
+
/* @__PURE__ */ jsx(
|
|
9652
|
+
Form$2.Field,
|
|
9653
|
+
{
|
|
9654
|
+
control: form.control,
|
|
9655
|
+
name: "last_name",
|
|
9656
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9657
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
9658
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9659
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9660
|
+
] })
|
|
9661
|
+
}
|
|
9662
|
+
)
|
|
9663
|
+
] }),
|
|
9664
|
+
/* @__PURE__ */ jsx(
|
|
9665
|
+
Form$2.Field,
|
|
9666
|
+
{
|
|
9667
|
+
control: form.control,
|
|
9668
|
+
name: "company",
|
|
9669
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9670
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
9671
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9672
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9673
|
+
] })
|
|
9674
|
+
}
|
|
9675
|
+
),
|
|
9676
|
+
/* @__PURE__ */ jsx(
|
|
9677
|
+
Form$2.Field,
|
|
9678
|
+
{
|
|
9679
|
+
control: form.control,
|
|
9680
|
+
name: "address_1",
|
|
9681
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9682
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
9683
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9684
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9685
|
+
] })
|
|
9686
|
+
}
|
|
9687
|
+
),
|
|
9688
|
+
/* @__PURE__ */ jsx(
|
|
9689
|
+
Form$2.Field,
|
|
9690
|
+
{
|
|
9691
|
+
control: form.control,
|
|
9692
|
+
name: "address_2",
|
|
9693
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9694
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
9695
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9696
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9697
|
+
] })
|
|
9698
|
+
}
|
|
9699
|
+
),
|
|
9700
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9701
|
+
/* @__PURE__ */ jsx(
|
|
9702
|
+
Form$2.Field,
|
|
9703
|
+
{
|
|
9704
|
+
control: form.control,
|
|
9705
|
+
name: "postal_code",
|
|
9706
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9707
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
9708
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9709
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9710
|
+
] })
|
|
9711
|
+
}
|
|
9712
|
+
),
|
|
9713
|
+
/* @__PURE__ */ jsx(
|
|
9714
|
+
Form$2.Field,
|
|
9715
|
+
{
|
|
9716
|
+
control: form.control,
|
|
9717
|
+
name: "city",
|
|
9718
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9719
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
9720
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9721
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9722
|
+
] })
|
|
9723
|
+
}
|
|
9724
|
+
)
|
|
9725
|
+
] }),
|
|
9726
|
+
/* @__PURE__ */ jsx(
|
|
9727
|
+
Form$2.Field,
|
|
9728
|
+
{
|
|
9729
|
+
control: form.control,
|
|
9730
|
+
name: "province",
|
|
9731
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9732
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
9733
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9734
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9735
|
+
] })
|
|
9736
|
+
}
|
|
9737
|
+
),
|
|
9738
|
+
/* @__PURE__ */ jsx(
|
|
9739
|
+
Form$2.Field,
|
|
9740
|
+
{
|
|
9741
|
+
control: form.control,
|
|
9742
|
+
name: "phone",
|
|
9743
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9744
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
9745
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9746
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9747
|
+
] })
|
|
9748
|
+
}
|
|
9749
|
+
)
|
|
9750
|
+
] }) }),
|
|
9648
9751
|
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9649
9752
|
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9650
9753
|
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
@@ -9653,6 +9756,25 @@ const EmailForm = ({ order }) => {
|
|
|
9653
9756
|
}
|
|
9654
9757
|
) });
|
|
9655
9758
|
};
|
|
9759
|
+
const schema$5 = addressSchema;
|
|
9760
|
+
const CustomItems = () => {
|
|
9761
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9762
|
+
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
9763
|
+
/* @__PURE__ */ jsx(CustomItemsForm, {})
|
|
9764
|
+
] });
|
|
9765
|
+
};
|
|
9766
|
+
const CustomItemsForm = () => {
|
|
9767
|
+
const form = useForm({
|
|
9768
|
+
resolver: zodResolver(schema$4)
|
|
9769
|
+
});
|
|
9770
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9771
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
9772
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9773
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9774
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
|
|
9775
|
+
] }) })
|
|
9776
|
+
] }) });
|
|
9777
|
+
};
|
|
9656
9778
|
const schema$4 = objectType({
|
|
9657
9779
|
email: stringType().email()
|
|
9658
9780
|
});
|
|
@@ -11257,59 +11379,165 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11257
11379
|
}
|
|
11258
11380
|
return Array.from(promotionIds);
|
|
11259
11381
|
}
|
|
11260
|
-
const
|
|
11261
|
-
const Shipping = () => {
|
|
11262
|
-
var _a;
|
|
11382
|
+
const SalesChannel = () => {
|
|
11263
11383
|
const { id } = useParams();
|
|
11264
|
-
const {
|
|
11265
|
-
|
|
11266
|
-
});
|
|
11267
|
-
const {
|
|
11268
|
-
order: preview,
|
|
11269
|
-
isPending: isPreviewPending,
|
|
11270
|
-
isError: isPreviewError,
|
|
11271
|
-
error: previewError
|
|
11272
|
-
} = useOrderPreview(id);
|
|
11273
|
-
useInitiateOrderEdit({ preview });
|
|
11274
|
-
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11275
|
-
if (isError) {
|
|
11276
|
-
throw error;
|
|
11277
|
-
}
|
|
11278
|
-
if (isPreviewError) {
|
|
11279
|
-
throw previewError;
|
|
11280
|
-
}
|
|
11281
|
-
const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
|
|
11282
|
-
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
11283
|
-
return /* @__PURE__ */ jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
11284
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
|
|
11285
|
-
/* @__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 py-16 px-6", children: [
|
|
11286
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
|
|
11287
|
-
/* @__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." }) })
|
|
11288
|
-
] }) }) }),
|
|
11289
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
|
|
11290
|
-
] }) : isReady ? /* @__PURE__ */ jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxs("div", { children: [
|
|
11291
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
11292
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
11293
|
-
] }) });
|
|
11294
|
-
};
|
|
11295
|
-
const ShippingForm = ({ preview, order }) => {
|
|
11296
|
-
var _a;
|
|
11297
|
-
const { setIsOpen } = useStackedModal();
|
|
11298
|
-
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
11299
|
-
const [data, setData] = useState(null);
|
|
11300
|
-
const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
|
|
11301
|
-
const { shipping_options } = useShippingOptions(
|
|
11384
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11385
|
+
id,
|
|
11302
11386
|
{
|
|
11303
|
-
|
|
11304
|
-
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
11387
|
+
fields: "+sales_channel_id"
|
|
11305
11388
|
},
|
|
11306
11389
|
{
|
|
11307
|
-
enabled:
|
|
11390
|
+
enabled: !!id
|
|
11308
11391
|
}
|
|
11309
11392
|
);
|
|
11310
|
-
|
|
11311
|
-
|
|
11312
|
-
|
|
11393
|
+
if (isError) {
|
|
11394
|
+
throw error;
|
|
11395
|
+
}
|
|
11396
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
11397
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11398
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11399
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
11400
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
11401
|
+
] }),
|
|
11402
|
+
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
11403
|
+
] });
|
|
11404
|
+
};
|
|
11405
|
+
const SalesChannelForm = ({ order }) => {
|
|
11406
|
+
const form = useForm({
|
|
11407
|
+
defaultValues: {
|
|
11408
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
11409
|
+
},
|
|
11410
|
+
resolver: zodResolver(schema$3)
|
|
11411
|
+
});
|
|
11412
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11413
|
+
const { handleSuccess } = useRouteModal();
|
|
11414
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11415
|
+
await mutateAsync(
|
|
11416
|
+
{
|
|
11417
|
+
sales_channel_id: data.sales_channel_id
|
|
11418
|
+
},
|
|
11419
|
+
{
|
|
11420
|
+
onSuccess: () => {
|
|
11421
|
+
toast.success("Sales channel updated");
|
|
11422
|
+
handleSuccess();
|
|
11423
|
+
},
|
|
11424
|
+
onError: (error) => {
|
|
11425
|
+
toast.error(error.message);
|
|
11426
|
+
}
|
|
11427
|
+
}
|
|
11428
|
+
);
|
|
11429
|
+
});
|
|
11430
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11431
|
+
KeyboundForm,
|
|
11432
|
+
{
|
|
11433
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11434
|
+
onSubmit,
|
|
11435
|
+
children: [
|
|
11436
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11437
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11438
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11439
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11440
|
+
] }) })
|
|
11441
|
+
]
|
|
11442
|
+
}
|
|
11443
|
+
) });
|
|
11444
|
+
};
|
|
11445
|
+
const SalesChannelField = ({ control, order }) => {
|
|
11446
|
+
const salesChannels = useComboboxData({
|
|
11447
|
+
queryFn: async (params) => {
|
|
11448
|
+
return await sdk.admin.salesChannel.list(params);
|
|
11449
|
+
},
|
|
11450
|
+
queryKey: ["sales-channels"],
|
|
11451
|
+
getOptions: (data) => {
|
|
11452
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
11453
|
+
label: salesChannel.name,
|
|
11454
|
+
value: salesChannel.id
|
|
11455
|
+
}));
|
|
11456
|
+
},
|
|
11457
|
+
defaultValue: order.sales_channel_id || void 0
|
|
11458
|
+
});
|
|
11459
|
+
return /* @__PURE__ */ jsx(
|
|
11460
|
+
Form$2.Field,
|
|
11461
|
+
{
|
|
11462
|
+
control,
|
|
11463
|
+
name: "sales_channel_id",
|
|
11464
|
+
render: ({ field }) => {
|
|
11465
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11466
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11467
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
11468
|
+
Combobox,
|
|
11469
|
+
{
|
|
11470
|
+
options: salesChannels.options,
|
|
11471
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
11472
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11473
|
+
searchValue: salesChannels.searchValue,
|
|
11474
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11475
|
+
placeholder: "Select sales channel",
|
|
11476
|
+
...field
|
|
11477
|
+
}
|
|
11478
|
+
) }),
|
|
11479
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11480
|
+
] });
|
|
11481
|
+
}
|
|
11482
|
+
}
|
|
11483
|
+
);
|
|
11484
|
+
};
|
|
11485
|
+
const schema$3 = objectType({
|
|
11486
|
+
sales_channel_id: stringType().min(1)
|
|
11487
|
+
});
|
|
11488
|
+
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11489
|
+
const Shipping = () => {
|
|
11490
|
+
var _a;
|
|
11491
|
+
const { id } = useParams();
|
|
11492
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
11493
|
+
fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
|
|
11494
|
+
});
|
|
11495
|
+
const {
|
|
11496
|
+
order: preview,
|
|
11497
|
+
isPending: isPreviewPending,
|
|
11498
|
+
isError: isPreviewError,
|
|
11499
|
+
error: previewError
|
|
11500
|
+
} = useOrderPreview(id);
|
|
11501
|
+
useInitiateOrderEdit({ preview });
|
|
11502
|
+
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11503
|
+
if (isError) {
|
|
11504
|
+
throw error;
|
|
11505
|
+
}
|
|
11506
|
+
if (isPreviewError) {
|
|
11507
|
+
throw previewError;
|
|
11508
|
+
}
|
|
11509
|
+
const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
|
|
11510
|
+
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
11511
|
+
return /* @__PURE__ */ jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
11512
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
|
|
11513
|
+
/* @__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 py-16 px-6", children: [
|
|
11514
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
|
|
11515
|
+
/* @__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." }) })
|
|
11516
|
+
] }) }) }),
|
|
11517
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
|
|
11518
|
+
] }) : isReady ? /* @__PURE__ */ jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxs("div", { children: [
|
|
11519
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
11520
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
11521
|
+
] }) });
|
|
11522
|
+
};
|
|
11523
|
+
const ShippingForm = ({ preview, order }) => {
|
|
11524
|
+
var _a;
|
|
11525
|
+
const { setIsOpen } = useStackedModal();
|
|
11526
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
11527
|
+
const [data, setData] = useState(null);
|
|
11528
|
+
const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
|
|
11529
|
+
const { shipping_options } = useShippingOptions(
|
|
11530
|
+
{
|
|
11531
|
+
id: appliedShippingOptionIds,
|
|
11532
|
+
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
11533
|
+
},
|
|
11534
|
+
{
|
|
11535
|
+
enabled: appliedShippingOptionIds.length > 0
|
|
11536
|
+
}
|
|
11537
|
+
);
|
|
11538
|
+
const uniqueShippingProfiles = useMemo(() => {
|
|
11539
|
+
const profiles = /* @__PURE__ */ new Map();
|
|
11540
|
+
getUniqueShippingProfiles(order.items).forEach((profile) => {
|
|
11313
11541
|
profiles.set(profile.id, profile);
|
|
11314
11542
|
});
|
|
11315
11543
|
shipping_options == null ? void 0 : shipping_options.forEach((option) => {
|
|
@@ -12064,112 +12292,6 @@ const CustomAmountField = ({
|
|
|
12064
12292
|
}
|
|
12065
12293
|
);
|
|
12066
12294
|
};
|
|
12067
|
-
const SalesChannel = () => {
|
|
12068
|
-
const { id } = useParams();
|
|
12069
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12070
|
-
id,
|
|
12071
|
-
{
|
|
12072
|
-
fields: "+sales_channel_id"
|
|
12073
|
-
},
|
|
12074
|
-
{
|
|
12075
|
-
enabled: !!id
|
|
12076
|
-
}
|
|
12077
|
-
);
|
|
12078
|
-
if (isError) {
|
|
12079
|
-
throw error;
|
|
12080
|
-
}
|
|
12081
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
12082
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12083
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12084
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
12085
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
12086
|
-
] }),
|
|
12087
|
-
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
12088
|
-
] });
|
|
12089
|
-
};
|
|
12090
|
-
const SalesChannelForm = ({ order }) => {
|
|
12091
|
-
const form = useForm({
|
|
12092
|
-
defaultValues: {
|
|
12093
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
12094
|
-
},
|
|
12095
|
-
resolver: zodResolver(schema$3)
|
|
12096
|
-
});
|
|
12097
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12098
|
-
const { handleSuccess } = useRouteModal();
|
|
12099
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12100
|
-
await mutateAsync(
|
|
12101
|
-
{
|
|
12102
|
-
sales_channel_id: data.sales_channel_id
|
|
12103
|
-
},
|
|
12104
|
-
{
|
|
12105
|
-
onSuccess: () => {
|
|
12106
|
-
toast.success("Sales channel updated");
|
|
12107
|
-
handleSuccess();
|
|
12108
|
-
},
|
|
12109
|
-
onError: (error) => {
|
|
12110
|
-
toast.error(error.message);
|
|
12111
|
-
}
|
|
12112
|
-
}
|
|
12113
|
-
);
|
|
12114
|
-
});
|
|
12115
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12116
|
-
KeyboundForm,
|
|
12117
|
-
{
|
|
12118
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12119
|
-
onSubmit,
|
|
12120
|
-
children: [
|
|
12121
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12122
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12123
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12124
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12125
|
-
] }) })
|
|
12126
|
-
]
|
|
12127
|
-
}
|
|
12128
|
-
) });
|
|
12129
|
-
};
|
|
12130
|
-
const SalesChannelField = ({ control, order }) => {
|
|
12131
|
-
const salesChannels = useComboboxData({
|
|
12132
|
-
queryFn: async (params) => {
|
|
12133
|
-
return await sdk.admin.salesChannel.list(params);
|
|
12134
|
-
},
|
|
12135
|
-
queryKey: ["sales-channels"],
|
|
12136
|
-
getOptions: (data) => {
|
|
12137
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
12138
|
-
label: salesChannel.name,
|
|
12139
|
-
value: salesChannel.id
|
|
12140
|
-
}));
|
|
12141
|
-
},
|
|
12142
|
-
defaultValue: order.sales_channel_id || void 0
|
|
12143
|
-
});
|
|
12144
|
-
return /* @__PURE__ */ jsx(
|
|
12145
|
-
Form$2.Field,
|
|
12146
|
-
{
|
|
12147
|
-
control,
|
|
12148
|
-
name: "sales_channel_id",
|
|
12149
|
-
render: ({ field }) => {
|
|
12150
|
-
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12151
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
12152
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
12153
|
-
Combobox,
|
|
12154
|
-
{
|
|
12155
|
-
options: salesChannels.options,
|
|
12156
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
12157
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
12158
|
-
searchValue: salesChannels.searchValue,
|
|
12159
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
12160
|
-
placeholder: "Select sales channel",
|
|
12161
|
-
...field
|
|
12162
|
-
}
|
|
12163
|
-
) }),
|
|
12164
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12165
|
-
] });
|
|
12166
|
-
}
|
|
12167
|
-
}
|
|
12168
|
-
);
|
|
12169
|
-
};
|
|
12170
|
-
const schema$3 = objectType({
|
|
12171
|
-
sales_channel_id: stringType().min(1)
|
|
12172
|
-
});
|
|
12173
12295
|
const ShippingAddress = () => {
|
|
12174
12296
|
const { id } = useParams();
|
|
12175
12297
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -12373,7 +12495,75 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12373
12495
|
) });
|
|
12374
12496
|
};
|
|
12375
12497
|
const schema$2 = addressSchema;
|
|
12376
|
-
const
|
|
12498
|
+
const Email = () => {
|
|
12499
|
+
const { id } = useParams();
|
|
12500
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
12501
|
+
fields: "+email"
|
|
12502
|
+
});
|
|
12503
|
+
if (isError) {
|
|
12504
|
+
throw error;
|
|
12505
|
+
}
|
|
12506
|
+
const isReady = !isPending && !!order;
|
|
12507
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12508
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12509
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
|
|
12510
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
12511
|
+
] }),
|
|
12512
|
+
isReady && /* @__PURE__ */ jsx(EmailForm, { order })
|
|
12513
|
+
] });
|
|
12514
|
+
};
|
|
12515
|
+
const EmailForm = ({ order }) => {
|
|
12516
|
+
const form = useForm({
|
|
12517
|
+
defaultValues: {
|
|
12518
|
+
email: order.email ?? ""
|
|
12519
|
+
},
|
|
12520
|
+
resolver: zodResolver(schema$1)
|
|
12521
|
+
});
|
|
12522
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12523
|
+
const { handleSuccess } = useRouteModal();
|
|
12524
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12525
|
+
await mutateAsync(
|
|
12526
|
+
{ email: data.email },
|
|
12527
|
+
{
|
|
12528
|
+
onSuccess: () => {
|
|
12529
|
+
handleSuccess();
|
|
12530
|
+
},
|
|
12531
|
+
onError: (error) => {
|
|
12532
|
+
toast.error(error.message);
|
|
12533
|
+
}
|
|
12534
|
+
}
|
|
12535
|
+
);
|
|
12536
|
+
});
|
|
12537
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12538
|
+
KeyboundForm,
|
|
12539
|
+
{
|
|
12540
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12541
|
+
onSubmit,
|
|
12542
|
+
children: [
|
|
12543
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
12544
|
+
Form$2.Field,
|
|
12545
|
+
{
|
|
12546
|
+
control: form.control,
|
|
12547
|
+
name: "email",
|
|
12548
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12549
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
|
|
12550
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12551
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12552
|
+
] })
|
|
12553
|
+
}
|
|
12554
|
+
) }),
|
|
12555
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12556
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12557
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12558
|
+
] }) })
|
|
12559
|
+
]
|
|
12560
|
+
}
|
|
12561
|
+
) });
|
|
12562
|
+
};
|
|
12563
|
+
const schema$1 = objectType({
|
|
12564
|
+
email: stringType().email()
|
|
12565
|
+
});
|
|
12566
|
+
const TransferOwnership = () => {
|
|
12377
12567
|
const { id } = useParams();
|
|
12378
12568
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
12379
12569
|
fields: "id,customer_id,customer.*"
|
|
@@ -12396,7 +12586,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12396
12586
|
defaultValues: {
|
|
12397
12587
|
customer_id: order.customer_id || ""
|
|
12398
12588
|
},
|
|
12399
|
-
resolver: zodResolver(schema
|
|
12589
|
+
resolver: zodResolver(schema)
|
|
12400
12590
|
});
|
|
12401
12591
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12402
12592
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12846,199 +13036,9 @@ const Illustration = () => {
|
|
|
12846
13036
|
}
|
|
12847
13037
|
);
|
|
12848
13038
|
};
|
|
12849
|
-
const schema
|
|
13039
|
+
const schema = objectType({
|
|
12850
13040
|
customer_id: stringType().min(1)
|
|
12851
13041
|
});
|
|
12852
|
-
const BillingAddress = () => {
|
|
12853
|
-
const { id } = useParams();
|
|
12854
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
12855
|
-
fields: "+billing_address"
|
|
12856
|
-
});
|
|
12857
|
-
if (isError) {
|
|
12858
|
-
throw error;
|
|
12859
|
-
}
|
|
12860
|
-
const isReady = !isPending && !!order;
|
|
12861
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12862
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12863
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
|
|
12864
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
12865
|
-
] }),
|
|
12866
|
-
isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
|
|
12867
|
-
] });
|
|
12868
|
-
};
|
|
12869
|
-
const BillingAddressForm = ({ order }) => {
|
|
12870
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12871
|
-
const form = useForm({
|
|
12872
|
-
defaultValues: {
|
|
12873
|
-
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12874
|
-
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12875
|
-
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
12876
|
-
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12877
|
-
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12878
|
-
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
12879
|
-
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
12880
|
-
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12881
|
-
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12882
|
-
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
12883
|
-
},
|
|
12884
|
-
resolver: zodResolver(schema)
|
|
12885
|
-
});
|
|
12886
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12887
|
-
const { handleSuccess } = useRouteModal();
|
|
12888
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12889
|
-
await mutateAsync(
|
|
12890
|
-
{ billing_address: data },
|
|
12891
|
-
{
|
|
12892
|
-
onSuccess: () => {
|
|
12893
|
-
handleSuccess();
|
|
12894
|
-
},
|
|
12895
|
-
onError: (error) => {
|
|
12896
|
-
toast.error(error.message);
|
|
12897
|
-
}
|
|
12898
|
-
}
|
|
12899
|
-
);
|
|
12900
|
-
});
|
|
12901
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12902
|
-
KeyboundForm,
|
|
12903
|
-
{
|
|
12904
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12905
|
-
onSubmit,
|
|
12906
|
-
children: [
|
|
12907
|
-
/* @__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: [
|
|
12908
|
-
/* @__PURE__ */ jsx(
|
|
12909
|
-
Form$2.Field,
|
|
12910
|
-
{
|
|
12911
|
-
control: form.control,
|
|
12912
|
-
name: "country_code",
|
|
12913
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12914
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
12915
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
12916
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12917
|
-
] })
|
|
12918
|
-
}
|
|
12919
|
-
),
|
|
12920
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12921
|
-
/* @__PURE__ */ jsx(
|
|
12922
|
-
Form$2.Field,
|
|
12923
|
-
{
|
|
12924
|
-
control: form.control,
|
|
12925
|
-
name: "first_name",
|
|
12926
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12927
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
12928
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12929
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12930
|
-
] })
|
|
12931
|
-
}
|
|
12932
|
-
),
|
|
12933
|
-
/* @__PURE__ */ jsx(
|
|
12934
|
-
Form$2.Field,
|
|
12935
|
-
{
|
|
12936
|
-
control: form.control,
|
|
12937
|
-
name: "last_name",
|
|
12938
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12939
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
12940
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12941
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12942
|
-
] })
|
|
12943
|
-
}
|
|
12944
|
-
)
|
|
12945
|
-
] }),
|
|
12946
|
-
/* @__PURE__ */ jsx(
|
|
12947
|
-
Form$2.Field,
|
|
12948
|
-
{
|
|
12949
|
-
control: form.control,
|
|
12950
|
-
name: "company",
|
|
12951
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12952
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12953
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12954
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12955
|
-
] })
|
|
12956
|
-
}
|
|
12957
|
-
),
|
|
12958
|
-
/* @__PURE__ */ jsx(
|
|
12959
|
-
Form$2.Field,
|
|
12960
|
-
{
|
|
12961
|
-
control: form.control,
|
|
12962
|
-
name: "address_1",
|
|
12963
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12964
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
12965
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12966
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12967
|
-
] })
|
|
12968
|
-
}
|
|
12969
|
-
),
|
|
12970
|
-
/* @__PURE__ */ jsx(
|
|
12971
|
-
Form$2.Field,
|
|
12972
|
-
{
|
|
12973
|
-
control: form.control,
|
|
12974
|
-
name: "address_2",
|
|
12975
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12976
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12977
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12978
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12979
|
-
] })
|
|
12980
|
-
}
|
|
12981
|
-
),
|
|
12982
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12983
|
-
/* @__PURE__ */ jsx(
|
|
12984
|
-
Form$2.Field,
|
|
12985
|
-
{
|
|
12986
|
-
control: form.control,
|
|
12987
|
-
name: "postal_code",
|
|
12988
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12989
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
12990
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12991
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12992
|
-
] })
|
|
12993
|
-
}
|
|
12994
|
-
),
|
|
12995
|
-
/* @__PURE__ */ jsx(
|
|
12996
|
-
Form$2.Field,
|
|
12997
|
-
{
|
|
12998
|
-
control: form.control,
|
|
12999
|
-
name: "city",
|
|
13000
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13001
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
13002
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13003
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13004
|
-
] })
|
|
13005
|
-
}
|
|
13006
|
-
)
|
|
13007
|
-
] }),
|
|
13008
|
-
/* @__PURE__ */ jsx(
|
|
13009
|
-
Form$2.Field,
|
|
13010
|
-
{
|
|
13011
|
-
control: form.control,
|
|
13012
|
-
name: "province",
|
|
13013
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13014
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
13015
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13016
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13017
|
-
] })
|
|
13018
|
-
}
|
|
13019
|
-
),
|
|
13020
|
-
/* @__PURE__ */ jsx(
|
|
13021
|
-
Form$2.Field,
|
|
13022
|
-
{
|
|
13023
|
-
control: form.control,
|
|
13024
|
-
name: "phone",
|
|
13025
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13026
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
13027
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13028
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13029
|
-
] })
|
|
13030
|
-
}
|
|
13031
|
-
)
|
|
13032
|
-
] }) }),
|
|
13033
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13034
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
13035
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
13036
|
-
] }) })
|
|
13037
|
-
]
|
|
13038
|
-
}
|
|
13039
|
-
) });
|
|
13040
|
-
};
|
|
13041
|
-
const schema = addressSchema;
|
|
13042
13042
|
const widgetModule = { widgets: [] };
|
|
13043
13043
|
const routeModule = {
|
|
13044
13044
|
routes: [
|
|
@@ -13060,12 +13060,12 @@ const routeModule = {
|
|
|
13060
13060
|
loader,
|
|
13061
13061
|
children: [
|
|
13062
13062
|
{
|
|
13063
|
-
Component:
|
|
13064
|
-
path: "/draft-orders/:id/
|
|
13063
|
+
Component: BillingAddress,
|
|
13064
|
+
path: "/draft-orders/:id/billing-address"
|
|
13065
13065
|
},
|
|
13066
13066
|
{
|
|
13067
|
-
Component:
|
|
13068
|
-
path: "/draft-orders/:id/
|
|
13067
|
+
Component: CustomItems,
|
|
13068
|
+
path: "/draft-orders/:id/custom-items"
|
|
13069
13069
|
},
|
|
13070
13070
|
{
|
|
13071
13071
|
Component: Items,
|
|
@@ -13079,25 +13079,25 @@ const routeModule = {
|
|
|
13079
13079
|
Component: Promotions,
|
|
13080
13080
|
path: "/draft-orders/:id/promotions"
|
|
13081
13081
|
},
|
|
13082
|
-
{
|
|
13083
|
-
Component: Shipping,
|
|
13084
|
-
path: "/draft-orders/:id/shipping"
|
|
13085
|
-
},
|
|
13086
13082
|
{
|
|
13087
13083
|
Component: SalesChannel,
|
|
13088
13084
|
path: "/draft-orders/:id/sales-channel"
|
|
13089
13085
|
},
|
|
13086
|
+
{
|
|
13087
|
+
Component: Shipping,
|
|
13088
|
+
path: "/draft-orders/:id/shipping"
|
|
13089
|
+
},
|
|
13090
13090
|
{
|
|
13091
13091
|
Component: ShippingAddress,
|
|
13092
13092
|
path: "/draft-orders/:id/shipping-address"
|
|
13093
13093
|
},
|
|
13094
13094
|
{
|
|
13095
|
-
Component:
|
|
13096
|
-
path: "/draft-orders/:id/
|
|
13095
|
+
Component: Email,
|
|
13096
|
+
path: "/draft-orders/:id/email"
|
|
13097
13097
|
},
|
|
13098
13098
|
{
|
|
13099
|
-
Component:
|
|
13100
|
-
path: "/draft-orders/:id/
|
|
13099
|
+
Component: TransferOwnership,
|
|
13100
|
+
path: "/draft-orders/:id/transfer-ownership"
|
|
13101
13101
|
}
|
|
13102
13102
|
]
|
|
13103
13103
|
}
|