@medusajs/draft-order 2.10.0-snapshot-20250827070327 → 2.10.0-snapshot-20250827150653
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 +473 -473
- package/.medusa/server/src/admin/index.mjs +473 -473
- package/package.json +18 -18
|
@@ -9560,6 +9560,196 @@ const ID = () => {
|
|
|
9560
9560
|
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
9561
9561
|
] });
|
|
9562
9562
|
};
|
|
9563
|
+
const BillingAddress = () => {
|
|
9564
|
+
const { id } = reactRouterDom.useParams();
|
|
9565
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
9566
|
+
fields: "+billing_address"
|
|
9567
|
+
});
|
|
9568
|
+
if (isError) {
|
|
9569
|
+
throw error;
|
|
9570
|
+
}
|
|
9571
|
+
const isReady = !isPending && !!order;
|
|
9572
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9573
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
9574
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
|
|
9575
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
9576
|
+
] }),
|
|
9577
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
|
|
9578
|
+
] });
|
|
9579
|
+
};
|
|
9580
|
+
const BillingAddressForm = ({ order }) => {
|
|
9581
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
9582
|
+
const form = reactHookForm.useForm({
|
|
9583
|
+
defaultValues: {
|
|
9584
|
+
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
9585
|
+
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
9586
|
+
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
9587
|
+
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
9588
|
+
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
9589
|
+
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
9590
|
+
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
9591
|
+
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
9592
|
+
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9593
|
+
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9594
|
+
},
|
|
9595
|
+
resolver: zod.zodResolver(schema$5)
|
|
9596
|
+
});
|
|
9597
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9598
|
+
const { handleSuccess } = useRouteModal();
|
|
9599
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
9600
|
+
await mutateAsync(
|
|
9601
|
+
{ billing_address: data },
|
|
9602
|
+
{
|
|
9603
|
+
onSuccess: () => {
|
|
9604
|
+
handleSuccess();
|
|
9605
|
+
},
|
|
9606
|
+
onError: (error) => {
|
|
9607
|
+
ui.toast.error(error.message);
|
|
9608
|
+
}
|
|
9609
|
+
}
|
|
9610
|
+
);
|
|
9611
|
+
});
|
|
9612
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9613
|
+
KeyboundForm,
|
|
9614
|
+
{
|
|
9615
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
9616
|
+
onSubmit,
|
|
9617
|
+
children: [
|
|
9618
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
|
|
9619
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9620
|
+
Form$2.Field,
|
|
9621
|
+
{
|
|
9622
|
+
control: form.control,
|
|
9623
|
+
name: "country_code",
|
|
9624
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9625
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
|
|
9626
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
9627
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9628
|
+
] })
|
|
9629
|
+
}
|
|
9630
|
+
),
|
|
9631
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9632
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9633
|
+
Form$2.Field,
|
|
9634
|
+
{
|
|
9635
|
+
control: form.control,
|
|
9636
|
+
name: "first_name",
|
|
9637
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9638
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
9639
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9640
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9641
|
+
] })
|
|
9642
|
+
}
|
|
9643
|
+
),
|
|
9644
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9645
|
+
Form$2.Field,
|
|
9646
|
+
{
|
|
9647
|
+
control: form.control,
|
|
9648
|
+
name: "last_name",
|
|
9649
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9650
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
9651
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9652
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9653
|
+
] })
|
|
9654
|
+
}
|
|
9655
|
+
)
|
|
9656
|
+
] }),
|
|
9657
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9658
|
+
Form$2.Field,
|
|
9659
|
+
{
|
|
9660
|
+
control: form.control,
|
|
9661
|
+
name: "company",
|
|
9662
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9663
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
9664
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9665
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9666
|
+
] })
|
|
9667
|
+
}
|
|
9668
|
+
),
|
|
9669
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9670
|
+
Form$2.Field,
|
|
9671
|
+
{
|
|
9672
|
+
control: form.control,
|
|
9673
|
+
name: "address_1",
|
|
9674
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9675
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
9676
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9677
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9678
|
+
] })
|
|
9679
|
+
}
|
|
9680
|
+
),
|
|
9681
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9682
|
+
Form$2.Field,
|
|
9683
|
+
{
|
|
9684
|
+
control: form.control,
|
|
9685
|
+
name: "address_2",
|
|
9686
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9687
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
9688
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9689
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9690
|
+
] })
|
|
9691
|
+
}
|
|
9692
|
+
),
|
|
9693
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9694
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9695
|
+
Form$2.Field,
|
|
9696
|
+
{
|
|
9697
|
+
control: form.control,
|
|
9698
|
+
name: "postal_code",
|
|
9699
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9700
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
9701
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9702
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9703
|
+
] })
|
|
9704
|
+
}
|
|
9705
|
+
),
|
|
9706
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9707
|
+
Form$2.Field,
|
|
9708
|
+
{
|
|
9709
|
+
control: form.control,
|
|
9710
|
+
name: "city",
|
|
9711
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9712
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
9713
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9714
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9715
|
+
] })
|
|
9716
|
+
}
|
|
9717
|
+
)
|
|
9718
|
+
] }),
|
|
9719
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9720
|
+
Form$2.Field,
|
|
9721
|
+
{
|
|
9722
|
+
control: form.control,
|
|
9723
|
+
name: "province",
|
|
9724
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9725
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
9726
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9727
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9728
|
+
] })
|
|
9729
|
+
}
|
|
9730
|
+
),
|
|
9731
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9732
|
+
Form$2.Field,
|
|
9733
|
+
{
|
|
9734
|
+
control: form.control,
|
|
9735
|
+
name: "phone",
|
|
9736
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9737
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
9738
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9739
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9740
|
+
] })
|
|
9741
|
+
}
|
|
9742
|
+
)
|
|
9743
|
+
] }) }),
|
|
9744
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9745
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9746
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9747
|
+
] }) })
|
|
9748
|
+
]
|
|
9749
|
+
}
|
|
9750
|
+
) });
|
|
9751
|
+
};
|
|
9752
|
+
const schema$5 = addressSchema;
|
|
9563
9753
|
const CustomItems = () => {
|
|
9564
9754
|
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9565
9755
|
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
@@ -9568,7 +9758,7 @@ const CustomItems = () => {
|
|
|
9568
9758
|
};
|
|
9569
9759
|
const CustomItemsForm = () => {
|
|
9570
9760
|
const form = reactHookForm.useForm({
|
|
9571
|
-
resolver: zod.zodResolver(schema$
|
|
9761
|
+
resolver: zod.zodResolver(schema$4)
|
|
9572
9762
|
});
|
|
9573
9763
|
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9574
9764
|
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
@@ -9578,46 +9768,114 @@ const CustomItemsForm = () => {
|
|
|
9578
9768
|
] }) })
|
|
9579
9769
|
] }) });
|
|
9580
9770
|
};
|
|
9581
|
-
const schema$
|
|
9771
|
+
const schema$4 = objectType({
|
|
9582
9772
|
email: stringType().email()
|
|
9583
9773
|
});
|
|
9584
|
-
const
|
|
9585
|
-
(
|
|
9586
|
-
|
|
9587
|
-
|
|
9588
|
-
|
|
9589
|
-
|
|
9590
|
-
|
|
9591
|
-
|
|
9592
|
-
|
|
9593
|
-
|
|
9594
|
-
|
|
9595
|
-
|
|
9596
|
-
|
|
9597
|
-
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
|
|
9601
|
-
|
|
9602
|
-
|
|
9603
|
-
|
|
9604
|
-
|
|
9605
|
-
|
|
9606
|
-
|
|
9607
|
-
|
|
9608
|
-
|
|
9609
|
-
|
|
9610
|
-
|
|
9611
|
-
|
|
9612
|
-
}
|
|
9613
|
-
};
|
|
9614
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9615
|
-
"div",
|
|
9774
|
+
const Email = () => {
|
|
9775
|
+
const { id } = reactRouterDom.useParams();
|
|
9776
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
9777
|
+
fields: "+email"
|
|
9778
|
+
});
|
|
9779
|
+
if (isError) {
|
|
9780
|
+
throw error;
|
|
9781
|
+
}
|
|
9782
|
+
const isReady = !isPending && !!order;
|
|
9783
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9784
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
9785
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
|
|
9786
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
9787
|
+
] }),
|
|
9788
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
|
|
9789
|
+
] });
|
|
9790
|
+
};
|
|
9791
|
+
const EmailForm = ({ order }) => {
|
|
9792
|
+
const form = reactHookForm.useForm({
|
|
9793
|
+
defaultValues: {
|
|
9794
|
+
email: order.email ?? ""
|
|
9795
|
+
},
|
|
9796
|
+
resolver: zod.zodResolver(schema$3)
|
|
9797
|
+
});
|
|
9798
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9799
|
+
const { handleSuccess } = useRouteModal();
|
|
9800
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
9801
|
+
await mutateAsync(
|
|
9802
|
+
{ email: data.email },
|
|
9616
9803
|
{
|
|
9617
|
-
|
|
9618
|
-
|
|
9619
|
-
|
|
9620
|
-
|
|
9804
|
+
onSuccess: () => {
|
|
9805
|
+
handleSuccess();
|
|
9806
|
+
},
|
|
9807
|
+
onError: (error) => {
|
|
9808
|
+
ui.toast.error(error.message);
|
|
9809
|
+
}
|
|
9810
|
+
}
|
|
9811
|
+
);
|
|
9812
|
+
});
|
|
9813
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9814
|
+
KeyboundForm,
|
|
9815
|
+
{
|
|
9816
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
9817
|
+
onSubmit,
|
|
9818
|
+
children: [
|
|
9819
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9820
|
+
Form$2.Field,
|
|
9821
|
+
{
|
|
9822
|
+
control: form.control,
|
|
9823
|
+
name: "email",
|
|
9824
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9825
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
|
|
9826
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9827
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9828
|
+
] })
|
|
9829
|
+
}
|
|
9830
|
+
) }),
|
|
9831
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9832
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9833
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9834
|
+
] }) })
|
|
9835
|
+
]
|
|
9836
|
+
}
|
|
9837
|
+
) });
|
|
9838
|
+
};
|
|
9839
|
+
const schema$3 = objectType({
|
|
9840
|
+
email: stringType().email()
|
|
9841
|
+
});
|
|
9842
|
+
const NumberInput = React.forwardRef(
|
|
9843
|
+
({
|
|
9844
|
+
value,
|
|
9845
|
+
onChange,
|
|
9846
|
+
size = "base",
|
|
9847
|
+
min = 0,
|
|
9848
|
+
max = 100,
|
|
9849
|
+
step = 1,
|
|
9850
|
+
className,
|
|
9851
|
+
disabled,
|
|
9852
|
+
...props
|
|
9853
|
+
}, ref) => {
|
|
9854
|
+
const handleChange = (event) => {
|
|
9855
|
+
const newValue = event.target.value === "" ? min : Number(event.target.value);
|
|
9856
|
+
if (!isNaN(newValue) && (max === void 0 || newValue <= max) && (min === void 0 || newValue >= min)) {
|
|
9857
|
+
onChange(newValue);
|
|
9858
|
+
}
|
|
9859
|
+
};
|
|
9860
|
+
const handleIncrement = () => {
|
|
9861
|
+
const newValue = value + step;
|
|
9862
|
+
if (max === void 0 || newValue <= max) {
|
|
9863
|
+
onChange(newValue);
|
|
9864
|
+
}
|
|
9865
|
+
};
|
|
9866
|
+
const handleDecrement = () => {
|
|
9867
|
+
const newValue = value - step;
|
|
9868
|
+
if (min === void 0 || newValue >= min) {
|
|
9869
|
+
onChange(newValue);
|
|
9870
|
+
}
|
|
9871
|
+
};
|
|
9872
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9873
|
+
"div",
|
|
9874
|
+
{
|
|
9875
|
+
className: ui.clx(
|
|
9876
|
+
"inline-flex rounded-md bg-ui-bg-field shadow-borders-base overflow-hidden divide-x transition-fg",
|
|
9877
|
+
"[&:has(input:focus)]:shadow-borders-interactive-with-active",
|
|
9878
|
+
{
|
|
9621
9879
|
"h-7": size === "small",
|
|
9622
9880
|
"h-8": size === "base"
|
|
9623
9881
|
},
|
|
@@ -11016,362 +11274,172 @@ const PromotionForm = ({ preview }) => {
|
|
|
11016
11274
|
await confirmOrderEdit(void 0, {
|
|
11017
11275
|
onError: (e) => {
|
|
11018
11276
|
ui.toast.error(e.message);
|
|
11019
|
-
},
|
|
11020
|
-
onSuccess: () => {
|
|
11021
|
-
handleSuccess();
|
|
11022
|
-
},
|
|
11023
|
-
onSettled: () => {
|
|
11024
|
-
setIsSubmitting(false);
|
|
11025
|
-
}
|
|
11026
|
-
});
|
|
11027
|
-
};
|
|
11028
|
-
if (isError) {
|
|
11029
|
-
throw error;
|
|
11030
|
-
}
|
|
11031
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", onSubmit, children: [
|
|
11032
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
11033
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
11034
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
11035
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "promotion-combobox", children: "Apply promotions" }),
|
|
11036
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { id: "promotion-combobox-hint", children: "Manage promotions that should be applied to the order." })
|
|
11037
|
-
] }),
|
|
11038
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11039
|
-
Combobox,
|
|
11040
|
-
{
|
|
11041
|
-
id: "promotion-combobox",
|
|
11042
|
-
"aria-describedby": "promotion-combobox-hint",
|
|
11043
|
-
isFetchingNextPage: comboboxData.isFetchingNextPage,
|
|
11044
|
-
fetchNextPage: comboboxData.fetchNextPage,
|
|
11045
|
-
options: comboboxData.options,
|
|
11046
|
-
onSearchValueChange: comboboxData.onSearchValueChange,
|
|
11047
|
-
searchValue: comboboxData.searchValue,
|
|
11048
|
-
disabled: comboboxData.disabled || isAddingPromotions,
|
|
11049
|
-
onChange: add,
|
|
11050
|
-
value: comboboxValue
|
|
11051
|
-
}
|
|
11052
|
-
)
|
|
11053
|
-
] }),
|
|
11054
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
11055
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-2", children: promotions == null ? void 0 : promotions.map((promotion) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
11056
|
-
PromotionItem,
|
|
11057
|
-
{
|
|
11058
|
-
promotion,
|
|
11059
|
-
orderId: preview.id,
|
|
11060
|
-
isLoading: isPending
|
|
11061
|
-
},
|
|
11062
|
-
promotion.id
|
|
11063
|
-
)) })
|
|
11064
|
-
] }) }),
|
|
11065
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11066
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11067
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11068
|
-
ui.Button,
|
|
11069
|
-
{
|
|
11070
|
-
size: "small",
|
|
11071
|
-
type: "submit",
|
|
11072
|
-
isLoading: isSubmitting || isAddingPromotions,
|
|
11073
|
-
children: "Save"
|
|
11074
|
-
}
|
|
11075
|
-
)
|
|
11076
|
-
] }) })
|
|
11077
|
-
] });
|
|
11078
|
-
};
|
|
11079
|
-
const PromotionItem = ({
|
|
11080
|
-
promotion,
|
|
11081
|
-
orderId,
|
|
11082
|
-
isLoading
|
|
11083
|
-
}) => {
|
|
11084
|
-
var _a;
|
|
11085
|
-
const { mutateAsync: removePromotions, isPending } = useDraftOrderRemovePromotions(orderId);
|
|
11086
|
-
const onRemove = async () => {
|
|
11087
|
-
removePromotions(
|
|
11088
|
-
{
|
|
11089
|
-
promo_codes: [promotion.code]
|
|
11090
|
-
},
|
|
11091
|
-
{
|
|
11092
|
-
onError: (e) => {
|
|
11093
|
-
ui.toast.error(e.message);
|
|
11094
|
-
}
|
|
11095
|
-
}
|
|
11096
|
-
);
|
|
11097
|
-
};
|
|
11098
|
-
const displayValue = getDisplayValue(promotion);
|
|
11099
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11100
|
-
"div",
|
|
11101
|
-
{
|
|
11102
|
-
className: ui.clx(
|
|
11103
|
-
"px-3 py-2 rounded-lg bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between",
|
|
11104
|
-
{
|
|
11105
|
-
"animate-pulse": isLoading
|
|
11106
|
-
}
|
|
11107
|
-
),
|
|
11108
|
-
children: [
|
|
11109
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11110
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: promotion.code }),
|
|
11111
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5 text-ui-fg-subtle", children: [
|
|
11112
|
-
displayValue && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
11113
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: displayValue }),
|
|
11114
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: "·" })
|
|
11115
|
-
] }),
|
|
11116
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", className: "capitalize", children: (_a = promotion.application_method) == null ? void 0 : _a.allocation })
|
|
11117
|
-
] })
|
|
11118
|
-
] }),
|
|
11119
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11120
|
-
ui.IconButton,
|
|
11121
|
-
{
|
|
11122
|
-
size: "small",
|
|
11123
|
-
type: "button",
|
|
11124
|
-
variant: "transparent",
|
|
11125
|
-
onClick: onRemove,
|
|
11126
|
-
isLoading: isPending || isLoading,
|
|
11127
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(icons.XMark, {})
|
|
11128
|
-
}
|
|
11129
|
-
)
|
|
11130
|
-
]
|
|
11131
|
-
},
|
|
11132
|
-
promotion.id
|
|
11133
|
-
);
|
|
11134
|
-
};
|
|
11135
|
-
function getDisplayValue(promotion) {
|
|
11136
|
-
var _a, _b, _c, _d;
|
|
11137
|
-
const value = (_a = promotion.application_method) == null ? void 0 : _a.value;
|
|
11138
|
-
if (!value) {
|
|
11139
|
-
return null;
|
|
11140
|
-
}
|
|
11141
|
-
if (((_b = promotion.application_method) == null ? void 0 : _b.type) === "fixed") {
|
|
11142
|
-
const currency = (_c = promotion.application_method) == null ? void 0 : _c.currency_code;
|
|
11143
|
-
if (!currency) {
|
|
11144
|
-
return null;
|
|
11145
|
-
}
|
|
11146
|
-
return getLocaleAmount(value, currency);
|
|
11147
|
-
} else if (((_d = promotion.application_method) == null ? void 0 : _d.type) === "percentage") {
|
|
11148
|
-
return formatPercentage(value);
|
|
11149
|
-
}
|
|
11150
|
-
return null;
|
|
11151
|
-
}
|
|
11152
|
-
const formatter = new Intl.NumberFormat([], {
|
|
11153
|
-
style: "percent",
|
|
11154
|
-
minimumFractionDigits: 2
|
|
11155
|
-
});
|
|
11156
|
-
const formatPercentage = (value, isPercentageValue = false) => {
|
|
11157
|
-
let val = value || 0;
|
|
11158
|
-
if (!isPercentageValue) {
|
|
11159
|
-
val = val / 100;
|
|
11160
|
-
}
|
|
11161
|
-
return formatter.format(val);
|
|
11162
|
-
};
|
|
11163
|
-
function getPromotionCodes(items, shippingMethods) {
|
|
11164
|
-
const codes = /* @__PURE__ */ new Set();
|
|
11165
|
-
for (const item of items) {
|
|
11166
|
-
if (item.adjustments) {
|
|
11167
|
-
for (const adjustment of item.adjustments) {
|
|
11168
|
-
if (adjustment.code) {
|
|
11169
|
-
codes.add(adjustment.code);
|
|
11170
|
-
}
|
|
11171
|
-
}
|
|
11172
|
-
}
|
|
11173
|
-
}
|
|
11174
|
-
for (const shippingMethod of shippingMethods) {
|
|
11175
|
-
if (shippingMethod.adjustments) {
|
|
11176
|
-
for (const adjustment of shippingMethod.adjustments) {
|
|
11177
|
-
if (adjustment.code) {
|
|
11178
|
-
codes.add(adjustment.code);
|
|
11179
|
-
}
|
|
11180
|
-
}
|
|
11181
|
-
}
|
|
11182
|
-
}
|
|
11183
|
-
return Array.from(codes);
|
|
11184
|
-
}
|
|
11185
|
-
const BillingAddress = () => {
|
|
11186
|
-
const { id } = reactRouterDom.useParams();
|
|
11187
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
11188
|
-
fields: "+billing_address"
|
|
11189
|
-
});
|
|
11190
|
-
if (isError) {
|
|
11191
|
-
throw error;
|
|
11192
|
-
}
|
|
11193
|
-
const isReady = !isPending && !!order;
|
|
11194
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11195
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
11196
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
|
|
11197
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
11198
|
-
] }),
|
|
11199
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
|
|
11200
|
-
] });
|
|
11201
|
-
};
|
|
11202
|
-
const BillingAddressForm = ({ order }) => {
|
|
11203
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
11204
|
-
const form = reactHookForm.useForm({
|
|
11205
|
-
defaultValues: {
|
|
11206
|
-
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
11207
|
-
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
11208
|
-
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
11209
|
-
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
11210
|
-
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
11211
|
-
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
11212
|
-
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
11213
|
-
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
11214
|
-
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
11215
|
-
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
11216
|
-
},
|
|
11217
|
-
resolver: zod.zodResolver(schema$4)
|
|
11218
|
-
});
|
|
11219
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11220
|
-
const { handleSuccess } = useRouteModal();
|
|
11221
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
11222
|
-
await mutateAsync(
|
|
11223
|
-
{ billing_address: data },
|
|
11224
|
-
{
|
|
11225
|
-
onSuccess: () => {
|
|
11226
|
-
handleSuccess();
|
|
11227
|
-
},
|
|
11228
|
-
onError: (error) => {
|
|
11229
|
-
ui.toast.error(error.message);
|
|
11230
|
-
}
|
|
11231
|
-
}
|
|
11232
|
-
);
|
|
11233
|
-
});
|
|
11234
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11235
|
-
KeyboundForm,
|
|
11236
|
-
{
|
|
11237
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
11238
|
-
onSubmit,
|
|
11239
|
-
children: [
|
|
11240
|
-
/* @__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: [
|
|
11241
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11242
|
-
Form$2.Field,
|
|
11243
|
-
{
|
|
11244
|
-
control: form.control,
|
|
11245
|
-
name: "country_code",
|
|
11246
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11247
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
|
|
11248
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
11249
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11250
|
-
] })
|
|
11251
|
-
}
|
|
11252
|
-
),
|
|
11253
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11254
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11255
|
-
Form$2.Field,
|
|
11256
|
-
{
|
|
11257
|
-
control: form.control,
|
|
11258
|
-
name: "first_name",
|
|
11259
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11260
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
11261
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11262
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11263
|
-
] })
|
|
11264
|
-
}
|
|
11265
|
-
),
|
|
11266
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11267
|
-
Form$2.Field,
|
|
11268
|
-
{
|
|
11269
|
-
control: form.control,
|
|
11270
|
-
name: "last_name",
|
|
11271
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11272
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
11273
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11274
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11275
|
-
] })
|
|
11276
|
-
}
|
|
11277
|
-
)
|
|
11278
|
-
] }),
|
|
11279
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11280
|
-
Form$2.Field,
|
|
11281
|
-
{
|
|
11282
|
-
control: form.control,
|
|
11283
|
-
name: "company",
|
|
11284
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11285
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
11286
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11287
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11288
|
-
] })
|
|
11289
|
-
}
|
|
11290
|
-
),
|
|
11291
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11292
|
-
Form$2.Field,
|
|
11293
|
-
{
|
|
11294
|
-
control: form.control,
|
|
11295
|
-
name: "address_1",
|
|
11296
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11297
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
11298
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11299
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11300
|
-
] })
|
|
11301
|
-
}
|
|
11302
|
-
),
|
|
11303
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11304
|
-
Form$2.Field,
|
|
11305
|
-
{
|
|
11306
|
-
control: form.control,
|
|
11307
|
-
name: "address_2",
|
|
11308
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11309
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
11310
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11311
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11312
|
-
] })
|
|
11313
|
-
}
|
|
11314
|
-
),
|
|
11315
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11316
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11317
|
-
Form$2.Field,
|
|
11318
|
-
{
|
|
11319
|
-
control: form.control,
|
|
11320
|
-
name: "postal_code",
|
|
11321
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11322
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
11323
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11324
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11325
|
-
] })
|
|
11326
|
-
}
|
|
11327
|
-
),
|
|
11328
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11329
|
-
Form$2.Field,
|
|
11330
|
-
{
|
|
11331
|
-
control: form.control,
|
|
11332
|
-
name: "city",
|
|
11333
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11334
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
11335
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11336
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11337
|
-
] })
|
|
11338
|
-
}
|
|
11339
|
-
)
|
|
11340
|
-
] }),
|
|
11341
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11342
|
-
Form$2.Field,
|
|
11343
|
-
{
|
|
11344
|
-
control: form.control,
|
|
11345
|
-
name: "province",
|
|
11346
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11347
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
11348
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11349
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11350
|
-
] })
|
|
11351
|
-
}
|
|
11352
|
-
),
|
|
11353
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11354
|
-
Form$2.Field,
|
|
11355
|
-
{
|
|
11356
|
-
control: form.control,
|
|
11357
|
-
name: "phone",
|
|
11358
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11359
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
11360
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11361
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11362
|
-
] })
|
|
11363
|
-
}
|
|
11364
|
-
)
|
|
11365
|
-
] }) }),
|
|
11366
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11367
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11368
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11369
|
-
] }) })
|
|
11277
|
+
},
|
|
11278
|
+
onSuccess: () => {
|
|
11279
|
+
handleSuccess();
|
|
11280
|
+
},
|
|
11281
|
+
onSettled: () => {
|
|
11282
|
+
setIsSubmitting(false);
|
|
11283
|
+
}
|
|
11284
|
+
});
|
|
11285
|
+
};
|
|
11286
|
+
if (isError) {
|
|
11287
|
+
throw error;
|
|
11288
|
+
}
|
|
11289
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", onSubmit, children: [
|
|
11290
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
11291
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
11292
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
11293
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "promotion-combobox", children: "Apply promotions" }),
|
|
11294
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { id: "promotion-combobox-hint", children: "Manage promotions that should be applied to the order." })
|
|
11295
|
+
] }),
|
|
11296
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11297
|
+
Combobox,
|
|
11298
|
+
{
|
|
11299
|
+
id: "promotion-combobox",
|
|
11300
|
+
"aria-describedby": "promotion-combobox-hint",
|
|
11301
|
+
isFetchingNextPage: comboboxData.isFetchingNextPage,
|
|
11302
|
+
fetchNextPage: comboboxData.fetchNextPage,
|
|
11303
|
+
options: comboboxData.options,
|
|
11304
|
+
onSearchValueChange: comboboxData.onSearchValueChange,
|
|
11305
|
+
searchValue: comboboxData.searchValue,
|
|
11306
|
+
disabled: comboboxData.disabled || isAddingPromotions,
|
|
11307
|
+
onChange: add,
|
|
11308
|
+
value: comboboxValue
|
|
11309
|
+
}
|
|
11310
|
+
)
|
|
11311
|
+
] }),
|
|
11312
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
11313
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-2", children: promotions == null ? void 0 : promotions.map((promotion) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
11314
|
+
PromotionItem,
|
|
11315
|
+
{
|
|
11316
|
+
promotion,
|
|
11317
|
+
orderId: preview.id,
|
|
11318
|
+
isLoading: isPending
|
|
11319
|
+
},
|
|
11320
|
+
promotion.id
|
|
11321
|
+
)) })
|
|
11322
|
+
] }) }),
|
|
11323
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11324
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11325
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11326
|
+
ui.Button,
|
|
11327
|
+
{
|
|
11328
|
+
size: "small",
|
|
11329
|
+
type: "submit",
|
|
11330
|
+
isLoading: isSubmitting || isAddingPromotions,
|
|
11331
|
+
children: "Save"
|
|
11332
|
+
}
|
|
11333
|
+
)
|
|
11334
|
+
] }) })
|
|
11335
|
+
] });
|
|
11336
|
+
};
|
|
11337
|
+
const PromotionItem = ({
|
|
11338
|
+
promotion,
|
|
11339
|
+
orderId,
|
|
11340
|
+
isLoading
|
|
11341
|
+
}) => {
|
|
11342
|
+
var _a;
|
|
11343
|
+
const { mutateAsync: removePromotions, isPending } = useDraftOrderRemovePromotions(orderId);
|
|
11344
|
+
const onRemove = async () => {
|
|
11345
|
+
removePromotions(
|
|
11346
|
+
{
|
|
11347
|
+
promo_codes: [promotion.code]
|
|
11348
|
+
},
|
|
11349
|
+
{
|
|
11350
|
+
onError: (e) => {
|
|
11351
|
+
ui.toast.error(e.message);
|
|
11352
|
+
}
|
|
11353
|
+
}
|
|
11354
|
+
);
|
|
11355
|
+
};
|
|
11356
|
+
const displayValue = getDisplayValue(promotion);
|
|
11357
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11358
|
+
"div",
|
|
11359
|
+
{
|
|
11360
|
+
className: ui.clx(
|
|
11361
|
+
"px-3 py-2 rounded-lg bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between",
|
|
11362
|
+
{
|
|
11363
|
+
"animate-pulse": isLoading
|
|
11364
|
+
}
|
|
11365
|
+
),
|
|
11366
|
+
children: [
|
|
11367
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11368
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: promotion.code }),
|
|
11369
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5 text-ui-fg-subtle", children: [
|
|
11370
|
+
displayValue && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
11371
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: displayValue }),
|
|
11372
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: "·" })
|
|
11373
|
+
] }),
|
|
11374
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", className: "capitalize", children: (_a = promotion.application_method) == null ? void 0 : _a.allocation })
|
|
11375
|
+
] })
|
|
11376
|
+
] }),
|
|
11377
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11378
|
+
ui.IconButton,
|
|
11379
|
+
{
|
|
11380
|
+
size: "small",
|
|
11381
|
+
type: "button",
|
|
11382
|
+
variant: "transparent",
|
|
11383
|
+
onClick: onRemove,
|
|
11384
|
+
isLoading: isPending || isLoading,
|
|
11385
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.XMark, {})
|
|
11386
|
+
}
|
|
11387
|
+
)
|
|
11370
11388
|
]
|
|
11389
|
+
},
|
|
11390
|
+
promotion.id
|
|
11391
|
+
);
|
|
11392
|
+
};
|
|
11393
|
+
function getDisplayValue(promotion) {
|
|
11394
|
+
var _a, _b, _c, _d;
|
|
11395
|
+
const value = (_a = promotion.application_method) == null ? void 0 : _a.value;
|
|
11396
|
+
if (!value) {
|
|
11397
|
+
return null;
|
|
11398
|
+
}
|
|
11399
|
+
if (((_b = promotion.application_method) == null ? void 0 : _b.type) === "fixed") {
|
|
11400
|
+
const currency = (_c = promotion.application_method) == null ? void 0 : _c.currency_code;
|
|
11401
|
+
if (!currency) {
|
|
11402
|
+
return null;
|
|
11371
11403
|
}
|
|
11372
|
-
|
|
11404
|
+
return getLocaleAmount(value, currency);
|
|
11405
|
+
} else if (((_d = promotion.application_method) == null ? void 0 : _d.type) === "percentage") {
|
|
11406
|
+
return formatPercentage(value);
|
|
11407
|
+
}
|
|
11408
|
+
return null;
|
|
11409
|
+
}
|
|
11410
|
+
const formatter = new Intl.NumberFormat([], {
|
|
11411
|
+
style: "percent",
|
|
11412
|
+
minimumFractionDigits: 2
|
|
11413
|
+
});
|
|
11414
|
+
const formatPercentage = (value, isPercentageValue = false) => {
|
|
11415
|
+
let val = value || 0;
|
|
11416
|
+
if (!isPercentageValue) {
|
|
11417
|
+
val = val / 100;
|
|
11418
|
+
}
|
|
11419
|
+
return formatter.format(val);
|
|
11373
11420
|
};
|
|
11374
|
-
|
|
11421
|
+
function getPromotionCodes(items, shippingMethods) {
|
|
11422
|
+
const codes = /* @__PURE__ */ new Set();
|
|
11423
|
+
for (const item of items) {
|
|
11424
|
+
if (item.adjustments) {
|
|
11425
|
+
for (const adjustment of item.adjustments) {
|
|
11426
|
+
if (adjustment.code) {
|
|
11427
|
+
codes.add(adjustment.code);
|
|
11428
|
+
}
|
|
11429
|
+
}
|
|
11430
|
+
}
|
|
11431
|
+
}
|
|
11432
|
+
for (const shippingMethod of shippingMethods) {
|
|
11433
|
+
if (shippingMethod.adjustments) {
|
|
11434
|
+
for (const adjustment of shippingMethod.adjustments) {
|
|
11435
|
+
if (adjustment.code) {
|
|
11436
|
+
codes.add(adjustment.code);
|
|
11437
|
+
}
|
|
11438
|
+
}
|
|
11439
|
+
}
|
|
11440
|
+
}
|
|
11441
|
+
return Array.from(codes);
|
|
11442
|
+
}
|
|
11375
11443
|
const SalesChannel = () => {
|
|
11376
11444
|
const { id } = reactRouterDom.useParams();
|
|
11377
11445
|
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
@@ -11400,7 +11468,7 @@ const SalesChannelForm = ({ order }) => {
|
|
|
11400
11468
|
defaultValues: {
|
|
11401
11469
|
sales_channel_id: order.sales_channel_id || ""
|
|
11402
11470
|
},
|
|
11403
|
-
resolver: zod.zodResolver(schema$
|
|
11471
|
+
resolver: zod.zodResolver(schema$2)
|
|
11404
11472
|
});
|
|
11405
11473
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11406
11474
|
const { handleSuccess } = useRouteModal();
|
|
@@ -11475,7 +11543,7 @@ const SalesChannelField = ({ control, order }) => {
|
|
|
11475
11543
|
}
|
|
11476
11544
|
);
|
|
11477
11545
|
};
|
|
11478
|
-
const schema$
|
|
11546
|
+
const schema$2 = objectType({
|
|
11479
11547
|
sales_channel_id: stringType().min(1)
|
|
11480
11548
|
});
|
|
11481
11549
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
@@ -12317,7 +12385,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12317
12385
|
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12318
12386
|
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12319
12387
|
},
|
|
12320
|
-
resolver: zod.zodResolver(schema$
|
|
12388
|
+
resolver: zod.zodResolver(schema$1)
|
|
12321
12389
|
});
|
|
12322
12390
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12323
12391
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12487,7 +12555,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12487
12555
|
}
|
|
12488
12556
|
) });
|
|
12489
12557
|
};
|
|
12490
|
-
const schema$
|
|
12558
|
+
const schema$1 = addressSchema;
|
|
12491
12559
|
const TransferOwnership = () => {
|
|
12492
12560
|
const { id } = reactRouterDom.useParams();
|
|
12493
12561
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -12511,7 +12579,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12511
12579
|
defaultValues: {
|
|
12512
12580
|
customer_id: order.customer_id || ""
|
|
12513
12581
|
},
|
|
12514
|
-
resolver: zod.zodResolver(schema
|
|
12582
|
+
resolver: zod.zodResolver(schema)
|
|
12515
12583
|
});
|
|
12516
12584
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12517
12585
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12961,76 +13029,8 @@ const Illustration = () => {
|
|
|
12961
13029
|
}
|
|
12962
13030
|
);
|
|
12963
13031
|
};
|
|
12964
|
-
const schema$1 = objectType({
|
|
12965
|
-
customer_id: stringType().min(1)
|
|
12966
|
-
});
|
|
12967
|
-
const Email = () => {
|
|
12968
|
-
const { id } = reactRouterDom.useParams();
|
|
12969
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
12970
|
-
fields: "+email"
|
|
12971
|
-
});
|
|
12972
|
-
if (isError) {
|
|
12973
|
-
throw error;
|
|
12974
|
-
}
|
|
12975
|
-
const isReady = !isPending && !!order;
|
|
12976
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12977
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12978
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
|
|
12979
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
12980
|
-
] }),
|
|
12981
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
|
|
12982
|
-
] });
|
|
12983
|
-
};
|
|
12984
|
-
const EmailForm = ({ order }) => {
|
|
12985
|
-
const form = reactHookForm.useForm({
|
|
12986
|
-
defaultValues: {
|
|
12987
|
-
email: order.email ?? ""
|
|
12988
|
-
},
|
|
12989
|
-
resolver: zod.zodResolver(schema)
|
|
12990
|
-
});
|
|
12991
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12992
|
-
const { handleSuccess } = useRouteModal();
|
|
12993
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12994
|
-
await mutateAsync(
|
|
12995
|
-
{ email: data.email },
|
|
12996
|
-
{
|
|
12997
|
-
onSuccess: () => {
|
|
12998
|
-
handleSuccess();
|
|
12999
|
-
},
|
|
13000
|
-
onError: (error) => {
|
|
13001
|
-
ui.toast.error(error.message);
|
|
13002
|
-
}
|
|
13003
|
-
}
|
|
13004
|
-
);
|
|
13005
|
-
});
|
|
13006
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
13007
|
-
KeyboundForm,
|
|
13008
|
-
{
|
|
13009
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
13010
|
-
onSubmit,
|
|
13011
|
-
children: [
|
|
13012
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13013
|
-
Form$2.Field,
|
|
13014
|
-
{
|
|
13015
|
-
control: form.control,
|
|
13016
|
-
name: "email",
|
|
13017
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
13018
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
|
|
13019
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
13020
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
13021
|
-
] })
|
|
13022
|
-
}
|
|
13023
|
-
) }),
|
|
13024
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13025
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
13026
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
13027
|
-
] }) })
|
|
13028
|
-
]
|
|
13029
|
-
}
|
|
13030
|
-
) });
|
|
13031
|
-
};
|
|
13032
13032
|
const schema = objectType({
|
|
13033
|
-
|
|
13033
|
+
customer_id: stringType().min(1)
|
|
13034
13034
|
});
|
|
13035
13035
|
const widgetModule = { widgets: [] };
|
|
13036
13036
|
const routeModule = {
|
|
@@ -13052,10 +13052,18 @@ const routeModule = {
|
|
|
13052
13052
|
handle,
|
|
13053
13053
|
loader,
|
|
13054
13054
|
children: [
|
|
13055
|
+
{
|
|
13056
|
+
Component: BillingAddress,
|
|
13057
|
+
path: "/draft-orders/:id/billing-address"
|
|
13058
|
+
},
|
|
13055
13059
|
{
|
|
13056
13060
|
Component: CustomItems,
|
|
13057
13061
|
path: "/draft-orders/:id/custom-items"
|
|
13058
13062
|
},
|
|
13063
|
+
{
|
|
13064
|
+
Component: Email,
|
|
13065
|
+
path: "/draft-orders/:id/email"
|
|
13066
|
+
},
|
|
13059
13067
|
{
|
|
13060
13068
|
Component: Items,
|
|
13061
13069
|
path: "/draft-orders/:id/items"
|
|
@@ -13068,10 +13076,6 @@ const routeModule = {
|
|
|
13068
13076
|
Component: Promotions,
|
|
13069
13077
|
path: "/draft-orders/:id/promotions"
|
|
13070
13078
|
},
|
|
13071
|
-
{
|
|
13072
|
-
Component: BillingAddress,
|
|
13073
|
-
path: "/draft-orders/:id/billing-address"
|
|
13074
|
-
},
|
|
13075
13079
|
{
|
|
13076
13080
|
Component: SalesChannel,
|
|
13077
13081
|
path: "/draft-orders/:id/sales-channel"
|
|
@@ -13087,10 +13091,6 @@ const routeModule = {
|
|
|
13087
13091
|
{
|
|
13088
13092
|
Component: TransferOwnership,
|
|
13089
13093
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13090
|
-
},
|
|
13091
|
-
{
|
|
13092
|
-
Component: Email,
|
|
13093
|
-
path: "/draft-orders/:id/email"
|
|
13094
13094
|
}
|
|
13095
13095
|
]
|
|
13096
13096
|
}
|