@medusajs/draft-order 2.10.2-preview-20250911101351 → 2.10.2-preview-20250911120205
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 +451 -451
- package/.medusa/server/src/admin/index.mjs +451 -451
- package/package.json +16 -16
|
@@ -9573,196 +9573,6 @@ const ID = () => {
|
|
|
9573
9573
|
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
9574
9574
|
] });
|
|
9575
9575
|
};
|
|
9576
|
-
const BillingAddress = () => {
|
|
9577
|
-
const { id } = reactRouterDom.useParams();
|
|
9578
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
9579
|
-
fields: "+billing_address"
|
|
9580
|
-
});
|
|
9581
|
-
if (isError) {
|
|
9582
|
-
throw error;
|
|
9583
|
-
}
|
|
9584
|
-
const isReady = !isPending && !!order;
|
|
9585
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9586
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
9587
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
|
|
9588
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
9589
|
-
] }),
|
|
9590
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
|
|
9591
|
-
] });
|
|
9592
|
-
};
|
|
9593
|
-
const BillingAddressForm = ({ order }) => {
|
|
9594
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
9595
|
-
const form = reactHookForm.useForm({
|
|
9596
|
-
defaultValues: {
|
|
9597
|
-
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
9598
|
-
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
9599
|
-
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
9600
|
-
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
9601
|
-
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
9602
|
-
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
9603
|
-
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
9604
|
-
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
9605
|
-
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9606
|
-
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9607
|
-
},
|
|
9608
|
-
resolver: zod.zodResolver(schema$5)
|
|
9609
|
-
});
|
|
9610
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9611
|
-
const { handleSuccess } = useRouteModal();
|
|
9612
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
9613
|
-
await mutateAsync(
|
|
9614
|
-
{ billing_address: data },
|
|
9615
|
-
{
|
|
9616
|
-
onSuccess: () => {
|
|
9617
|
-
handleSuccess();
|
|
9618
|
-
},
|
|
9619
|
-
onError: (error) => {
|
|
9620
|
-
ui.toast.error(error.message);
|
|
9621
|
-
}
|
|
9622
|
-
}
|
|
9623
|
-
);
|
|
9624
|
-
});
|
|
9625
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9626
|
-
KeyboundForm,
|
|
9627
|
-
{
|
|
9628
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
9629
|
-
onSubmit,
|
|
9630
|
-
children: [
|
|
9631
|
-
/* @__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: [
|
|
9632
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9633
|
-
Form$2.Field,
|
|
9634
|
-
{
|
|
9635
|
-
control: form.control,
|
|
9636
|
-
name: "country_code",
|
|
9637
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9638
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
|
|
9639
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
9640
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9641
|
-
] })
|
|
9642
|
-
}
|
|
9643
|
-
),
|
|
9644
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9645
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9646
|
-
Form$2.Field,
|
|
9647
|
-
{
|
|
9648
|
-
control: form.control,
|
|
9649
|
-
name: "first_name",
|
|
9650
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9651
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
9652
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9653
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9654
|
-
] })
|
|
9655
|
-
}
|
|
9656
|
-
),
|
|
9657
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9658
|
-
Form$2.Field,
|
|
9659
|
-
{
|
|
9660
|
-
control: form.control,
|
|
9661
|
-
name: "last_name",
|
|
9662
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9663
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
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
|
-
] }),
|
|
9670
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9671
|
-
Form$2.Field,
|
|
9672
|
-
{
|
|
9673
|
-
control: form.control,
|
|
9674
|
-
name: "company",
|
|
9675
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9676
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
9677
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9678
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9679
|
-
] })
|
|
9680
|
-
}
|
|
9681
|
-
),
|
|
9682
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9683
|
-
Form$2.Field,
|
|
9684
|
-
{
|
|
9685
|
-
control: form.control,
|
|
9686
|
-
name: "address_1",
|
|
9687
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9688
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
9689
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9690
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9691
|
-
] })
|
|
9692
|
-
}
|
|
9693
|
-
),
|
|
9694
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9695
|
-
Form$2.Field,
|
|
9696
|
-
{
|
|
9697
|
-
control: form.control,
|
|
9698
|
-
name: "address_2",
|
|
9699
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9700
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
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.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9707
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9708
|
-
Form$2.Field,
|
|
9709
|
-
{
|
|
9710
|
-
control: form.control,
|
|
9711
|
-
name: "postal_code",
|
|
9712
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9713
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
9714
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9715
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9716
|
-
] })
|
|
9717
|
-
}
|
|
9718
|
-
),
|
|
9719
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9720
|
-
Form$2.Field,
|
|
9721
|
-
{
|
|
9722
|
-
control: form.control,
|
|
9723
|
-
name: "city",
|
|
9724
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9725
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
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
|
-
] }),
|
|
9732
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9733
|
-
Form$2.Field,
|
|
9734
|
-
{
|
|
9735
|
-
control: form.control,
|
|
9736
|
-
name: "province",
|
|
9737
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9738
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
9739
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9740
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9741
|
-
] })
|
|
9742
|
-
}
|
|
9743
|
-
),
|
|
9744
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9745
|
-
Form$2.Field,
|
|
9746
|
-
{
|
|
9747
|
-
control: form.control,
|
|
9748
|
-
name: "phone",
|
|
9749
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9750
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
9751
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9752
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9753
|
-
] })
|
|
9754
|
-
}
|
|
9755
|
-
)
|
|
9756
|
-
] }) }),
|
|
9757
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9758
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9759
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9760
|
-
] }) })
|
|
9761
|
-
]
|
|
9762
|
-
}
|
|
9763
|
-
) });
|
|
9764
|
-
};
|
|
9765
|
-
const schema$5 = addressSchema;
|
|
9766
9576
|
const CustomItems = () => {
|
|
9767
9577
|
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9768
9578
|
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
@@ -9771,7 +9581,7 @@ const CustomItems = () => {
|
|
|
9771
9581
|
};
|
|
9772
9582
|
const CustomItemsForm = () => {
|
|
9773
9583
|
const form = reactHookForm.useForm({
|
|
9774
|
-
resolver: zod.zodResolver(schema$
|
|
9584
|
+
resolver: zod.zodResolver(schema$5)
|
|
9775
9585
|
});
|
|
9776
9586
|
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9777
9587
|
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
@@ -9781,75 +9591,7 @@ const CustomItemsForm = () => {
|
|
|
9781
9591
|
] }) })
|
|
9782
9592
|
] }) });
|
|
9783
9593
|
};
|
|
9784
|
-
const schema$
|
|
9785
|
-
email: stringType().email()
|
|
9786
|
-
});
|
|
9787
|
-
const Email = () => {
|
|
9788
|
-
const { id } = reactRouterDom.useParams();
|
|
9789
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
9790
|
-
fields: "+email"
|
|
9791
|
-
});
|
|
9792
|
-
if (isError) {
|
|
9793
|
-
throw error;
|
|
9794
|
-
}
|
|
9795
|
-
const isReady = !isPending && !!order;
|
|
9796
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9797
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
9798
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
|
|
9799
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
9800
|
-
] }),
|
|
9801
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
|
|
9802
|
-
] });
|
|
9803
|
-
};
|
|
9804
|
-
const EmailForm = ({ order }) => {
|
|
9805
|
-
const form = reactHookForm.useForm({
|
|
9806
|
-
defaultValues: {
|
|
9807
|
-
email: order.email ?? ""
|
|
9808
|
-
},
|
|
9809
|
-
resolver: zod.zodResolver(schema$3)
|
|
9810
|
-
});
|
|
9811
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9812
|
-
const { handleSuccess } = useRouteModal();
|
|
9813
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
9814
|
-
await mutateAsync(
|
|
9815
|
-
{ email: data.email },
|
|
9816
|
-
{
|
|
9817
|
-
onSuccess: () => {
|
|
9818
|
-
handleSuccess();
|
|
9819
|
-
},
|
|
9820
|
-
onError: (error) => {
|
|
9821
|
-
ui.toast.error(error.message);
|
|
9822
|
-
}
|
|
9823
|
-
}
|
|
9824
|
-
);
|
|
9825
|
-
});
|
|
9826
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9827
|
-
KeyboundForm,
|
|
9828
|
-
{
|
|
9829
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
9830
|
-
onSubmit,
|
|
9831
|
-
children: [
|
|
9832
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9833
|
-
Form$2.Field,
|
|
9834
|
-
{
|
|
9835
|
-
control: form.control,
|
|
9836
|
-
name: "email",
|
|
9837
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9838
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
|
|
9839
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9840
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9841
|
-
] })
|
|
9842
|
-
}
|
|
9843
|
-
) }),
|
|
9844
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9845
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9846
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9847
|
-
] }) })
|
|
9848
|
-
]
|
|
9849
|
-
}
|
|
9850
|
-
) });
|
|
9851
|
-
};
|
|
9852
|
-
const schema$3 = objectType({
|
|
9594
|
+
const schema$5 = objectType({
|
|
9853
9595
|
email: stringType().email()
|
|
9854
9596
|
});
|
|
9855
9597
|
const NumberInput = React.forwardRef(
|
|
@@ -11429,136 +11171,30 @@ const formatPercentage = (value, isPercentageValue = false) => {
|
|
|
11429
11171
|
if (!isPercentageValue) {
|
|
11430
11172
|
val = val / 100;
|
|
11431
11173
|
}
|
|
11432
|
-
return formatter.format(val);
|
|
11433
|
-
};
|
|
11434
|
-
function getPromotionIds(items, shippingMethods) {
|
|
11435
|
-
const promotionIds = /* @__PURE__ */ new Set();
|
|
11436
|
-
for (const item of items) {
|
|
11437
|
-
if (item.adjustments) {
|
|
11438
|
-
for (const adjustment of item.adjustments) {
|
|
11439
|
-
if (adjustment.promotion_id) {
|
|
11440
|
-
promotionIds.add(adjustment.promotion_id);
|
|
11441
|
-
}
|
|
11442
|
-
}
|
|
11443
|
-
}
|
|
11444
|
-
}
|
|
11445
|
-
for (const shippingMethod of shippingMethods) {
|
|
11446
|
-
if (shippingMethod.adjustments) {
|
|
11447
|
-
for (const adjustment of shippingMethod.adjustments) {
|
|
11448
|
-
if (adjustment.promotion_id) {
|
|
11449
|
-
promotionIds.add(adjustment.promotion_id);
|
|
11450
|
-
}
|
|
11451
|
-
}
|
|
11452
|
-
}
|
|
11453
|
-
}
|
|
11454
|
-
return Array.from(promotionIds);
|
|
11455
|
-
}
|
|
11456
|
-
const SalesChannel = () => {
|
|
11457
|
-
const { id } = reactRouterDom.useParams();
|
|
11458
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11459
|
-
id,
|
|
11460
|
-
{
|
|
11461
|
-
fields: "+sales_channel_id"
|
|
11462
|
-
},
|
|
11463
|
-
{
|
|
11464
|
-
enabled: !!id
|
|
11465
|
-
}
|
|
11466
|
-
);
|
|
11467
|
-
if (isError) {
|
|
11468
|
-
throw error;
|
|
11469
|
-
}
|
|
11470
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
11471
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11472
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
11473
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
11474
|
-
/* @__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" }) })
|
|
11475
|
-
] }),
|
|
11476
|
-
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
11477
|
-
] });
|
|
11478
|
-
};
|
|
11479
|
-
const SalesChannelForm = ({ order }) => {
|
|
11480
|
-
const form = reactHookForm.useForm({
|
|
11481
|
-
defaultValues: {
|
|
11482
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
11483
|
-
},
|
|
11484
|
-
resolver: zod.zodResolver(schema$2)
|
|
11485
|
-
});
|
|
11486
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11487
|
-
const { handleSuccess } = useRouteModal();
|
|
11488
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
11489
|
-
await mutateAsync(
|
|
11490
|
-
{
|
|
11491
|
-
sales_channel_id: data.sales_channel_id
|
|
11492
|
-
},
|
|
11493
|
-
{
|
|
11494
|
-
onSuccess: () => {
|
|
11495
|
-
ui.toast.success("Sales channel updated");
|
|
11496
|
-
handleSuccess();
|
|
11497
|
-
},
|
|
11498
|
-
onError: (error) => {
|
|
11499
|
-
ui.toast.error(error.message);
|
|
11500
|
-
}
|
|
11501
|
-
}
|
|
11502
|
-
);
|
|
11503
|
-
});
|
|
11504
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11505
|
-
KeyboundForm,
|
|
11506
|
-
{
|
|
11507
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
11508
|
-
onSubmit,
|
|
11509
|
-
children: [
|
|
11510
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11511
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11512
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11513
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11514
|
-
] }) })
|
|
11515
|
-
]
|
|
11516
|
-
}
|
|
11517
|
-
) });
|
|
11518
|
-
};
|
|
11519
|
-
const SalesChannelField = ({ control, order }) => {
|
|
11520
|
-
const salesChannels = useComboboxData({
|
|
11521
|
-
queryFn: async (params) => {
|
|
11522
|
-
return await sdk.admin.salesChannel.list(params);
|
|
11523
|
-
},
|
|
11524
|
-
queryKey: ["sales-channels"],
|
|
11525
|
-
getOptions: (data) => {
|
|
11526
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
11527
|
-
label: salesChannel.name,
|
|
11528
|
-
value: salesChannel.id
|
|
11529
|
-
}));
|
|
11530
|
-
},
|
|
11531
|
-
defaultValue: order.sales_channel_id || void 0
|
|
11532
|
-
});
|
|
11533
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11534
|
-
Form$2.Field,
|
|
11535
|
-
{
|
|
11536
|
-
control,
|
|
11537
|
-
name: "sales_channel_id",
|
|
11538
|
-
render: ({ field }) => {
|
|
11539
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11540
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11541
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11542
|
-
Combobox,
|
|
11543
|
-
{
|
|
11544
|
-
options: salesChannels.options,
|
|
11545
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
11546
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11547
|
-
searchValue: salesChannels.searchValue,
|
|
11548
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11549
|
-
placeholder: "Select sales channel",
|
|
11550
|
-
...field
|
|
11551
|
-
}
|
|
11552
|
-
) }),
|
|
11553
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11554
|
-
] });
|
|
11174
|
+
return formatter.format(val);
|
|
11175
|
+
};
|
|
11176
|
+
function getPromotionIds(items, shippingMethods) {
|
|
11177
|
+
const promotionIds = /* @__PURE__ */ new Set();
|
|
11178
|
+
for (const item of items) {
|
|
11179
|
+
if (item.adjustments) {
|
|
11180
|
+
for (const adjustment of item.adjustments) {
|
|
11181
|
+
if (adjustment.promotion_id) {
|
|
11182
|
+
promotionIds.add(adjustment.promotion_id);
|
|
11183
|
+
}
|
|
11555
11184
|
}
|
|
11556
11185
|
}
|
|
11557
|
-
|
|
11558
|
-
|
|
11559
|
-
|
|
11560
|
-
|
|
11561
|
-
|
|
11186
|
+
}
|
|
11187
|
+
for (const shippingMethod of shippingMethods) {
|
|
11188
|
+
if (shippingMethod.adjustments) {
|
|
11189
|
+
for (const adjustment of shippingMethod.adjustments) {
|
|
11190
|
+
if (adjustment.promotion_id) {
|
|
11191
|
+
promotionIds.add(adjustment.promotion_id);
|
|
11192
|
+
}
|
|
11193
|
+
}
|
|
11194
|
+
}
|
|
11195
|
+
}
|
|
11196
|
+
return Array.from(promotionIds);
|
|
11197
|
+
}
|
|
11562
11198
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11563
11199
|
const Shipping = () => {
|
|
11564
11200
|
var _a;
|
|
@@ -12398,7 +12034,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12398
12034
|
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12399
12035
|
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12400
12036
|
},
|
|
12401
|
-
resolver: zod.zodResolver(schema$
|
|
12037
|
+
resolver: zod.zodResolver(schema$4)
|
|
12402
12038
|
});
|
|
12403
12039
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12404
12040
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12568,7 +12204,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12568
12204
|
}
|
|
12569
12205
|
) });
|
|
12570
12206
|
};
|
|
12571
|
-
const schema$
|
|
12207
|
+
const schema$4 = addressSchema;
|
|
12572
12208
|
const TransferOwnership = () => {
|
|
12573
12209
|
const { id } = reactRouterDom.useParams();
|
|
12574
12210
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -12592,7 +12228,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12592
12228
|
defaultValues: {
|
|
12593
12229
|
customer_id: order.customer_id || ""
|
|
12594
12230
|
},
|
|
12595
|
-
resolver: zod.zodResolver(schema)
|
|
12231
|
+
resolver: zod.zodResolver(schema$3)
|
|
12596
12232
|
});
|
|
12597
12233
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12598
12234
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12982,69 +12618,433 @@ const Illustration = () => {
|
|
|
12982
12618
|
strokeLinejoin: "round"
|
|
12983
12619
|
}
|
|
12984
12620
|
) }),
|
|
12985
|
-
/* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
|
|
12986
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12987
|
-
"rect",
|
|
12621
|
+
/* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
|
|
12622
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12623
|
+
"rect",
|
|
12624
|
+
{
|
|
12625
|
+
width: "12",
|
|
12626
|
+
height: "12",
|
|
12627
|
+
fill: "white",
|
|
12628
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
|
|
12629
|
+
}
|
|
12630
|
+
) }),
|
|
12631
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12632
|
+
"rect",
|
|
12633
|
+
{
|
|
12634
|
+
width: "12",
|
|
12635
|
+
height: "12",
|
|
12636
|
+
fill: "white",
|
|
12637
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
|
|
12638
|
+
}
|
|
12639
|
+
) }),
|
|
12640
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12641
|
+
"rect",
|
|
12642
|
+
{
|
|
12643
|
+
width: "12",
|
|
12644
|
+
height: "12",
|
|
12645
|
+
fill: "white",
|
|
12646
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
|
|
12647
|
+
}
|
|
12648
|
+
) }),
|
|
12649
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12650
|
+
"rect",
|
|
12651
|
+
{
|
|
12652
|
+
width: "12",
|
|
12653
|
+
height: "12",
|
|
12654
|
+
fill: "white",
|
|
12655
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
|
|
12656
|
+
}
|
|
12657
|
+
) }),
|
|
12658
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12659
|
+
"rect",
|
|
12660
|
+
{
|
|
12661
|
+
width: "12",
|
|
12662
|
+
height: "12",
|
|
12663
|
+
fill: "white",
|
|
12664
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
|
|
12665
|
+
}
|
|
12666
|
+
) }),
|
|
12667
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12668
|
+
"rect",
|
|
12669
|
+
{
|
|
12670
|
+
width: "12",
|
|
12671
|
+
height: "12",
|
|
12672
|
+
fill: "white",
|
|
12673
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
|
|
12674
|
+
}
|
|
12675
|
+
) })
|
|
12676
|
+
] })
|
|
12677
|
+
]
|
|
12678
|
+
}
|
|
12679
|
+
);
|
|
12680
|
+
};
|
|
12681
|
+
const schema$3 = objectType({
|
|
12682
|
+
customer_id: stringType().min(1)
|
|
12683
|
+
});
|
|
12684
|
+
const SalesChannel = () => {
|
|
12685
|
+
const { id } = reactRouterDom.useParams();
|
|
12686
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12687
|
+
id,
|
|
12688
|
+
{
|
|
12689
|
+
fields: "+sales_channel_id"
|
|
12690
|
+
},
|
|
12691
|
+
{
|
|
12692
|
+
enabled: !!id
|
|
12693
|
+
}
|
|
12694
|
+
);
|
|
12695
|
+
if (isError) {
|
|
12696
|
+
throw error;
|
|
12697
|
+
}
|
|
12698
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
12699
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12700
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12701
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
12702
|
+
/* @__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" }) })
|
|
12703
|
+
] }),
|
|
12704
|
+
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
12705
|
+
] });
|
|
12706
|
+
};
|
|
12707
|
+
const SalesChannelForm = ({ order }) => {
|
|
12708
|
+
const form = reactHookForm.useForm({
|
|
12709
|
+
defaultValues: {
|
|
12710
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
12711
|
+
},
|
|
12712
|
+
resolver: zod.zodResolver(schema$2)
|
|
12713
|
+
});
|
|
12714
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12715
|
+
const { handleSuccess } = useRouteModal();
|
|
12716
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12717
|
+
await mutateAsync(
|
|
12718
|
+
{
|
|
12719
|
+
sales_channel_id: data.sales_channel_id
|
|
12720
|
+
},
|
|
12721
|
+
{
|
|
12722
|
+
onSuccess: () => {
|
|
12723
|
+
ui.toast.success("Sales channel updated");
|
|
12724
|
+
handleSuccess();
|
|
12725
|
+
},
|
|
12726
|
+
onError: (error) => {
|
|
12727
|
+
ui.toast.error(error.message);
|
|
12728
|
+
}
|
|
12729
|
+
}
|
|
12730
|
+
);
|
|
12731
|
+
});
|
|
12732
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12733
|
+
KeyboundForm,
|
|
12734
|
+
{
|
|
12735
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12736
|
+
onSubmit,
|
|
12737
|
+
children: [
|
|
12738
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12739
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12740
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12741
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12742
|
+
] }) })
|
|
12743
|
+
]
|
|
12744
|
+
}
|
|
12745
|
+
) });
|
|
12746
|
+
};
|
|
12747
|
+
const SalesChannelField = ({ control, order }) => {
|
|
12748
|
+
const salesChannels = useComboboxData({
|
|
12749
|
+
queryFn: async (params) => {
|
|
12750
|
+
return await sdk.admin.salesChannel.list(params);
|
|
12751
|
+
},
|
|
12752
|
+
queryKey: ["sales-channels"],
|
|
12753
|
+
getOptions: (data) => {
|
|
12754
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
12755
|
+
label: salesChannel.name,
|
|
12756
|
+
value: salesChannel.id
|
|
12757
|
+
}));
|
|
12758
|
+
},
|
|
12759
|
+
defaultValue: order.sales_channel_id || void 0
|
|
12760
|
+
});
|
|
12761
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12762
|
+
Form$2.Field,
|
|
12763
|
+
{
|
|
12764
|
+
control,
|
|
12765
|
+
name: "sales_channel_id",
|
|
12766
|
+
render: ({ field }) => {
|
|
12767
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12768
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
12769
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12770
|
+
Combobox,
|
|
12771
|
+
{
|
|
12772
|
+
options: salesChannels.options,
|
|
12773
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
12774
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
12775
|
+
searchValue: salesChannels.searchValue,
|
|
12776
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
12777
|
+
placeholder: "Select sales channel",
|
|
12778
|
+
...field
|
|
12779
|
+
}
|
|
12780
|
+
) }),
|
|
12781
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12782
|
+
] });
|
|
12783
|
+
}
|
|
12784
|
+
}
|
|
12785
|
+
);
|
|
12786
|
+
};
|
|
12787
|
+
const schema$2 = objectType({
|
|
12788
|
+
sales_channel_id: stringType().min(1)
|
|
12789
|
+
});
|
|
12790
|
+
const Email = () => {
|
|
12791
|
+
const { id } = reactRouterDom.useParams();
|
|
12792
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
12793
|
+
fields: "+email"
|
|
12794
|
+
});
|
|
12795
|
+
if (isError) {
|
|
12796
|
+
throw error;
|
|
12797
|
+
}
|
|
12798
|
+
const isReady = !isPending && !!order;
|
|
12799
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12800
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12801
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
|
|
12802
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
12803
|
+
] }),
|
|
12804
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
|
|
12805
|
+
] });
|
|
12806
|
+
};
|
|
12807
|
+
const EmailForm = ({ order }) => {
|
|
12808
|
+
const form = reactHookForm.useForm({
|
|
12809
|
+
defaultValues: {
|
|
12810
|
+
email: order.email ?? ""
|
|
12811
|
+
},
|
|
12812
|
+
resolver: zod.zodResolver(schema$1)
|
|
12813
|
+
});
|
|
12814
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12815
|
+
const { handleSuccess } = useRouteModal();
|
|
12816
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12817
|
+
await mutateAsync(
|
|
12818
|
+
{ email: data.email },
|
|
12819
|
+
{
|
|
12820
|
+
onSuccess: () => {
|
|
12821
|
+
handleSuccess();
|
|
12822
|
+
},
|
|
12823
|
+
onError: (error) => {
|
|
12824
|
+
ui.toast.error(error.message);
|
|
12825
|
+
}
|
|
12826
|
+
}
|
|
12827
|
+
);
|
|
12828
|
+
});
|
|
12829
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12830
|
+
KeyboundForm,
|
|
12831
|
+
{
|
|
12832
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12833
|
+
onSubmit,
|
|
12834
|
+
children: [
|
|
12835
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12836
|
+
Form$2.Field,
|
|
12837
|
+
{
|
|
12838
|
+
control: form.control,
|
|
12839
|
+
name: "email",
|
|
12840
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12841
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
|
|
12842
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12843
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12844
|
+
] })
|
|
12845
|
+
}
|
|
12846
|
+
) }),
|
|
12847
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12848
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12849
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12850
|
+
] }) })
|
|
12851
|
+
]
|
|
12852
|
+
}
|
|
12853
|
+
) });
|
|
12854
|
+
};
|
|
12855
|
+
const schema$1 = objectType({
|
|
12856
|
+
email: stringType().email()
|
|
12857
|
+
});
|
|
12858
|
+
const BillingAddress = () => {
|
|
12859
|
+
const { id } = reactRouterDom.useParams();
|
|
12860
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
12861
|
+
fields: "+billing_address"
|
|
12862
|
+
});
|
|
12863
|
+
if (isError) {
|
|
12864
|
+
throw error;
|
|
12865
|
+
}
|
|
12866
|
+
const isReady = !isPending && !!order;
|
|
12867
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12868
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12869
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
|
|
12870
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
12871
|
+
] }),
|
|
12872
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
|
|
12873
|
+
] });
|
|
12874
|
+
};
|
|
12875
|
+
const BillingAddressForm = ({ order }) => {
|
|
12876
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12877
|
+
const form = reactHookForm.useForm({
|
|
12878
|
+
defaultValues: {
|
|
12879
|
+
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12880
|
+
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12881
|
+
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
12882
|
+
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12883
|
+
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12884
|
+
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
12885
|
+
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
12886
|
+
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12887
|
+
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12888
|
+
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
12889
|
+
},
|
|
12890
|
+
resolver: zod.zodResolver(schema)
|
|
12891
|
+
});
|
|
12892
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12893
|
+
const { handleSuccess } = useRouteModal();
|
|
12894
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12895
|
+
await mutateAsync(
|
|
12896
|
+
{ billing_address: data },
|
|
12897
|
+
{
|
|
12898
|
+
onSuccess: () => {
|
|
12899
|
+
handleSuccess();
|
|
12900
|
+
},
|
|
12901
|
+
onError: (error) => {
|
|
12902
|
+
ui.toast.error(error.message);
|
|
12903
|
+
}
|
|
12904
|
+
}
|
|
12905
|
+
);
|
|
12906
|
+
});
|
|
12907
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12908
|
+
KeyboundForm,
|
|
12909
|
+
{
|
|
12910
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12911
|
+
onSubmit,
|
|
12912
|
+
children: [
|
|
12913
|
+
/* @__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: [
|
|
12914
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12915
|
+
Form$2.Field,
|
|
12988
12916
|
{
|
|
12989
|
-
|
|
12990
|
-
|
|
12991
|
-
|
|
12992
|
-
|
|
12917
|
+
control: form.control,
|
|
12918
|
+
name: "country_code",
|
|
12919
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12920
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
|
|
12921
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
12922
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12923
|
+
] })
|
|
12993
12924
|
}
|
|
12994
|
-
)
|
|
12995
|
-
/* @__PURE__ */ jsxRuntime.
|
|
12996
|
-
|
|
12925
|
+
),
|
|
12926
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12927
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12928
|
+
Form$2.Field,
|
|
12929
|
+
{
|
|
12930
|
+
control: form.control,
|
|
12931
|
+
name: "first_name",
|
|
12932
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12933
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
12934
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12935
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12936
|
+
] })
|
|
12937
|
+
}
|
|
12938
|
+
),
|
|
12939
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12940
|
+
Form$2.Field,
|
|
12941
|
+
{
|
|
12942
|
+
control: form.control,
|
|
12943
|
+
name: "last_name",
|
|
12944
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12945
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
12946
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12947
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12948
|
+
] })
|
|
12949
|
+
}
|
|
12950
|
+
)
|
|
12951
|
+
] }),
|
|
12952
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12953
|
+
Form$2.Field,
|
|
12997
12954
|
{
|
|
12998
|
-
|
|
12999
|
-
|
|
13000
|
-
|
|
13001
|
-
|
|
12955
|
+
control: form.control,
|
|
12956
|
+
name: "company",
|
|
12957
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12958
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12959
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12960
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12961
|
+
] })
|
|
13002
12962
|
}
|
|
13003
|
-
)
|
|
13004
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13005
|
-
|
|
12963
|
+
),
|
|
12964
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12965
|
+
Form$2.Field,
|
|
13006
12966
|
{
|
|
13007
|
-
|
|
13008
|
-
|
|
13009
|
-
|
|
13010
|
-
|
|
12967
|
+
control: form.control,
|
|
12968
|
+
name: "address_1",
|
|
12969
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12970
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
12971
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12972
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12973
|
+
] })
|
|
13011
12974
|
}
|
|
13012
|
-
)
|
|
13013
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13014
|
-
|
|
12975
|
+
),
|
|
12976
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12977
|
+
Form$2.Field,
|
|
13015
12978
|
{
|
|
13016
|
-
|
|
13017
|
-
|
|
13018
|
-
|
|
13019
|
-
|
|
12979
|
+
control: form.control,
|
|
12980
|
+
name: "address_2",
|
|
12981
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12982
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12983
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12984
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12985
|
+
] })
|
|
13020
12986
|
}
|
|
13021
|
-
)
|
|
13022
|
-
/* @__PURE__ */ jsxRuntime.
|
|
13023
|
-
|
|
12987
|
+
),
|
|
12988
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12989
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12990
|
+
Form$2.Field,
|
|
12991
|
+
{
|
|
12992
|
+
control: form.control,
|
|
12993
|
+
name: "postal_code",
|
|
12994
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12995
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
12996
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12997
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12998
|
+
] })
|
|
12999
|
+
}
|
|
13000
|
+
),
|
|
13001
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13002
|
+
Form$2.Field,
|
|
13003
|
+
{
|
|
13004
|
+
control: form.control,
|
|
13005
|
+
name: "city",
|
|
13006
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
13007
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
13008
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
13009
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
13010
|
+
] })
|
|
13011
|
+
}
|
|
13012
|
+
)
|
|
13013
|
+
] }),
|
|
13014
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13015
|
+
Form$2.Field,
|
|
13024
13016
|
{
|
|
13025
|
-
|
|
13026
|
-
|
|
13027
|
-
|
|
13028
|
-
|
|
13017
|
+
control: form.control,
|
|
13018
|
+
name: "province",
|
|
13019
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
13020
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
13021
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
13022
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
13023
|
+
] })
|
|
13029
13024
|
}
|
|
13030
|
-
)
|
|
13031
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13032
|
-
|
|
13025
|
+
),
|
|
13026
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13027
|
+
Form$2.Field,
|
|
13033
13028
|
{
|
|
13034
|
-
|
|
13035
|
-
|
|
13036
|
-
|
|
13037
|
-
|
|
13029
|
+
control: form.control,
|
|
13030
|
+
name: "phone",
|
|
13031
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
13032
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
13033
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
13034
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
13035
|
+
] })
|
|
13038
13036
|
}
|
|
13039
|
-
)
|
|
13040
|
-
] })
|
|
13037
|
+
)
|
|
13038
|
+
] }) }),
|
|
13039
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13040
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
13041
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
13042
|
+
] }) })
|
|
13041
13043
|
]
|
|
13042
13044
|
}
|
|
13043
|
-
);
|
|
13045
|
+
) });
|
|
13044
13046
|
};
|
|
13045
|
-
const schema =
|
|
13046
|
-
customer_id: stringType().min(1)
|
|
13047
|
-
});
|
|
13047
|
+
const schema = addressSchema;
|
|
13048
13048
|
const widgetModule = { widgets: [] };
|
|
13049
13049
|
const routeModule = {
|
|
13050
13050
|
routes: [
|
|
@@ -13065,18 +13065,10 @@ const routeModule = {
|
|
|
13065
13065
|
handle,
|
|
13066
13066
|
loader,
|
|
13067
13067
|
children: [
|
|
13068
|
-
{
|
|
13069
|
-
Component: BillingAddress,
|
|
13070
|
-
path: "/draft-orders/:id/billing-address"
|
|
13071
|
-
},
|
|
13072
13068
|
{
|
|
13073
13069
|
Component: CustomItems,
|
|
13074
13070
|
path: "/draft-orders/:id/custom-items"
|
|
13075
13071
|
},
|
|
13076
|
-
{
|
|
13077
|
-
Component: Email,
|
|
13078
|
-
path: "/draft-orders/:id/email"
|
|
13079
|
-
},
|
|
13080
13072
|
{
|
|
13081
13073
|
Component: Items,
|
|
13082
13074
|
path: "/draft-orders/:id/items"
|
|
@@ -13089,10 +13081,6 @@ const routeModule = {
|
|
|
13089
13081
|
Component: Promotions,
|
|
13090
13082
|
path: "/draft-orders/:id/promotions"
|
|
13091
13083
|
},
|
|
13092
|
-
{
|
|
13093
|
-
Component: SalesChannel,
|
|
13094
|
-
path: "/draft-orders/:id/sales-channel"
|
|
13095
|
-
},
|
|
13096
13084
|
{
|
|
13097
13085
|
Component: Shipping,
|
|
13098
13086
|
path: "/draft-orders/:id/shipping"
|
|
@@ -13104,6 +13092,18 @@ const routeModule = {
|
|
|
13104
13092
|
{
|
|
13105
13093
|
Component: TransferOwnership,
|
|
13106
13094
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13095
|
+
},
|
|
13096
|
+
{
|
|
13097
|
+
Component: SalesChannel,
|
|
13098
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13099
|
+
},
|
|
13100
|
+
{
|
|
13101
|
+
Component: Email,
|
|
13102
|
+
path: "/draft-orders/:id/email"
|
|
13103
|
+
},
|
|
13104
|
+
{
|
|
13105
|
+
Component: BillingAddress,
|
|
13106
|
+
path: "/draft-orders/:id/billing-address"
|
|
13107
13107
|
}
|
|
13108
13108
|
]
|
|
13109
13109
|
}
|