@medusajs/draft-order 2.10.2-preview-20250903090152 → 2.10.2-preview-20250903120201
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 +450 -450
- package/.medusa/server/src/admin/index.mjs +450 -450
- package/package.json +16 -16
|
@@ -9560,6 +9560,196 @@ const ID = () => {
|
|
|
9560
9560
|
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
9561
9561
|
] });
|
|
9562
9562
|
};
|
|
9563
|
+
const BillingAddress = () => {
|
|
9564
|
+
const { id } = reactRouterDom.useParams();
|
|
9565
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
9566
|
+
fields: "+billing_address"
|
|
9567
|
+
});
|
|
9568
|
+
if (isError) {
|
|
9569
|
+
throw error;
|
|
9570
|
+
}
|
|
9571
|
+
const isReady = !isPending && !!order;
|
|
9572
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9573
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
9574
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
|
|
9575
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
9576
|
+
] }),
|
|
9577
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
|
|
9578
|
+
] });
|
|
9579
|
+
};
|
|
9580
|
+
const BillingAddressForm = ({ order }) => {
|
|
9581
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
9582
|
+
const form = reactHookForm.useForm({
|
|
9583
|
+
defaultValues: {
|
|
9584
|
+
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
9585
|
+
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
9586
|
+
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
9587
|
+
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
9588
|
+
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
9589
|
+
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
9590
|
+
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
9591
|
+
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
9592
|
+
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9593
|
+
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9594
|
+
},
|
|
9595
|
+
resolver: zod.zodResolver(schema$5)
|
|
9596
|
+
});
|
|
9597
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9598
|
+
const { handleSuccess } = useRouteModal();
|
|
9599
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
9600
|
+
await mutateAsync(
|
|
9601
|
+
{ billing_address: data },
|
|
9602
|
+
{
|
|
9603
|
+
onSuccess: () => {
|
|
9604
|
+
handleSuccess();
|
|
9605
|
+
},
|
|
9606
|
+
onError: (error) => {
|
|
9607
|
+
ui.toast.error(error.message);
|
|
9608
|
+
}
|
|
9609
|
+
}
|
|
9610
|
+
);
|
|
9611
|
+
});
|
|
9612
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9613
|
+
KeyboundForm,
|
|
9614
|
+
{
|
|
9615
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
9616
|
+
onSubmit,
|
|
9617
|
+
children: [
|
|
9618
|
+
/* @__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: [
|
|
9619
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9620
|
+
Form$2.Field,
|
|
9621
|
+
{
|
|
9622
|
+
control: form.control,
|
|
9623
|
+
name: "country_code",
|
|
9624
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9625
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
|
|
9626
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
9627
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9628
|
+
] })
|
|
9629
|
+
}
|
|
9630
|
+
),
|
|
9631
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9632
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9633
|
+
Form$2.Field,
|
|
9634
|
+
{
|
|
9635
|
+
control: form.control,
|
|
9636
|
+
name: "first_name",
|
|
9637
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9638
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
9639
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9640
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9641
|
+
] })
|
|
9642
|
+
}
|
|
9643
|
+
),
|
|
9644
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9645
|
+
Form$2.Field,
|
|
9646
|
+
{
|
|
9647
|
+
control: form.control,
|
|
9648
|
+
name: "last_name",
|
|
9649
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9650
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
9651
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9652
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9653
|
+
] })
|
|
9654
|
+
}
|
|
9655
|
+
)
|
|
9656
|
+
] }),
|
|
9657
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9658
|
+
Form$2.Field,
|
|
9659
|
+
{
|
|
9660
|
+
control: form.control,
|
|
9661
|
+
name: "company",
|
|
9662
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9663
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
9664
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9665
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9666
|
+
] })
|
|
9667
|
+
}
|
|
9668
|
+
),
|
|
9669
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9670
|
+
Form$2.Field,
|
|
9671
|
+
{
|
|
9672
|
+
control: form.control,
|
|
9673
|
+
name: "address_1",
|
|
9674
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9675
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
9676
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9677
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9678
|
+
] })
|
|
9679
|
+
}
|
|
9680
|
+
),
|
|
9681
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9682
|
+
Form$2.Field,
|
|
9683
|
+
{
|
|
9684
|
+
control: form.control,
|
|
9685
|
+
name: "address_2",
|
|
9686
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9687
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
9688
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9689
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9690
|
+
] })
|
|
9691
|
+
}
|
|
9692
|
+
),
|
|
9693
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9694
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9695
|
+
Form$2.Field,
|
|
9696
|
+
{
|
|
9697
|
+
control: form.control,
|
|
9698
|
+
name: "postal_code",
|
|
9699
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9700
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
9701
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9702
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9703
|
+
] })
|
|
9704
|
+
}
|
|
9705
|
+
),
|
|
9706
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9707
|
+
Form$2.Field,
|
|
9708
|
+
{
|
|
9709
|
+
control: form.control,
|
|
9710
|
+
name: "city",
|
|
9711
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9712
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
9713
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9714
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9715
|
+
] })
|
|
9716
|
+
}
|
|
9717
|
+
)
|
|
9718
|
+
] }),
|
|
9719
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9720
|
+
Form$2.Field,
|
|
9721
|
+
{
|
|
9722
|
+
control: form.control,
|
|
9723
|
+
name: "province",
|
|
9724
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9725
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
9726
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9727
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9728
|
+
] })
|
|
9729
|
+
}
|
|
9730
|
+
),
|
|
9731
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9732
|
+
Form$2.Field,
|
|
9733
|
+
{
|
|
9734
|
+
control: form.control,
|
|
9735
|
+
name: "phone",
|
|
9736
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9737
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
9738
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9739
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9740
|
+
] })
|
|
9741
|
+
}
|
|
9742
|
+
)
|
|
9743
|
+
] }) }),
|
|
9744
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9745
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9746
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9747
|
+
] }) })
|
|
9748
|
+
]
|
|
9749
|
+
}
|
|
9750
|
+
) });
|
|
9751
|
+
};
|
|
9752
|
+
const schema$5 = addressSchema;
|
|
9563
9753
|
const CustomItems = () => {
|
|
9564
9754
|
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9565
9755
|
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
@@ -9568,7 +9758,7 @@ const CustomItems = () => {
|
|
|
9568
9758
|
};
|
|
9569
9759
|
const CustomItemsForm = () => {
|
|
9570
9760
|
const form = reactHookForm.useForm({
|
|
9571
|
-
resolver: zod.zodResolver(schema$
|
|
9761
|
+
resolver: zod.zodResolver(schema$4)
|
|
9572
9762
|
});
|
|
9573
9763
|
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9574
9764
|
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
@@ -9578,7 +9768,7 @@ const CustomItemsForm = () => {
|
|
|
9578
9768
|
] }) })
|
|
9579
9769
|
] }) });
|
|
9580
9770
|
};
|
|
9581
|
-
const schema$
|
|
9771
|
+
const schema$4 = objectType({
|
|
9582
9772
|
email: stringType().email()
|
|
9583
9773
|
});
|
|
9584
9774
|
const Email = () => {
|
|
@@ -9603,7 +9793,7 @@ const EmailForm = ({ order }) => {
|
|
|
9603
9793
|
defaultValues: {
|
|
9604
9794
|
email: order.email ?? ""
|
|
9605
9795
|
},
|
|
9606
|
-
resolver: zod.zodResolver(schema$
|
|
9796
|
+
resolver: zod.zodResolver(schema$3)
|
|
9607
9797
|
});
|
|
9608
9798
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9609
9799
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9646,7 +9836,7 @@ const EmailForm = ({ order }) => {
|
|
|
9646
9836
|
}
|
|
9647
9837
|
) });
|
|
9648
9838
|
};
|
|
9649
|
-
const schema$
|
|
9839
|
+
const schema$3 = objectType({
|
|
9650
9840
|
email: stringType().email()
|
|
9651
9841
|
});
|
|
9652
9842
|
const NumberInput = React.forwardRef(
|
|
@@ -11250,67 +11440,173 @@ function getPromotionCodes(items, shippingMethods) {
|
|
|
11250
11440
|
}
|
|
11251
11441
|
return Array.from(codes);
|
|
11252
11442
|
}
|
|
11253
|
-
const
|
|
11254
|
-
const Shipping = () => {
|
|
11255
|
-
var _a;
|
|
11443
|
+
const SalesChannel = () => {
|
|
11256
11444
|
const { id } = reactRouterDom.useParams();
|
|
11257
|
-
const {
|
|
11258
|
-
|
|
11259
|
-
});
|
|
11260
|
-
const {
|
|
11261
|
-
order: preview,
|
|
11262
|
-
isPending: isPreviewPending,
|
|
11263
|
-
isError: isPreviewError,
|
|
11264
|
-
error: previewError
|
|
11265
|
-
} = useOrderPreview(id);
|
|
11266
|
-
useInitiateOrderEdit({ preview });
|
|
11267
|
-
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11268
|
-
if (isError) {
|
|
11269
|
-
throw error;
|
|
11270
|
-
}
|
|
11271
|
-
if (isPreviewError) {
|
|
11272
|
-
throw previewError;
|
|
11273
|
-
}
|
|
11274
|
-
const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
|
|
11275
|
-
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
11276
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
11277
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
11278
|
-
/* @__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: [
|
|
11279
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
11280
|
-
/* @__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." }) })
|
|
11281
|
-
] }) }) }),
|
|
11282
|
-
/* @__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" }) }) })
|
|
11283
|
-
] }) : isReady ? /* @__PURE__ */ jsxRuntime.jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11284
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
11285
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
11286
|
-
] }) });
|
|
11287
|
-
};
|
|
11288
|
-
const ShippingForm = ({ preview, order }) => {
|
|
11289
|
-
var _a;
|
|
11290
|
-
const { setIsOpen } = useStackedModal();
|
|
11291
|
-
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
11292
|
-
const [data, setData] = React.useState(null);
|
|
11293
|
-
const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
|
|
11294
|
-
const { shipping_options } = useShippingOptions(
|
|
11445
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11446
|
+
id,
|
|
11295
11447
|
{
|
|
11296
|
-
|
|
11297
|
-
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
11448
|
+
fields: "+sales_channel_id"
|
|
11298
11449
|
},
|
|
11299
11450
|
{
|
|
11300
|
-
enabled:
|
|
11451
|
+
enabled: !!id
|
|
11301
11452
|
}
|
|
11302
11453
|
);
|
|
11303
|
-
|
|
11304
|
-
|
|
11305
|
-
|
|
11306
|
-
|
|
11307
|
-
|
|
11308
|
-
|
|
11309
|
-
|
|
11310
|
-
|
|
11311
|
-
|
|
11312
|
-
|
|
11313
|
-
|
|
11454
|
+
if (isError) {
|
|
11455
|
+
throw error;
|
|
11456
|
+
}
|
|
11457
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
11458
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11459
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
11460
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
11461
|
+
/* @__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" }) })
|
|
11462
|
+
] }),
|
|
11463
|
+
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
11464
|
+
] });
|
|
11465
|
+
};
|
|
11466
|
+
const SalesChannelForm = ({ order }) => {
|
|
11467
|
+
const form = reactHookForm.useForm({
|
|
11468
|
+
defaultValues: {
|
|
11469
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
11470
|
+
},
|
|
11471
|
+
resolver: zod.zodResolver(schema$2)
|
|
11472
|
+
});
|
|
11473
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11474
|
+
const { handleSuccess } = useRouteModal();
|
|
11475
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11476
|
+
await mutateAsync(
|
|
11477
|
+
{
|
|
11478
|
+
sales_channel_id: data.sales_channel_id
|
|
11479
|
+
},
|
|
11480
|
+
{
|
|
11481
|
+
onSuccess: () => {
|
|
11482
|
+
ui.toast.success("Sales channel updated");
|
|
11483
|
+
handleSuccess();
|
|
11484
|
+
},
|
|
11485
|
+
onError: (error) => {
|
|
11486
|
+
ui.toast.error(error.message);
|
|
11487
|
+
}
|
|
11488
|
+
}
|
|
11489
|
+
);
|
|
11490
|
+
});
|
|
11491
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11492
|
+
KeyboundForm,
|
|
11493
|
+
{
|
|
11494
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11495
|
+
onSubmit,
|
|
11496
|
+
children: [
|
|
11497
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11498
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11499
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11500
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11501
|
+
] }) })
|
|
11502
|
+
]
|
|
11503
|
+
}
|
|
11504
|
+
) });
|
|
11505
|
+
};
|
|
11506
|
+
const SalesChannelField = ({ control, order }) => {
|
|
11507
|
+
const salesChannels = useComboboxData({
|
|
11508
|
+
queryFn: async (params) => {
|
|
11509
|
+
return await sdk.admin.salesChannel.list(params);
|
|
11510
|
+
},
|
|
11511
|
+
queryKey: ["sales-channels"],
|
|
11512
|
+
getOptions: (data) => {
|
|
11513
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
11514
|
+
label: salesChannel.name,
|
|
11515
|
+
value: salesChannel.id
|
|
11516
|
+
}));
|
|
11517
|
+
},
|
|
11518
|
+
defaultValue: order.sales_channel_id || void 0
|
|
11519
|
+
});
|
|
11520
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11521
|
+
Form$2.Field,
|
|
11522
|
+
{
|
|
11523
|
+
control,
|
|
11524
|
+
name: "sales_channel_id",
|
|
11525
|
+
render: ({ field }) => {
|
|
11526
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11527
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11528
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11529
|
+
Combobox,
|
|
11530
|
+
{
|
|
11531
|
+
options: salesChannels.options,
|
|
11532
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
11533
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11534
|
+
searchValue: salesChannels.searchValue,
|
|
11535
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11536
|
+
placeholder: "Select sales channel",
|
|
11537
|
+
...field
|
|
11538
|
+
}
|
|
11539
|
+
) }),
|
|
11540
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11541
|
+
] });
|
|
11542
|
+
}
|
|
11543
|
+
}
|
|
11544
|
+
);
|
|
11545
|
+
};
|
|
11546
|
+
const schema$2 = objectType({
|
|
11547
|
+
sales_channel_id: stringType().min(1)
|
|
11548
|
+
});
|
|
11549
|
+
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11550
|
+
const Shipping = () => {
|
|
11551
|
+
var _a;
|
|
11552
|
+
const { id } = reactRouterDom.useParams();
|
|
11553
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
11554
|
+
fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
|
|
11555
|
+
});
|
|
11556
|
+
const {
|
|
11557
|
+
order: preview,
|
|
11558
|
+
isPending: isPreviewPending,
|
|
11559
|
+
isError: isPreviewError,
|
|
11560
|
+
error: previewError
|
|
11561
|
+
} = useOrderPreview(id);
|
|
11562
|
+
useInitiateOrderEdit({ preview });
|
|
11563
|
+
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11564
|
+
if (isError) {
|
|
11565
|
+
throw error;
|
|
11566
|
+
}
|
|
11567
|
+
if (isPreviewError) {
|
|
11568
|
+
throw previewError;
|
|
11569
|
+
}
|
|
11570
|
+
const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
|
|
11571
|
+
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
11572
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
11573
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
11574
|
+
/* @__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: [
|
|
11575
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
11576
|
+
/* @__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." }) })
|
|
11577
|
+
] }) }) }),
|
|
11578
|
+
/* @__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" }) }) })
|
|
11579
|
+
] }) : isReady ? /* @__PURE__ */ jsxRuntime.jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11580
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
11581
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
11582
|
+
] }) });
|
|
11583
|
+
};
|
|
11584
|
+
const ShippingForm = ({ preview, order }) => {
|
|
11585
|
+
var _a;
|
|
11586
|
+
const { setIsOpen } = useStackedModal();
|
|
11587
|
+
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
11588
|
+
const [data, setData] = React.useState(null);
|
|
11589
|
+
const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
|
|
11590
|
+
const { shipping_options } = useShippingOptions(
|
|
11591
|
+
{
|
|
11592
|
+
id: appliedShippingOptionIds,
|
|
11593
|
+
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
11594
|
+
},
|
|
11595
|
+
{
|
|
11596
|
+
enabled: appliedShippingOptionIds.length > 0
|
|
11597
|
+
}
|
|
11598
|
+
);
|
|
11599
|
+
const uniqueShippingProfiles = React.useMemo(() => {
|
|
11600
|
+
const profiles = /* @__PURE__ */ new Map();
|
|
11601
|
+
getUniqueShippingProfiles(order.items).forEach((profile) => {
|
|
11602
|
+
profiles.set(profile.id, profile);
|
|
11603
|
+
});
|
|
11604
|
+
shipping_options == null ? void 0 : shipping_options.forEach((option) => {
|
|
11605
|
+
profiles.set(option.shipping_profile_id, option.shipping_profile);
|
|
11606
|
+
});
|
|
11607
|
+
return Array.from(profiles.values());
|
|
11608
|
+
}, [order.items, shipping_options]);
|
|
11609
|
+
const { handleSuccess } = useRouteModal();
|
|
11314
11610
|
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
11315
11611
|
const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
|
|
11316
11612
|
const { mutateAsync: removeShippingMethod } = useDraftOrderRemoveShippingMethod(preview.id);
|
|
@@ -12057,46 +12353,44 @@ const CustomAmountField = ({
|
|
|
12057
12353
|
}
|
|
12058
12354
|
);
|
|
12059
12355
|
};
|
|
12060
|
-
const
|
|
12356
|
+
const TransferOwnership = () => {
|
|
12061
12357
|
const { id } = reactRouterDom.useParams();
|
|
12062
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12063
|
-
id,
|
|
12064
|
-
|
|
12065
|
-
fields: "+sales_channel_id"
|
|
12066
|
-
},
|
|
12067
|
-
{
|
|
12068
|
-
enabled: !!id
|
|
12069
|
-
}
|
|
12070
|
-
);
|
|
12358
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
12359
|
+
fields: "id,customer_id,customer.*"
|
|
12360
|
+
});
|
|
12071
12361
|
if (isError) {
|
|
12072
12362
|
throw error;
|
|
12073
12363
|
}
|
|
12074
|
-
const
|
|
12364
|
+
const isReady = !isPending && !!draft_order;
|
|
12075
12365
|
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12076
12366
|
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12077
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "
|
|
12078
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "
|
|
12367
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
|
|
12368
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Transfer the ownership of this draft order to a new customer" }) })
|
|
12079
12369
|
] }),
|
|
12080
|
-
|
|
12370
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
|
|
12081
12371
|
] });
|
|
12082
12372
|
};
|
|
12083
|
-
const
|
|
12373
|
+
const TransferOwnershipForm = ({ order }) => {
|
|
12374
|
+
var _a, _b;
|
|
12084
12375
|
const form = reactHookForm.useForm({
|
|
12085
12376
|
defaultValues: {
|
|
12086
|
-
|
|
12377
|
+
customer_id: order.customer_id || ""
|
|
12087
12378
|
},
|
|
12088
|
-
resolver: zod.zodResolver(schema$
|
|
12379
|
+
resolver: zod.zodResolver(schema$1)
|
|
12089
12380
|
});
|
|
12090
12381
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12091
12382
|
const { handleSuccess } = useRouteModal();
|
|
12383
|
+
const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
|
|
12384
|
+
const currentCustomer = order.customer ? {
|
|
12385
|
+
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
12386
|
+
value: order.customer.id
|
|
12387
|
+
} : null;
|
|
12092
12388
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
12093
12389
|
await mutateAsync(
|
|
12094
|
-
{
|
|
12095
|
-
sales_channel_id: data.sales_channel_id
|
|
12096
|
-
},
|
|
12390
|
+
{ customer_id: data.customer_id },
|
|
12097
12391
|
{
|
|
12098
12392
|
onSuccess: () => {
|
|
12099
|
-
ui.toast.success("
|
|
12393
|
+
ui.toast.success("Customer updated");
|
|
12100
12394
|
handleSuccess();
|
|
12101
12395
|
},
|
|
12102
12396
|
onError: (error) => {
|
|
@@ -12111,364 +12405,57 @@ const SalesChannelForm = ({ order }) => {
|
|
|
12111
12405
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
12112
12406
|
onSubmit,
|
|
12113
12407
|
children: [
|
|
12114
|
-
/* @__PURE__ */ jsxRuntime.
|
|
12115
|
-
|
|
12116
|
-
|
|
12408
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
12409
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsxRuntime.jsx(Illustration, {}) }),
|
|
12410
|
+
currentCustomer && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col space-y-3", children: [
|
|
12411
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
12412
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
|
|
12413
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { children: "The customer that is currently associated with this draft order." })
|
|
12414
|
+
] }),
|
|
12415
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { disabled: true, value: currentCustomer.value, children: [
|
|
12416
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, {}) }),
|
|
12417
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
|
|
12418
|
+
] })
|
|
12419
|
+
] }),
|
|
12420
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12421
|
+
CustomerField,
|
|
12422
|
+
{
|
|
12423
|
+
control: form.control,
|
|
12424
|
+
currentCustomerId: order.customer_id
|
|
12425
|
+
}
|
|
12426
|
+
)
|
|
12427
|
+
] }),
|
|
12428
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
12429
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", children: "Cancel" }) }),
|
|
12117
12430
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12118
12431
|
] }) })
|
|
12119
12432
|
]
|
|
12120
12433
|
}
|
|
12121
12434
|
) });
|
|
12122
12435
|
};
|
|
12123
|
-
const
|
|
12124
|
-
const
|
|
12436
|
+
const CustomerField = ({ control, currentCustomerId }) => {
|
|
12437
|
+
const customers = useComboboxData({
|
|
12125
12438
|
queryFn: async (params) => {
|
|
12126
|
-
return await sdk.admin.
|
|
12439
|
+
return await sdk.admin.customer.list({
|
|
12440
|
+
...params,
|
|
12441
|
+
id: currentCustomerId ? { $nin: [currentCustomerId] } : void 0
|
|
12442
|
+
});
|
|
12127
12443
|
},
|
|
12128
|
-
queryKey: ["
|
|
12444
|
+
queryKey: ["customers"],
|
|
12129
12445
|
getOptions: (data) => {
|
|
12130
|
-
return data.
|
|
12131
|
-
|
|
12132
|
-
|
|
12133
|
-
|
|
12134
|
-
|
|
12135
|
-
|
|
12446
|
+
return data.customers.map((customer) => {
|
|
12447
|
+
const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
|
|
12448
|
+
return {
|
|
12449
|
+
label: name ? `${name} (${customer.email})` : customer.email,
|
|
12450
|
+
value: customer.id
|
|
12451
|
+
};
|
|
12452
|
+
});
|
|
12453
|
+
}
|
|
12136
12454
|
});
|
|
12137
12455
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12138
12456
|
Form$2.Field,
|
|
12139
12457
|
{
|
|
12140
|
-
|
|
12141
|
-
name: "sales_channel_id",
|
|
12142
|
-
render: ({ field }) => {
|
|
12143
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12144
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
12145
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12146
|
-
Combobox,
|
|
12147
|
-
{
|
|
12148
|
-
options: salesChannels.options,
|
|
12149
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
12150
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
12151
|
-
searchValue: salesChannels.searchValue,
|
|
12152
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
12153
|
-
placeholder: "Select sales channel",
|
|
12154
|
-
...field
|
|
12155
|
-
}
|
|
12156
|
-
) }),
|
|
12157
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12158
|
-
] });
|
|
12159
|
-
}
|
|
12160
|
-
}
|
|
12161
|
-
);
|
|
12162
|
-
};
|
|
12163
|
-
const schema$3 = objectType({
|
|
12164
|
-
sales_channel_id: stringType().min(1)
|
|
12165
|
-
});
|
|
12166
|
-
const ShippingAddress = () => {
|
|
12167
|
-
const { id } = reactRouterDom.useParams();
|
|
12168
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
12169
|
-
fields: "+shipping_address"
|
|
12170
|
-
});
|
|
12171
|
-
if (isError) {
|
|
12172
|
-
throw error;
|
|
12173
|
-
}
|
|
12174
|
-
const isReady = !isPending && !!order;
|
|
12175
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12176
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12177
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
|
|
12178
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
12179
|
-
] }),
|
|
12180
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
|
|
12181
|
-
] });
|
|
12182
|
-
};
|
|
12183
|
-
const ShippingAddressForm = ({ order }) => {
|
|
12184
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12185
|
-
const form = reactHookForm.useForm({
|
|
12186
|
-
defaultValues: {
|
|
12187
|
-
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12188
|
-
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12189
|
-
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12190
|
-
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12191
|
-
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12192
|
-
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12193
|
-
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12194
|
-
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12195
|
-
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12196
|
-
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12197
|
-
},
|
|
12198
|
-
resolver: zod.zodResolver(schema$2)
|
|
12199
|
-
});
|
|
12200
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12201
|
-
const { handleSuccess } = useRouteModal();
|
|
12202
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12203
|
-
await mutateAsync(
|
|
12204
|
-
{
|
|
12205
|
-
shipping_address: {
|
|
12206
|
-
first_name: data.first_name,
|
|
12207
|
-
last_name: data.last_name,
|
|
12208
|
-
company: data.company,
|
|
12209
|
-
address_1: data.address_1,
|
|
12210
|
-
address_2: data.address_2,
|
|
12211
|
-
city: data.city,
|
|
12212
|
-
province: data.province,
|
|
12213
|
-
country_code: data.country_code,
|
|
12214
|
-
postal_code: data.postal_code,
|
|
12215
|
-
phone: data.phone
|
|
12216
|
-
}
|
|
12217
|
-
},
|
|
12218
|
-
{
|
|
12219
|
-
onSuccess: () => {
|
|
12220
|
-
handleSuccess();
|
|
12221
|
-
},
|
|
12222
|
-
onError: (error) => {
|
|
12223
|
-
ui.toast.error(error.message);
|
|
12224
|
-
}
|
|
12225
|
-
}
|
|
12226
|
-
);
|
|
12227
|
-
});
|
|
12228
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12229
|
-
KeyboundForm,
|
|
12230
|
-
{
|
|
12231
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12232
|
-
onSubmit,
|
|
12233
|
-
children: [
|
|
12234
|
-
/* @__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: [
|
|
12235
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12236
|
-
Form$2.Field,
|
|
12237
|
-
{
|
|
12238
|
-
control: form.control,
|
|
12239
|
-
name: "country_code",
|
|
12240
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12241
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
|
|
12242
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
12243
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12244
|
-
] })
|
|
12245
|
-
}
|
|
12246
|
-
),
|
|
12247
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12248
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12249
|
-
Form$2.Field,
|
|
12250
|
-
{
|
|
12251
|
-
control: form.control,
|
|
12252
|
-
name: "first_name",
|
|
12253
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12254
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
12255
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12256
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12257
|
-
] })
|
|
12258
|
-
}
|
|
12259
|
-
),
|
|
12260
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12261
|
-
Form$2.Field,
|
|
12262
|
-
{
|
|
12263
|
-
control: form.control,
|
|
12264
|
-
name: "last_name",
|
|
12265
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12266
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
12267
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12268
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12269
|
-
] })
|
|
12270
|
-
}
|
|
12271
|
-
)
|
|
12272
|
-
] }),
|
|
12273
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12274
|
-
Form$2.Field,
|
|
12275
|
-
{
|
|
12276
|
-
control: form.control,
|
|
12277
|
-
name: "company",
|
|
12278
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12279
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12280
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12281
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12282
|
-
] })
|
|
12283
|
-
}
|
|
12284
|
-
),
|
|
12285
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12286
|
-
Form$2.Field,
|
|
12287
|
-
{
|
|
12288
|
-
control: form.control,
|
|
12289
|
-
name: "address_1",
|
|
12290
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12291
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
12292
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12293
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12294
|
-
] })
|
|
12295
|
-
}
|
|
12296
|
-
),
|
|
12297
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12298
|
-
Form$2.Field,
|
|
12299
|
-
{
|
|
12300
|
-
control: form.control,
|
|
12301
|
-
name: "address_2",
|
|
12302
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12303
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12304
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12305
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12306
|
-
] })
|
|
12307
|
-
}
|
|
12308
|
-
),
|
|
12309
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12310
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12311
|
-
Form$2.Field,
|
|
12312
|
-
{
|
|
12313
|
-
control: form.control,
|
|
12314
|
-
name: "postal_code",
|
|
12315
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12316
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
12317
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12318
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12319
|
-
] })
|
|
12320
|
-
}
|
|
12321
|
-
),
|
|
12322
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12323
|
-
Form$2.Field,
|
|
12324
|
-
{
|
|
12325
|
-
control: form.control,
|
|
12326
|
-
name: "city",
|
|
12327
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12328
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
12329
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12330
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12331
|
-
] })
|
|
12332
|
-
}
|
|
12333
|
-
)
|
|
12334
|
-
] }),
|
|
12335
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12336
|
-
Form$2.Field,
|
|
12337
|
-
{
|
|
12338
|
-
control: form.control,
|
|
12339
|
-
name: "province",
|
|
12340
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12341
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
12342
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12343
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12344
|
-
] })
|
|
12345
|
-
}
|
|
12346
|
-
),
|
|
12347
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12348
|
-
Form$2.Field,
|
|
12349
|
-
{
|
|
12350
|
-
control: form.control,
|
|
12351
|
-
name: "phone",
|
|
12352
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12353
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
12354
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12355
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12356
|
-
] })
|
|
12357
|
-
}
|
|
12358
|
-
)
|
|
12359
|
-
] }) }),
|
|
12360
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12361
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12362
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12363
|
-
] }) })
|
|
12364
|
-
]
|
|
12365
|
-
}
|
|
12366
|
-
) });
|
|
12367
|
-
};
|
|
12368
|
-
const schema$2 = addressSchema;
|
|
12369
|
-
const TransferOwnership = () => {
|
|
12370
|
-
const { id } = reactRouterDom.useParams();
|
|
12371
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
12372
|
-
fields: "id,customer_id,customer.*"
|
|
12373
|
-
});
|
|
12374
|
-
if (isError) {
|
|
12375
|
-
throw error;
|
|
12376
|
-
}
|
|
12377
|
-
const isReady = !isPending && !!draft_order;
|
|
12378
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12379
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12380
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
|
|
12381
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Transfer the ownership of this draft order to a new customer" }) })
|
|
12382
|
-
] }),
|
|
12383
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
|
|
12384
|
-
] });
|
|
12385
|
-
};
|
|
12386
|
-
const TransferOwnershipForm = ({ order }) => {
|
|
12387
|
-
var _a, _b;
|
|
12388
|
-
const form = reactHookForm.useForm({
|
|
12389
|
-
defaultValues: {
|
|
12390
|
-
customer_id: order.customer_id || ""
|
|
12391
|
-
},
|
|
12392
|
-
resolver: zod.zodResolver(schema$1)
|
|
12393
|
-
});
|
|
12394
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12395
|
-
const { handleSuccess } = useRouteModal();
|
|
12396
|
-
const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
|
|
12397
|
-
const currentCustomer = order.customer ? {
|
|
12398
|
-
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
12399
|
-
value: order.customer.id
|
|
12400
|
-
} : null;
|
|
12401
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12402
|
-
await mutateAsync(
|
|
12403
|
-
{ customer_id: data.customer_id },
|
|
12404
|
-
{
|
|
12405
|
-
onSuccess: () => {
|
|
12406
|
-
ui.toast.success("Customer updated");
|
|
12407
|
-
handleSuccess();
|
|
12408
|
-
},
|
|
12409
|
-
onError: (error) => {
|
|
12410
|
-
ui.toast.error(error.message);
|
|
12411
|
-
}
|
|
12412
|
-
}
|
|
12413
|
-
);
|
|
12414
|
-
});
|
|
12415
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12416
|
-
KeyboundForm,
|
|
12417
|
-
{
|
|
12418
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12419
|
-
onSubmit,
|
|
12420
|
-
children: [
|
|
12421
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
12422
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsxRuntime.jsx(Illustration, {}) }),
|
|
12423
|
-
currentCustomer && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col space-y-3", children: [
|
|
12424
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
12425
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
|
|
12426
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { children: "The customer that is currently associated with this draft order." })
|
|
12427
|
-
] }),
|
|
12428
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { disabled: true, value: currentCustomer.value, children: [
|
|
12429
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, {}) }),
|
|
12430
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Select.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
|
|
12431
|
-
] })
|
|
12432
|
-
] }),
|
|
12433
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12434
|
-
CustomerField,
|
|
12435
|
-
{
|
|
12436
|
-
control: form.control,
|
|
12437
|
-
currentCustomerId: order.customer_id
|
|
12438
|
-
}
|
|
12439
|
-
)
|
|
12440
|
-
] }),
|
|
12441
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
12442
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", children: "Cancel" }) }),
|
|
12443
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12444
|
-
] }) })
|
|
12445
|
-
]
|
|
12446
|
-
}
|
|
12447
|
-
) });
|
|
12448
|
-
};
|
|
12449
|
-
const CustomerField = ({ control, currentCustomerId }) => {
|
|
12450
|
-
const customers = useComboboxData({
|
|
12451
|
-
queryFn: async (params) => {
|
|
12452
|
-
return await sdk.admin.customer.list({
|
|
12453
|
-
...params,
|
|
12454
|
-
id: currentCustomerId ? { $nin: [currentCustomerId] } : void 0
|
|
12455
|
-
});
|
|
12456
|
-
},
|
|
12457
|
-
queryKey: ["customers"],
|
|
12458
|
-
getOptions: (data) => {
|
|
12459
|
-
return data.customers.map((customer) => {
|
|
12460
|
-
const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
|
|
12461
|
-
return {
|
|
12462
|
-
label: name ? `${name} (${customer.email})` : customer.email,
|
|
12463
|
-
value: customer.id
|
|
12464
|
-
};
|
|
12465
|
-
});
|
|
12466
|
-
}
|
|
12467
|
-
});
|
|
12468
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12469
|
-
Form$2.Field,
|
|
12470
|
-
{
|
|
12471
|
-
name: "customer_id",
|
|
12458
|
+
name: "customer_id",
|
|
12472
12459
|
control,
|
|
12473
12460
|
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "space-y-3", children: [
|
|
12474
12461
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
@@ -12842,10 +12829,10 @@ const Illustration = () => {
|
|
|
12842
12829
|
const schema$1 = objectType({
|
|
12843
12830
|
customer_id: stringType().min(1)
|
|
12844
12831
|
});
|
|
12845
|
-
const
|
|
12832
|
+
const ShippingAddress = () => {
|
|
12846
12833
|
const { id } = reactRouterDom.useParams();
|
|
12847
12834
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
12848
|
-
fields: "+
|
|
12835
|
+
fields: "+shipping_address"
|
|
12849
12836
|
});
|
|
12850
12837
|
if (isError) {
|
|
12851
12838
|
throw error;
|
|
@@ -12853,26 +12840,26 @@ const BillingAddress = () => {
|
|
|
12853
12840
|
const isReady = !isPending && !!order;
|
|
12854
12841
|
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12855
12842
|
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12856
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit
|
|
12857
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the
|
|
12843
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
|
|
12844
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
12858
12845
|
] }),
|
|
12859
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(
|
|
12846
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
|
|
12860
12847
|
] });
|
|
12861
12848
|
};
|
|
12862
|
-
const
|
|
12849
|
+
const ShippingAddressForm = ({ order }) => {
|
|
12863
12850
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12864
12851
|
const form = reactHookForm.useForm({
|
|
12865
12852
|
defaultValues: {
|
|
12866
|
-
first_name: ((_a = order.
|
|
12867
|
-
last_name: ((_b = order.
|
|
12868
|
-
company: ((_c = order.
|
|
12869
|
-
address_1: ((_d = order.
|
|
12870
|
-
address_2: ((_e = order.
|
|
12871
|
-
city: ((_f = order.
|
|
12872
|
-
province: ((_g = order.
|
|
12873
|
-
country_code: ((_h = order.
|
|
12874
|
-
postal_code: ((_i = order.
|
|
12875
|
-
phone: ((_j = order.
|
|
12853
|
+
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12854
|
+
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12855
|
+
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12856
|
+
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12857
|
+
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12858
|
+
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12859
|
+
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12860
|
+
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12861
|
+
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12862
|
+
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12876
12863
|
},
|
|
12877
12864
|
resolver: zod.zodResolver(schema)
|
|
12878
12865
|
});
|
|
@@ -12880,7 +12867,20 @@ const BillingAddressForm = ({ order }) => {
|
|
|
12880
12867
|
const { handleSuccess } = useRouteModal();
|
|
12881
12868
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
12882
12869
|
await mutateAsync(
|
|
12883
|
-
{
|
|
12870
|
+
{
|
|
12871
|
+
shipping_address: {
|
|
12872
|
+
first_name: data.first_name,
|
|
12873
|
+
last_name: data.last_name,
|
|
12874
|
+
company: data.company,
|
|
12875
|
+
address_1: data.address_1,
|
|
12876
|
+
address_2: data.address_2,
|
|
12877
|
+
city: data.city,
|
|
12878
|
+
province: data.province,
|
|
12879
|
+
country_code: data.country_code,
|
|
12880
|
+
postal_code: data.postal_code,
|
|
12881
|
+
phone: data.phone
|
|
12882
|
+
}
|
|
12883
|
+
},
|
|
12884
12884
|
{
|
|
12885
12885
|
onSuccess: () => {
|
|
12886
12886
|
handleSuccess();
|
|
@@ -13052,6 +13052,10 @@ const routeModule = {
|
|
|
13052
13052
|
handle,
|
|
13053
13053
|
loader,
|
|
13054
13054
|
children: [
|
|
13055
|
+
{
|
|
13056
|
+
Component: BillingAddress,
|
|
13057
|
+
path: "/draft-orders/:id/billing-address"
|
|
13058
|
+
},
|
|
13055
13059
|
{
|
|
13056
13060
|
Component: CustomItems,
|
|
13057
13061
|
path: "/draft-orders/:id/custom-items"
|
|
@@ -13072,25 +13076,21 @@ const routeModule = {
|
|
|
13072
13076
|
Component: Promotions,
|
|
13073
13077
|
path: "/draft-orders/:id/promotions"
|
|
13074
13078
|
},
|
|
13075
|
-
{
|
|
13076
|
-
Component: Shipping,
|
|
13077
|
-
path: "/draft-orders/:id/shipping"
|
|
13078
|
-
},
|
|
13079
13079
|
{
|
|
13080
13080
|
Component: SalesChannel,
|
|
13081
13081
|
path: "/draft-orders/:id/sales-channel"
|
|
13082
13082
|
},
|
|
13083
13083
|
{
|
|
13084
|
-
Component:
|
|
13085
|
-
path: "/draft-orders/:id/shipping
|
|
13084
|
+
Component: Shipping,
|
|
13085
|
+
path: "/draft-orders/:id/shipping"
|
|
13086
13086
|
},
|
|
13087
13087
|
{
|
|
13088
13088
|
Component: TransferOwnership,
|
|
13089
13089
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13090
13090
|
},
|
|
13091
13091
|
{
|
|
13092
|
-
Component:
|
|
13093
|
-
path: "/draft-orders/:id/
|
|
13092
|
+
Component: ShippingAddress,
|
|
13093
|
+
path: "/draft-orders/:id/shipping-address"
|
|
13094
13094
|
}
|
|
13095
13095
|
]
|
|
13096
13096
|
}
|