@medusajs/draft-order 2.11.2-preview-20251027210155 → 2.11.2-preview-20251028000318
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 +281 -281
- package/.medusa/server/src/admin/index.mjs +281 -281
- package/package.json +16 -16
|
@@ -9571,264 +9571,6 @@ const ID = () => {
|
|
|
9571
9571
|
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
9572
9572
|
] });
|
|
9573
9573
|
};
|
|
9574
|
-
const BillingAddress = () => {
|
|
9575
|
-
const { id } = reactRouterDom.useParams();
|
|
9576
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
9577
|
-
fields: "+billing_address"
|
|
9578
|
-
});
|
|
9579
|
-
if (isError) {
|
|
9580
|
-
throw error;
|
|
9581
|
-
}
|
|
9582
|
-
const isReady = !isPending && !!order;
|
|
9583
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9584
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
9585
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
|
|
9586
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
9587
|
-
] }),
|
|
9588
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
|
|
9589
|
-
] });
|
|
9590
|
-
};
|
|
9591
|
-
const BillingAddressForm = ({ order }) => {
|
|
9592
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
9593
|
-
const form = reactHookForm.useForm({
|
|
9594
|
-
defaultValues: {
|
|
9595
|
-
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
9596
|
-
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
9597
|
-
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
9598
|
-
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
9599
|
-
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
9600
|
-
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
9601
|
-
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
9602
|
-
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
9603
|
-
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9604
|
-
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9605
|
-
},
|
|
9606
|
-
resolver: zod.zodResolver(schema$5)
|
|
9607
|
-
});
|
|
9608
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9609
|
-
const { handleSuccess } = useRouteModal();
|
|
9610
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
9611
|
-
await mutateAsync(
|
|
9612
|
-
{ billing_address: data },
|
|
9613
|
-
{
|
|
9614
|
-
onSuccess: () => {
|
|
9615
|
-
handleSuccess();
|
|
9616
|
-
},
|
|
9617
|
-
onError: (error) => {
|
|
9618
|
-
ui.toast.error(error.message);
|
|
9619
|
-
}
|
|
9620
|
-
}
|
|
9621
|
-
);
|
|
9622
|
-
});
|
|
9623
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9624
|
-
KeyboundForm,
|
|
9625
|
-
{
|
|
9626
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
9627
|
-
onSubmit,
|
|
9628
|
-
children: [
|
|
9629
|
-
/* @__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: [
|
|
9630
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9631
|
-
Form$2.Field,
|
|
9632
|
-
{
|
|
9633
|
-
control: form.control,
|
|
9634
|
-
name: "country_code",
|
|
9635
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9636
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
|
|
9637
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
9638
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9639
|
-
] })
|
|
9640
|
-
}
|
|
9641
|
-
),
|
|
9642
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9643
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9644
|
-
Form$2.Field,
|
|
9645
|
-
{
|
|
9646
|
-
control: form.control,
|
|
9647
|
-
name: "first_name",
|
|
9648
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9649
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
9650
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9651
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9652
|
-
] })
|
|
9653
|
-
}
|
|
9654
|
-
),
|
|
9655
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9656
|
-
Form$2.Field,
|
|
9657
|
-
{
|
|
9658
|
-
control: form.control,
|
|
9659
|
-
name: "last_name",
|
|
9660
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9661
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
9662
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9663
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9664
|
-
] })
|
|
9665
|
-
}
|
|
9666
|
-
)
|
|
9667
|
-
] }),
|
|
9668
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9669
|
-
Form$2.Field,
|
|
9670
|
-
{
|
|
9671
|
-
control: form.control,
|
|
9672
|
-
name: "company",
|
|
9673
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9674
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
9675
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9676
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9677
|
-
] })
|
|
9678
|
-
}
|
|
9679
|
-
),
|
|
9680
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9681
|
-
Form$2.Field,
|
|
9682
|
-
{
|
|
9683
|
-
control: form.control,
|
|
9684
|
-
name: "address_1",
|
|
9685
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9686
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
9687
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9688
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9689
|
-
] })
|
|
9690
|
-
}
|
|
9691
|
-
),
|
|
9692
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9693
|
-
Form$2.Field,
|
|
9694
|
-
{
|
|
9695
|
-
control: form.control,
|
|
9696
|
-
name: "address_2",
|
|
9697
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9698
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
9699
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9700
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9701
|
-
] })
|
|
9702
|
-
}
|
|
9703
|
-
),
|
|
9704
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9705
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9706
|
-
Form$2.Field,
|
|
9707
|
-
{
|
|
9708
|
-
control: form.control,
|
|
9709
|
-
name: "postal_code",
|
|
9710
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9711
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
9712
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9713
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9714
|
-
] })
|
|
9715
|
-
}
|
|
9716
|
-
),
|
|
9717
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9718
|
-
Form$2.Field,
|
|
9719
|
-
{
|
|
9720
|
-
control: form.control,
|
|
9721
|
-
name: "city",
|
|
9722
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9723
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
9724
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9725
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9726
|
-
] })
|
|
9727
|
-
}
|
|
9728
|
-
)
|
|
9729
|
-
] }),
|
|
9730
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9731
|
-
Form$2.Field,
|
|
9732
|
-
{
|
|
9733
|
-
control: form.control,
|
|
9734
|
-
name: "province",
|
|
9735
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9736
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
9737
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9738
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9739
|
-
] })
|
|
9740
|
-
}
|
|
9741
|
-
),
|
|
9742
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9743
|
-
Form$2.Field,
|
|
9744
|
-
{
|
|
9745
|
-
control: form.control,
|
|
9746
|
-
name: "phone",
|
|
9747
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9748
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
9749
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9750
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9751
|
-
] })
|
|
9752
|
-
}
|
|
9753
|
-
)
|
|
9754
|
-
] }) }),
|
|
9755
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9756
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9757
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9758
|
-
] }) })
|
|
9759
|
-
]
|
|
9760
|
-
}
|
|
9761
|
-
) });
|
|
9762
|
-
};
|
|
9763
|
-
const schema$5 = addressSchema;
|
|
9764
|
-
const Email = () => {
|
|
9765
|
-
const { id } = reactRouterDom.useParams();
|
|
9766
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
9767
|
-
fields: "+email"
|
|
9768
|
-
});
|
|
9769
|
-
if (isError) {
|
|
9770
|
-
throw error;
|
|
9771
|
-
}
|
|
9772
|
-
const isReady = !isPending && !!order;
|
|
9773
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9774
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
9775
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
|
|
9776
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
9777
|
-
] }),
|
|
9778
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
|
|
9779
|
-
] });
|
|
9780
|
-
};
|
|
9781
|
-
const EmailForm = ({ order }) => {
|
|
9782
|
-
const form = reactHookForm.useForm({
|
|
9783
|
-
defaultValues: {
|
|
9784
|
-
email: order.email ?? ""
|
|
9785
|
-
},
|
|
9786
|
-
resolver: zod.zodResolver(schema$4)
|
|
9787
|
-
});
|
|
9788
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9789
|
-
const { handleSuccess } = useRouteModal();
|
|
9790
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
9791
|
-
await mutateAsync(
|
|
9792
|
-
{ email: data.email },
|
|
9793
|
-
{
|
|
9794
|
-
onSuccess: () => {
|
|
9795
|
-
handleSuccess();
|
|
9796
|
-
},
|
|
9797
|
-
onError: (error) => {
|
|
9798
|
-
ui.toast.error(error.message);
|
|
9799
|
-
}
|
|
9800
|
-
}
|
|
9801
|
-
);
|
|
9802
|
-
});
|
|
9803
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9804
|
-
KeyboundForm,
|
|
9805
|
-
{
|
|
9806
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
9807
|
-
onSubmit,
|
|
9808
|
-
children: [
|
|
9809
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9810
|
-
Form$2.Field,
|
|
9811
|
-
{
|
|
9812
|
-
control: form.control,
|
|
9813
|
-
name: "email",
|
|
9814
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9815
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
|
|
9816
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9817
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9818
|
-
] })
|
|
9819
|
-
}
|
|
9820
|
-
) }),
|
|
9821
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9822
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9823
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9824
|
-
] }) })
|
|
9825
|
-
]
|
|
9826
|
-
}
|
|
9827
|
-
) });
|
|
9828
|
-
};
|
|
9829
|
-
const schema$4 = objectType({
|
|
9830
|
-
email: stringType().email()
|
|
9831
|
-
});
|
|
9832
9574
|
const CustomItems = () => {
|
|
9833
9575
|
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9834
9576
|
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
@@ -9837,7 +9579,7 @@ const CustomItems = () => {
|
|
|
9837
9579
|
};
|
|
9838
9580
|
const CustomItemsForm = () => {
|
|
9839
9581
|
const form = reactHookForm.useForm({
|
|
9840
|
-
resolver: zod.zodResolver(schema$
|
|
9582
|
+
resolver: zod.zodResolver(schema$5)
|
|
9841
9583
|
});
|
|
9842
9584
|
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9843
9585
|
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
@@ -9847,7 +9589,7 @@ const CustomItemsForm = () => {
|
|
|
9847
9589
|
] }) })
|
|
9848
9590
|
] }) });
|
|
9849
9591
|
};
|
|
9850
|
-
const schema$
|
|
9592
|
+
const schema$5 = objectType({
|
|
9851
9593
|
email: stringType().email()
|
|
9852
9594
|
});
|
|
9853
9595
|
const NumberInput = React.forwardRef(
|
|
@@ -10809,20 +10551,88 @@ const CustomItemForm = ({ orderId, currencyCode }) => {
|
|
|
10809
10551
|
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(NumberInput, { ...field, className: "w-full" }) }) }),
|
|
10810
10552
|
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
10811
10553
|
] })
|
|
10812
|
-
] }) })
|
|
10813
|
-
}
|
|
10814
|
-
)
|
|
10815
|
-
] }) }) }),
|
|
10816
|
-
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
10817
|
-
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
10818
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "button", onClick: onSubmit, children: "Add item" })
|
|
10819
|
-
] }) })
|
|
10820
|
-
] }) }) });
|
|
10554
|
+
] }) })
|
|
10555
|
+
}
|
|
10556
|
+
)
|
|
10557
|
+
] }) }) }),
|
|
10558
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
10559
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
10560
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "button", onClick: onSubmit, children: "Add item" })
|
|
10561
|
+
] }) })
|
|
10562
|
+
] }) }) });
|
|
10563
|
+
};
|
|
10564
|
+
const customItemSchema = objectType({
|
|
10565
|
+
title: stringType().min(1),
|
|
10566
|
+
quantity: numberType(),
|
|
10567
|
+
unit_price: unionType([numberType(), stringType()])
|
|
10568
|
+
});
|
|
10569
|
+
const Email = () => {
|
|
10570
|
+
const { id } = reactRouterDom.useParams();
|
|
10571
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
10572
|
+
fields: "+email"
|
|
10573
|
+
});
|
|
10574
|
+
if (isError) {
|
|
10575
|
+
throw error;
|
|
10576
|
+
}
|
|
10577
|
+
const isReady = !isPending && !!order;
|
|
10578
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
10579
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
10580
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
|
|
10581
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
10582
|
+
] }),
|
|
10583
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
|
|
10584
|
+
] });
|
|
10585
|
+
};
|
|
10586
|
+
const EmailForm = ({ order }) => {
|
|
10587
|
+
const form = reactHookForm.useForm({
|
|
10588
|
+
defaultValues: {
|
|
10589
|
+
email: order.email ?? ""
|
|
10590
|
+
},
|
|
10591
|
+
resolver: zod.zodResolver(schema$4)
|
|
10592
|
+
});
|
|
10593
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
10594
|
+
const { handleSuccess } = useRouteModal();
|
|
10595
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
10596
|
+
await mutateAsync(
|
|
10597
|
+
{ email: data.email },
|
|
10598
|
+
{
|
|
10599
|
+
onSuccess: () => {
|
|
10600
|
+
handleSuccess();
|
|
10601
|
+
},
|
|
10602
|
+
onError: (error) => {
|
|
10603
|
+
ui.toast.error(error.message);
|
|
10604
|
+
}
|
|
10605
|
+
}
|
|
10606
|
+
);
|
|
10607
|
+
});
|
|
10608
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10609
|
+
KeyboundForm,
|
|
10610
|
+
{
|
|
10611
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
10612
|
+
onSubmit,
|
|
10613
|
+
children: [
|
|
10614
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10615
|
+
Form$2.Field,
|
|
10616
|
+
{
|
|
10617
|
+
control: form.control,
|
|
10618
|
+
name: "email",
|
|
10619
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
10620
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
|
|
10621
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
10622
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
10623
|
+
] })
|
|
10624
|
+
}
|
|
10625
|
+
) }),
|
|
10626
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
10627
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
10628
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
10629
|
+
] }) })
|
|
10630
|
+
]
|
|
10631
|
+
}
|
|
10632
|
+
) });
|
|
10821
10633
|
};
|
|
10822
|
-
const
|
|
10823
|
-
|
|
10824
|
-
quantity: numberType(),
|
|
10825
|
-
unit_price: unionType([numberType(), stringType()])
|
|
10634
|
+
const schema$4 = objectType({
|
|
10635
|
+
email: stringType().email()
|
|
10826
10636
|
});
|
|
10827
10637
|
const InlineTip = React.forwardRef(
|
|
10828
10638
|
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
@@ -11174,6 +10984,196 @@ function getHasUneditableRows(metadata) {
|
|
|
11174
10984
|
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
11175
10985
|
);
|
|
11176
10986
|
}
|
|
10987
|
+
const BillingAddress = () => {
|
|
10988
|
+
const { id } = reactRouterDom.useParams();
|
|
10989
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
10990
|
+
fields: "+billing_address"
|
|
10991
|
+
});
|
|
10992
|
+
if (isError) {
|
|
10993
|
+
throw error;
|
|
10994
|
+
}
|
|
10995
|
+
const isReady = !isPending && !!order;
|
|
10996
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
10997
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
10998
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
|
|
10999
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
11000
|
+
] }),
|
|
11001
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
|
|
11002
|
+
] });
|
|
11003
|
+
};
|
|
11004
|
+
const BillingAddressForm = ({ order }) => {
|
|
11005
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
11006
|
+
const form = reactHookForm.useForm({
|
|
11007
|
+
defaultValues: {
|
|
11008
|
+
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
11009
|
+
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
11010
|
+
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
11011
|
+
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
11012
|
+
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
11013
|
+
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
11014
|
+
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
11015
|
+
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
11016
|
+
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
11017
|
+
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
11018
|
+
},
|
|
11019
|
+
resolver: zod.zodResolver(schema$3)
|
|
11020
|
+
});
|
|
11021
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11022
|
+
const { handleSuccess } = useRouteModal();
|
|
11023
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11024
|
+
await mutateAsync(
|
|
11025
|
+
{ billing_address: data },
|
|
11026
|
+
{
|
|
11027
|
+
onSuccess: () => {
|
|
11028
|
+
handleSuccess();
|
|
11029
|
+
},
|
|
11030
|
+
onError: (error) => {
|
|
11031
|
+
ui.toast.error(error.message);
|
|
11032
|
+
}
|
|
11033
|
+
}
|
|
11034
|
+
);
|
|
11035
|
+
});
|
|
11036
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11037
|
+
KeyboundForm,
|
|
11038
|
+
{
|
|
11039
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11040
|
+
onSubmit,
|
|
11041
|
+
children: [
|
|
11042
|
+
/* @__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: [
|
|
11043
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11044
|
+
Form$2.Field,
|
|
11045
|
+
{
|
|
11046
|
+
control: form.control,
|
|
11047
|
+
name: "country_code",
|
|
11048
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11049
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
|
|
11050
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
11051
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11052
|
+
] })
|
|
11053
|
+
}
|
|
11054
|
+
),
|
|
11055
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11056
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11057
|
+
Form$2.Field,
|
|
11058
|
+
{
|
|
11059
|
+
control: form.control,
|
|
11060
|
+
name: "first_name",
|
|
11061
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11062
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
11063
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11064
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11065
|
+
] })
|
|
11066
|
+
}
|
|
11067
|
+
),
|
|
11068
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11069
|
+
Form$2.Field,
|
|
11070
|
+
{
|
|
11071
|
+
control: form.control,
|
|
11072
|
+
name: "last_name",
|
|
11073
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11074
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
11075
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11076
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11077
|
+
] })
|
|
11078
|
+
}
|
|
11079
|
+
)
|
|
11080
|
+
] }),
|
|
11081
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11082
|
+
Form$2.Field,
|
|
11083
|
+
{
|
|
11084
|
+
control: form.control,
|
|
11085
|
+
name: "company",
|
|
11086
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11087
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
11088
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11089
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11090
|
+
] })
|
|
11091
|
+
}
|
|
11092
|
+
),
|
|
11093
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11094
|
+
Form$2.Field,
|
|
11095
|
+
{
|
|
11096
|
+
control: form.control,
|
|
11097
|
+
name: "address_1",
|
|
11098
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11099
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
11100
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11101
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11102
|
+
] })
|
|
11103
|
+
}
|
|
11104
|
+
),
|
|
11105
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11106
|
+
Form$2.Field,
|
|
11107
|
+
{
|
|
11108
|
+
control: form.control,
|
|
11109
|
+
name: "address_2",
|
|
11110
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11111
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
11112
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11113
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11114
|
+
] })
|
|
11115
|
+
}
|
|
11116
|
+
),
|
|
11117
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11118
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11119
|
+
Form$2.Field,
|
|
11120
|
+
{
|
|
11121
|
+
control: form.control,
|
|
11122
|
+
name: "postal_code",
|
|
11123
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11124
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
11125
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11126
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11127
|
+
] })
|
|
11128
|
+
}
|
|
11129
|
+
),
|
|
11130
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11131
|
+
Form$2.Field,
|
|
11132
|
+
{
|
|
11133
|
+
control: form.control,
|
|
11134
|
+
name: "city",
|
|
11135
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11136
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
11137
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11138
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11139
|
+
] })
|
|
11140
|
+
}
|
|
11141
|
+
)
|
|
11142
|
+
] }),
|
|
11143
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11144
|
+
Form$2.Field,
|
|
11145
|
+
{
|
|
11146
|
+
control: form.control,
|
|
11147
|
+
name: "province",
|
|
11148
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11149
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
11150
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11151
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11152
|
+
] })
|
|
11153
|
+
}
|
|
11154
|
+
),
|
|
11155
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11156
|
+
Form$2.Field,
|
|
11157
|
+
{
|
|
11158
|
+
control: form.control,
|
|
11159
|
+
name: "phone",
|
|
11160
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11161
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
11162
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11163
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11164
|
+
] })
|
|
11165
|
+
}
|
|
11166
|
+
)
|
|
11167
|
+
] }) }),
|
|
11168
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11169
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11170
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11171
|
+
] }) })
|
|
11172
|
+
]
|
|
11173
|
+
}
|
|
11174
|
+
) });
|
|
11175
|
+
};
|
|
11176
|
+
const schema$3 = addressSchema;
|
|
11177
11177
|
const PROMOTION_QUERY_KEY = "promotions";
|
|
11178
11178
|
const promotionsQueryKeys = {
|
|
11179
11179
|
list: (query2) => [
|
|
@@ -13063,14 +13063,6 @@ const routeModule = {
|
|
|
13063
13063
|
handle,
|
|
13064
13064
|
loader,
|
|
13065
13065
|
children: [
|
|
13066
|
-
{
|
|
13067
|
-
Component: BillingAddress,
|
|
13068
|
-
path: "/draft-orders/:id/billing-address"
|
|
13069
|
-
},
|
|
13070
|
-
{
|
|
13071
|
-
Component: Email,
|
|
13072
|
-
path: "/draft-orders/:id/email"
|
|
13073
|
-
},
|
|
13074
13066
|
{
|
|
13075
13067
|
Component: CustomItems,
|
|
13076
13068
|
path: "/draft-orders/:id/custom-items"
|
|
@@ -13079,10 +13071,18 @@ const routeModule = {
|
|
|
13079
13071
|
Component: Items,
|
|
13080
13072
|
path: "/draft-orders/:id/items"
|
|
13081
13073
|
},
|
|
13074
|
+
{
|
|
13075
|
+
Component: Email,
|
|
13076
|
+
path: "/draft-orders/:id/email"
|
|
13077
|
+
},
|
|
13082
13078
|
{
|
|
13083
13079
|
Component: Metadata,
|
|
13084
13080
|
path: "/draft-orders/:id/metadata"
|
|
13085
13081
|
},
|
|
13082
|
+
{
|
|
13083
|
+
Component: BillingAddress,
|
|
13084
|
+
path: "/draft-orders/:id/billing-address"
|
|
13085
|
+
},
|
|
13086
13086
|
{
|
|
13087
13087
|
Component: Promotions,
|
|
13088
13088
|
path: "/draft-orders/:id/promotions"
|
|
@@ -9565,264 +9565,6 @@ const ID = () => {
|
|
|
9565
9565
|
/* @__PURE__ */ jsx(Outlet, {})
|
|
9566
9566
|
] });
|
|
9567
9567
|
};
|
|
9568
|
-
const BillingAddress = () => {
|
|
9569
|
-
const { id } = useParams();
|
|
9570
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
9571
|
-
fields: "+billing_address"
|
|
9572
|
-
});
|
|
9573
|
-
if (isError) {
|
|
9574
|
-
throw error;
|
|
9575
|
-
}
|
|
9576
|
-
const isReady = !isPending && !!order;
|
|
9577
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9578
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
9579
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
|
|
9580
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
9581
|
-
] }),
|
|
9582
|
-
isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
|
|
9583
|
-
] });
|
|
9584
|
-
};
|
|
9585
|
-
const BillingAddressForm = ({ order }) => {
|
|
9586
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
9587
|
-
const form = useForm({
|
|
9588
|
-
defaultValues: {
|
|
9589
|
-
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
9590
|
-
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
9591
|
-
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
9592
|
-
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
9593
|
-
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
9594
|
-
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
9595
|
-
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
9596
|
-
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
9597
|
-
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9598
|
-
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9599
|
-
},
|
|
9600
|
-
resolver: zodResolver(schema$5)
|
|
9601
|
-
});
|
|
9602
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9603
|
-
const { handleSuccess } = useRouteModal();
|
|
9604
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
9605
|
-
await mutateAsync(
|
|
9606
|
-
{ billing_address: data },
|
|
9607
|
-
{
|
|
9608
|
-
onSuccess: () => {
|
|
9609
|
-
handleSuccess();
|
|
9610
|
-
},
|
|
9611
|
-
onError: (error) => {
|
|
9612
|
-
toast.error(error.message);
|
|
9613
|
-
}
|
|
9614
|
-
}
|
|
9615
|
-
);
|
|
9616
|
-
});
|
|
9617
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
9618
|
-
KeyboundForm,
|
|
9619
|
-
{
|
|
9620
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
9621
|
-
onSubmit,
|
|
9622
|
-
children: [
|
|
9623
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
|
|
9624
|
-
/* @__PURE__ */ jsx(
|
|
9625
|
-
Form$2.Field,
|
|
9626
|
-
{
|
|
9627
|
-
control: form.control,
|
|
9628
|
-
name: "country_code",
|
|
9629
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9630
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
9631
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
9632
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9633
|
-
] })
|
|
9634
|
-
}
|
|
9635
|
-
),
|
|
9636
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9637
|
-
/* @__PURE__ */ jsx(
|
|
9638
|
-
Form$2.Field,
|
|
9639
|
-
{
|
|
9640
|
-
control: form.control,
|
|
9641
|
-
name: "first_name",
|
|
9642
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9643
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
9644
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9645
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9646
|
-
] })
|
|
9647
|
-
}
|
|
9648
|
-
),
|
|
9649
|
-
/* @__PURE__ */ jsx(
|
|
9650
|
-
Form$2.Field,
|
|
9651
|
-
{
|
|
9652
|
-
control: form.control,
|
|
9653
|
-
name: "last_name",
|
|
9654
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9655
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
9656
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9657
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9658
|
-
] })
|
|
9659
|
-
}
|
|
9660
|
-
)
|
|
9661
|
-
] }),
|
|
9662
|
-
/* @__PURE__ */ jsx(
|
|
9663
|
-
Form$2.Field,
|
|
9664
|
-
{
|
|
9665
|
-
control: form.control,
|
|
9666
|
-
name: "company",
|
|
9667
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9668
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
9669
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9670
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9671
|
-
] })
|
|
9672
|
-
}
|
|
9673
|
-
),
|
|
9674
|
-
/* @__PURE__ */ jsx(
|
|
9675
|
-
Form$2.Field,
|
|
9676
|
-
{
|
|
9677
|
-
control: form.control,
|
|
9678
|
-
name: "address_1",
|
|
9679
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9680
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
9681
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9682
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9683
|
-
] })
|
|
9684
|
-
}
|
|
9685
|
-
),
|
|
9686
|
-
/* @__PURE__ */ jsx(
|
|
9687
|
-
Form$2.Field,
|
|
9688
|
-
{
|
|
9689
|
-
control: form.control,
|
|
9690
|
-
name: "address_2",
|
|
9691
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9692
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
9693
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9694
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9695
|
-
] })
|
|
9696
|
-
}
|
|
9697
|
-
),
|
|
9698
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9699
|
-
/* @__PURE__ */ jsx(
|
|
9700
|
-
Form$2.Field,
|
|
9701
|
-
{
|
|
9702
|
-
control: form.control,
|
|
9703
|
-
name: "postal_code",
|
|
9704
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9705
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
9706
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9707
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9708
|
-
] })
|
|
9709
|
-
}
|
|
9710
|
-
),
|
|
9711
|
-
/* @__PURE__ */ jsx(
|
|
9712
|
-
Form$2.Field,
|
|
9713
|
-
{
|
|
9714
|
-
control: form.control,
|
|
9715
|
-
name: "city",
|
|
9716
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9717
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
9718
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9719
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9720
|
-
] })
|
|
9721
|
-
}
|
|
9722
|
-
)
|
|
9723
|
-
] }),
|
|
9724
|
-
/* @__PURE__ */ jsx(
|
|
9725
|
-
Form$2.Field,
|
|
9726
|
-
{
|
|
9727
|
-
control: form.control,
|
|
9728
|
-
name: "province",
|
|
9729
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9730
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
9731
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9732
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9733
|
-
] })
|
|
9734
|
-
}
|
|
9735
|
-
),
|
|
9736
|
-
/* @__PURE__ */ jsx(
|
|
9737
|
-
Form$2.Field,
|
|
9738
|
-
{
|
|
9739
|
-
control: form.control,
|
|
9740
|
-
name: "phone",
|
|
9741
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9742
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
9743
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9744
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9745
|
-
] })
|
|
9746
|
-
}
|
|
9747
|
-
)
|
|
9748
|
-
] }) }),
|
|
9749
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9750
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9751
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9752
|
-
] }) })
|
|
9753
|
-
]
|
|
9754
|
-
}
|
|
9755
|
-
) });
|
|
9756
|
-
};
|
|
9757
|
-
const schema$5 = addressSchema;
|
|
9758
|
-
const Email = () => {
|
|
9759
|
-
const { id } = useParams();
|
|
9760
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
9761
|
-
fields: "+email"
|
|
9762
|
-
});
|
|
9763
|
-
if (isError) {
|
|
9764
|
-
throw error;
|
|
9765
|
-
}
|
|
9766
|
-
const isReady = !isPending && !!order;
|
|
9767
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9768
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
9769
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
|
|
9770
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
9771
|
-
] }),
|
|
9772
|
-
isReady && /* @__PURE__ */ jsx(EmailForm, { order })
|
|
9773
|
-
] });
|
|
9774
|
-
};
|
|
9775
|
-
const EmailForm = ({ order }) => {
|
|
9776
|
-
const form = useForm({
|
|
9777
|
-
defaultValues: {
|
|
9778
|
-
email: order.email ?? ""
|
|
9779
|
-
},
|
|
9780
|
-
resolver: zodResolver(schema$4)
|
|
9781
|
-
});
|
|
9782
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9783
|
-
const { handleSuccess } = useRouteModal();
|
|
9784
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
9785
|
-
await mutateAsync(
|
|
9786
|
-
{ email: data.email },
|
|
9787
|
-
{
|
|
9788
|
-
onSuccess: () => {
|
|
9789
|
-
handleSuccess();
|
|
9790
|
-
},
|
|
9791
|
-
onError: (error) => {
|
|
9792
|
-
toast.error(error.message);
|
|
9793
|
-
}
|
|
9794
|
-
}
|
|
9795
|
-
);
|
|
9796
|
-
});
|
|
9797
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
9798
|
-
KeyboundForm,
|
|
9799
|
-
{
|
|
9800
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
9801
|
-
onSubmit,
|
|
9802
|
-
children: [
|
|
9803
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
9804
|
-
Form$2.Field,
|
|
9805
|
-
{
|
|
9806
|
-
control: form.control,
|
|
9807
|
-
name: "email",
|
|
9808
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9809
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
|
|
9810
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9811
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9812
|
-
] })
|
|
9813
|
-
}
|
|
9814
|
-
) }),
|
|
9815
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9816
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9817
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9818
|
-
] }) })
|
|
9819
|
-
]
|
|
9820
|
-
}
|
|
9821
|
-
) });
|
|
9822
|
-
};
|
|
9823
|
-
const schema$4 = objectType({
|
|
9824
|
-
email: stringType().email()
|
|
9825
|
-
});
|
|
9826
9568
|
const CustomItems = () => {
|
|
9827
9569
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9828
9570
|
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
@@ -9831,7 +9573,7 @@ const CustomItems = () => {
|
|
|
9831
9573
|
};
|
|
9832
9574
|
const CustomItemsForm = () => {
|
|
9833
9575
|
const form = useForm({
|
|
9834
|
-
resolver: zodResolver(schema$
|
|
9576
|
+
resolver: zodResolver(schema$5)
|
|
9835
9577
|
});
|
|
9836
9578
|
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9837
9579
|
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
@@ -9841,7 +9583,7 @@ const CustomItemsForm = () => {
|
|
|
9841
9583
|
] }) })
|
|
9842
9584
|
] }) });
|
|
9843
9585
|
};
|
|
9844
|
-
const schema$
|
|
9586
|
+
const schema$5 = objectType({
|
|
9845
9587
|
email: stringType().email()
|
|
9846
9588
|
});
|
|
9847
9589
|
const NumberInput = forwardRef(
|
|
@@ -10803,20 +10545,88 @@ const CustomItemForm = ({ orderId, currencyCode }) => {
|
|
|
10803
10545
|
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx("div", { className: "w-full flex-1", children: /* @__PURE__ */ jsx(NumberInput, { ...field, className: "w-full" }) }) }),
|
|
10804
10546
|
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10805
10547
|
] })
|
|
10806
|
-
] }) })
|
|
10807
|
-
}
|
|
10808
|
-
)
|
|
10809
|
-
] }) }) }),
|
|
10810
|
-
/* @__PURE__ */ jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
10811
|
-
/* @__PURE__ */ jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
10812
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "button", onClick: onSubmit, children: "Add item" })
|
|
10813
|
-
] }) })
|
|
10814
|
-
] }) }) });
|
|
10548
|
+
] }) })
|
|
10549
|
+
}
|
|
10550
|
+
)
|
|
10551
|
+
] }) }) }),
|
|
10552
|
+
/* @__PURE__ */ jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
10553
|
+
/* @__PURE__ */ jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
10554
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "button", onClick: onSubmit, children: "Add item" })
|
|
10555
|
+
] }) })
|
|
10556
|
+
] }) }) });
|
|
10557
|
+
};
|
|
10558
|
+
const customItemSchema = objectType({
|
|
10559
|
+
title: stringType().min(1),
|
|
10560
|
+
quantity: numberType(),
|
|
10561
|
+
unit_price: unionType([numberType(), stringType()])
|
|
10562
|
+
});
|
|
10563
|
+
const Email = () => {
|
|
10564
|
+
const { id } = useParams();
|
|
10565
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
10566
|
+
fields: "+email"
|
|
10567
|
+
});
|
|
10568
|
+
if (isError) {
|
|
10569
|
+
throw error;
|
|
10570
|
+
}
|
|
10571
|
+
const isReady = !isPending && !!order;
|
|
10572
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
10573
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
10574
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
|
|
10575
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
10576
|
+
] }),
|
|
10577
|
+
isReady && /* @__PURE__ */ jsx(EmailForm, { order })
|
|
10578
|
+
] });
|
|
10579
|
+
};
|
|
10580
|
+
const EmailForm = ({ order }) => {
|
|
10581
|
+
const form = useForm({
|
|
10582
|
+
defaultValues: {
|
|
10583
|
+
email: order.email ?? ""
|
|
10584
|
+
},
|
|
10585
|
+
resolver: zodResolver(schema$4)
|
|
10586
|
+
});
|
|
10587
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
10588
|
+
const { handleSuccess } = useRouteModal();
|
|
10589
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
10590
|
+
await mutateAsync(
|
|
10591
|
+
{ email: data.email },
|
|
10592
|
+
{
|
|
10593
|
+
onSuccess: () => {
|
|
10594
|
+
handleSuccess();
|
|
10595
|
+
},
|
|
10596
|
+
onError: (error) => {
|
|
10597
|
+
toast.error(error.message);
|
|
10598
|
+
}
|
|
10599
|
+
}
|
|
10600
|
+
);
|
|
10601
|
+
});
|
|
10602
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
10603
|
+
KeyboundForm,
|
|
10604
|
+
{
|
|
10605
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
10606
|
+
onSubmit,
|
|
10607
|
+
children: [
|
|
10608
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
10609
|
+
Form$2.Field,
|
|
10610
|
+
{
|
|
10611
|
+
control: form.control,
|
|
10612
|
+
name: "email",
|
|
10613
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
10614
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
|
|
10615
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
10616
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10617
|
+
] })
|
|
10618
|
+
}
|
|
10619
|
+
) }),
|
|
10620
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
10621
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
10622
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
10623
|
+
] }) })
|
|
10624
|
+
]
|
|
10625
|
+
}
|
|
10626
|
+
) });
|
|
10815
10627
|
};
|
|
10816
|
-
const
|
|
10817
|
-
|
|
10818
|
-
quantity: numberType(),
|
|
10819
|
-
unit_price: unionType([numberType(), stringType()])
|
|
10628
|
+
const schema$4 = objectType({
|
|
10629
|
+
email: stringType().email()
|
|
10820
10630
|
});
|
|
10821
10631
|
const InlineTip = forwardRef(
|
|
10822
10632
|
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
@@ -11168,6 +10978,196 @@ function getHasUneditableRows(metadata) {
|
|
|
11168
10978
|
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
11169
10979
|
);
|
|
11170
10980
|
}
|
|
10981
|
+
const BillingAddress = () => {
|
|
10982
|
+
const { id } = useParams();
|
|
10983
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
10984
|
+
fields: "+billing_address"
|
|
10985
|
+
});
|
|
10986
|
+
if (isError) {
|
|
10987
|
+
throw error;
|
|
10988
|
+
}
|
|
10989
|
+
const isReady = !isPending && !!order;
|
|
10990
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
10991
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
10992
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
|
|
10993
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
10994
|
+
] }),
|
|
10995
|
+
isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
|
|
10996
|
+
] });
|
|
10997
|
+
};
|
|
10998
|
+
const BillingAddressForm = ({ order }) => {
|
|
10999
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
11000
|
+
const form = useForm({
|
|
11001
|
+
defaultValues: {
|
|
11002
|
+
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
11003
|
+
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
11004
|
+
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
11005
|
+
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
11006
|
+
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
11007
|
+
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
11008
|
+
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
11009
|
+
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
11010
|
+
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
11011
|
+
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
11012
|
+
},
|
|
11013
|
+
resolver: zodResolver(schema$3)
|
|
11014
|
+
});
|
|
11015
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11016
|
+
const { handleSuccess } = useRouteModal();
|
|
11017
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11018
|
+
await mutateAsync(
|
|
11019
|
+
{ billing_address: data },
|
|
11020
|
+
{
|
|
11021
|
+
onSuccess: () => {
|
|
11022
|
+
handleSuccess();
|
|
11023
|
+
},
|
|
11024
|
+
onError: (error) => {
|
|
11025
|
+
toast.error(error.message);
|
|
11026
|
+
}
|
|
11027
|
+
}
|
|
11028
|
+
);
|
|
11029
|
+
});
|
|
11030
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11031
|
+
KeyboundForm,
|
|
11032
|
+
{
|
|
11033
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11034
|
+
onSubmit,
|
|
11035
|
+
children: [
|
|
11036
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
|
|
11037
|
+
/* @__PURE__ */ jsx(
|
|
11038
|
+
Form$2.Field,
|
|
11039
|
+
{
|
|
11040
|
+
control: form.control,
|
|
11041
|
+
name: "country_code",
|
|
11042
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11043
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
11044
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
11045
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11046
|
+
] })
|
|
11047
|
+
}
|
|
11048
|
+
),
|
|
11049
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11050
|
+
/* @__PURE__ */ jsx(
|
|
11051
|
+
Form$2.Field,
|
|
11052
|
+
{
|
|
11053
|
+
control: form.control,
|
|
11054
|
+
name: "first_name",
|
|
11055
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11056
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
11057
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11058
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11059
|
+
] })
|
|
11060
|
+
}
|
|
11061
|
+
),
|
|
11062
|
+
/* @__PURE__ */ jsx(
|
|
11063
|
+
Form$2.Field,
|
|
11064
|
+
{
|
|
11065
|
+
control: form.control,
|
|
11066
|
+
name: "last_name",
|
|
11067
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11068
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
11069
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11070
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11071
|
+
] })
|
|
11072
|
+
}
|
|
11073
|
+
)
|
|
11074
|
+
] }),
|
|
11075
|
+
/* @__PURE__ */ jsx(
|
|
11076
|
+
Form$2.Field,
|
|
11077
|
+
{
|
|
11078
|
+
control: form.control,
|
|
11079
|
+
name: "company",
|
|
11080
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11081
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
11082
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11083
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11084
|
+
] })
|
|
11085
|
+
}
|
|
11086
|
+
),
|
|
11087
|
+
/* @__PURE__ */ jsx(
|
|
11088
|
+
Form$2.Field,
|
|
11089
|
+
{
|
|
11090
|
+
control: form.control,
|
|
11091
|
+
name: "address_1",
|
|
11092
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11093
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
11094
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11095
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11096
|
+
] })
|
|
11097
|
+
}
|
|
11098
|
+
),
|
|
11099
|
+
/* @__PURE__ */ jsx(
|
|
11100
|
+
Form$2.Field,
|
|
11101
|
+
{
|
|
11102
|
+
control: form.control,
|
|
11103
|
+
name: "address_2",
|
|
11104
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11105
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
11106
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11107
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11108
|
+
] })
|
|
11109
|
+
}
|
|
11110
|
+
),
|
|
11111
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11112
|
+
/* @__PURE__ */ jsx(
|
|
11113
|
+
Form$2.Field,
|
|
11114
|
+
{
|
|
11115
|
+
control: form.control,
|
|
11116
|
+
name: "postal_code",
|
|
11117
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11118
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
11119
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11120
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11121
|
+
] })
|
|
11122
|
+
}
|
|
11123
|
+
),
|
|
11124
|
+
/* @__PURE__ */ jsx(
|
|
11125
|
+
Form$2.Field,
|
|
11126
|
+
{
|
|
11127
|
+
control: form.control,
|
|
11128
|
+
name: "city",
|
|
11129
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11130
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
11131
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11132
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11133
|
+
] })
|
|
11134
|
+
}
|
|
11135
|
+
)
|
|
11136
|
+
] }),
|
|
11137
|
+
/* @__PURE__ */ jsx(
|
|
11138
|
+
Form$2.Field,
|
|
11139
|
+
{
|
|
11140
|
+
control: form.control,
|
|
11141
|
+
name: "province",
|
|
11142
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11143
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
11144
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11145
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11146
|
+
] })
|
|
11147
|
+
}
|
|
11148
|
+
),
|
|
11149
|
+
/* @__PURE__ */ jsx(
|
|
11150
|
+
Form$2.Field,
|
|
11151
|
+
{
|
|
11152
|
+
control: form.control,
|
|
11153
|
+
name: "phone",
|
|
11154
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11155
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
11156
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11157
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11158
|
+
] })
|
|
11159
|
+
}
|
|
11160
|
+
)
|
|
11161
|
+
] }) }),
|
|
11162
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11163
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11164
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11165
|
+
] }) })
|
|
11166
|
+
]
|
|
11167
|
+
}
|
|
11168
|
+
) });
|
|
11169
|
+
};
|
|
11170
|
+
const schema$3 = addressSchema;
|
|
11171
11171
|
const PROMOTION_QUERY_KEY = "promotions";
|
|
11172
11172
|
const promotionsQueryKeys = {
|
|
11173
11173
|
list: (query2) => [
|
|
@@ -13057,14 +13057,6 @@ const routeModule = {
|
|
|
13057
13057
|
handle,
|
|
13058
13058
|
loader,
|
|
13059
13059
|
children: [
|
|
13060
|
-
{
|
|
13061
|
-
Component: BillingAddress,
|
|
13062
|
-
path: "/draft-orders/:id/billing-address"
|
|
13063
|
-
},
|
|
13064
|
-
{
|
|
13065
|
-
Component: Email,
|
|
13066
|
-
path: "/draft-orders/:id/email"
|
|
13067
|
-
},
|
|
13068
13060
|
{
|
|
13069
13061
|
Component: CustomItems,
|
|
13070
13062
|
path: "/draft-orders/:id/custom-items"
|
|
@@ -13073,10 +13065,18 @@ const routeModule = {
|
|
|
13073
13065
|
Component: Items,
|
|
13074
13066
|
path: "/draft-orders/:id/items"
|
|
13075
13067
|
},
|
|
13068
|
+
{
|
|
13069
|
+
Component: Email,
|
|
13070
|
+
path: "/draft-orders/:id/email"
|
|
13071
|
+
},
|
|
13076
13072
|
{
|
|
13077
13073
|
Component: Metadata,
|
|
13078
13074
|
path: "/draft-orders/:id/metadata"
|
|
13079
13075
|
},
|
|
13076
|
+
{
|
|
13077
|
+
Component: BillingAddress,
|
|
13078
|
+
path: "/draft-orders/:id/billing-address"
|
|
13079
|
+
},
|
|
13080
13080
|
{
|
|
13081
13081
|
Component: Promotions,
|
|
13082
13082
|
path: "/draft-orders/:id/promotions"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/draft-order",
|
|
3
|
-
"version": "2.11.2-preview-
|
|
3
|
+
"version": "2.11.2-preview-20251028000318",
|
|
4
4
|
"description": "A starter for Medusa plugins.",
|
|
5
5
|
"author": "Medusa (https://medusajs.com)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@ariakit/react": "^0.4.15",
|
|
38
38
|
"@hookform/resolvers": "3.4.2",
|
|
39
|
-
"@medusajs/js-sdk": "2.11.2-preview-
|
|
39
|
+
"@medusajs/js-sdk": "2.11.2-preview-20251028000318",
|
|
40
40
|
"@tanstack/react-query": "5.64.2",
|
|
41
41
|
"@uiw/react-json-view": "^2.0.0-alpha.17",
|
|
42
42
|
"date-fns": "^3.6.0",
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
"react-hook-form": "7.49.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@medusajs/admin-sdk": "2.11.2-preview-
|
|
49
|
-
"@medusajs/cli": "2.11.2-preview-
|
|
50
|
-
"@medusajs/framework": "2.11.2-preview-
|
|
51
|
-
"@medusajs/icons": "2.11.2-preview-
|
|
52
|
-
"@medusajs/test-utils": "2.11.2-preview-
|
|
53
|
-
"@medusajs/types": "2.11.2-preview-
|
|
54
|
-
"@medusajs/ui": "4.0.26-preview-
|
|
55
|
-
"@medusajs/ui-preset": "2.11.2-preview-
|
|
48
|
+
"@medusajs/admin-sdk": "2.11.2-preview-20251028000318",
|
|
49
|
+
"@medusajs/cli": "2.11.2-preview-20251028000318",
|
|
50
|
+
"@medusajs/framework": "2.11.2-preview-20251028000318",
|
|
51
|
+
"@medusajs/icons": "2.11.2-preview-20251028000318",
|
|
52
|
+
"@medusajs/test-utils": "2.11.2-preview-20251028000318",
|
|
53
|
+
"@medusajs/types": "2.11.2-preview-20251028000318",
|
|
54
|
+
"@medusajs/ui": "4.0.26-preview-20251028000318",
|
|
55
|
+
"@medusajs/ui-preset": "2.11.2-preview-20251028000318",
|
|
56
56
|
"@swc/core": "1.5.7",
|
|
57
57
|
"@types/lodash": "^4.17.15",
|
|
58
58
|
"@types/node": "^20.0.0",
|
|
@@ -69,12 +69,12 @@
|
|
|
69
69
|
"yalc": "^1.0.0-pre.53"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
|
-
"@medusajs/admin-sdk": "2.11.2-preview-
|
|
73
|
-
"@medusajs/cli": "2.11.2-preview-
|
|
74
|
-
"@medusajs/framework": "2.11.2-preview-
|
|
75
|
-
"@medusajs/icons": "2.11.2-preview-
|
|
76
|
-
"@medusajs/test-utils": "2.11.2-preview-
|
|
77
|
-
"@medusajs/ui": "4.0.26-preview-
|
|
72
|
+
"@medusajs/admin-sdk": "2.11.2-preview-20251028000318",
|
|
73
|
+
"@medusajs/cli": "2.11.2-preview-20251028000318",
|
|
74
|
+
"@medusajs/framework": "2.11.2-preview-20251028000318",
|
|
75
|
+
"@medusajs/icons": "2.11.2-preview-20251028000318",
|
|
76
|
+
"@medusajs/test-utils": "2.11.2-preview-20251028000318",
|
|
77
|
+
"@medusajs/ui": "4.0.26-preview-20251028000318",
|
|
78
78
|
"lodash": "^4.17.21",
|
|
79
79
|
"react-router-dom": "6.20.1"
|
|
80
80
|
},
|