@medusajs/draft-order 2.11.2 → 2.11.3-preview-20251031120214
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 +599 -599
- package/.medusa/server/src/admin/index.mjs +599 -599
- package/package.json +24 -22
|
@@ -9586,264 +9586,6 @@ const CustomItemsForm = () => {
|
|
|
9586
9586
|
const schema$5 = objectType({
|
|
9587
9587
|
email: stringType().email()
|
|
9588
9588
|
});
|
|
9589
|
-
const Email = () => {
|
|
9590
|
-
const { id } = useParams();
|
|
9591
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
9592
|
-
fields: "+email"
|
|
9593
|
-
});
|
|
9594
|
-
if (isError) {
|
|
9595
|
-
throw error;
|
|
9596
|
-
}
|
|
9597
|
-
const isReady = !isPending && !!order;
|
|
9598
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9599
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
9600
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
|
|
9601
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
9602
|
-
] }),
|
|
9603
|
-
isReady && /* @__PURE__ */ jsx(EmailForm, { order })
|
|
9604
|
-
] });
|
|
9605
|
-
};
|
|
9606
|
-
const EmailForm = ({ order }) => {
|
|
9607
|
-
const form = useForm({
|
|
9608
|
-
defaultValues: {
|
|
9609
|
-
email: order.email ?? ""
|
|
9610
|
-
},
|
|
9611
|
-
resolver: zodResolver(schema$4)
|
|
9612
|
-
});
|
|
9613
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9614
|
-
const { handleSuccess } = useRouteModal();
|
|
9615
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
9616
|
-
await mutateAsync(
|
|
9617
|
-
{ email: data.email },
|
|
9618
|
-
{
|
|
9619
|
-
onSuccess: () => {
|
|
9620
|
-
handleSuccess();
|
|
9621
|
-
},
|
|
9622
|
-
onError: (error) => {
|
|
9623
|
-
toast.error(error.message);
|
|
9624
|
-
}
|
|
9625
|
-
}
|
|
9626
|
-
);
|
|
9627
|
-
});
|
|
9628
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
9629
|
-
KeyboundForm,
|
|
9630
|
-
{
|
|
9631
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
9632
|
-
onSubmit,
|
|
9633
|
-
children: [
|
|
9634
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
9635
|
-
Form$2.Field,
|
|
9636
|
-
{
|
|
9637
|
-
control: form.control,
|
|
9638
|
-
name: "email",
|
|
9639
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9640
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
|
|
9641
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9642
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9643
|
-
] })
|
|
9644
|
-
}
|
|
9645
|
-
) }),
|
|
9646
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9647
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9648
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9649
|
-
] }) })
|
|
9650
|
-
]
|
|
9651
|
-
}
|
|
9652
|
-
) });
|
|
9653
|
-
};
|
|
9654
|
-
const schema$4 = objectType({
|
|
9655
|
-
email: stringType().email()
|
|
9656
|
-
});
|
|
9657
|
-
const BillingAddress = () => {
|
|
9658
|
-
const { id } = useParams();
|
|
9659
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
9660
|
-
fields: "+billing_address"
|
|
9661
|
-
});
|
|
9662
|
-
if (isError) {
|
|
9663
|
-
throw error;
|
|
9664
|
-
}
|
|
9665
|
-
const isReady = !isPending && !!order;
|
|
9666
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9667
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
9668
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
|
|
9669
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
9670
|
-
] }),
|
|
9671
|
-
isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
|
|
9672
|
-
] });
|
|
9673
|
-
};
|
|
9674
|
-
const BillingAddressForm = ({ order }) => {
|
|
9675
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
9676
|
-
const form = useForm({
|
|
9677
|
-
defaultValues: {
|
|
9678
|
-
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
9679
|
-
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
9680
|
-
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
9681
|
-
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
9682
|
-
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
9683
|
-
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
9684
|
-
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
9685
|
-
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
9686
|
-
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9687
|
-
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9688
|
-
},
|
|
9689
|
-
resolver: zodResolver(schema$3)
|
|
9690
|
-
});
|
|
9691
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9692
|
-
const { handleSuccess } = useRouteModal();
|
|
9693
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
9694
|
-
await mutateAsync(
|
|
9695
|
-
{ billing_address: data },
|
|
9696
|
-
{
|
|
9697
|
-
onSuccess: () => {
|
|
9698
|
-
handleSuccess();
|
|
9699
|
-
},
|
|
9700
|
-
onError: (error) => {
|
|
9701
|
-
toast.error(error.message);
|
|
9702
|
-
}
|
|
9703
|
-
}
|
|
9704
|
-
);
|
|
9705
|
-
});
|
|
9706
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
9707
|
-
KeyboundForm,
|
|
9708
|
-
{
|
|
9709
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
9710
|
-
onSubmit,
|
|
9711
|
-
children: [
|
|
9712
|
-
/* @__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: [
|
|
9713
|
-
/* @__PURE__ */ jsx(
|
|
9714
|
-
Form$2.Field,
|
|
9715
|
-
{
|
|
9716
|
-
control: form.control,
|
|
9717
|
-
name: "country_code",
|
|
9718
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9719
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
9720
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
9721
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9722
|
-
] })
|
|
9723
|
-
}
|
|
9724
|
-
),
|
|
9725
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9726
|
-
/* @__PURE__ */ jsx(
|
|
9727
|
-
Form$2.Field,
|
|
9728
|
-
{
|
|
9729
|
-
control: form.control,
|
|
9730
|
-
name: "first_name",
|
|
9731
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9732
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
9733
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9734
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9735
|
-
] })
|
|
9736
|
-
}
|
|
9737
|
-
),
|
|
9738
|
-
/* @__PURE__ */ jsx(
|
|
9739
|
-
Form$2.Field,
|
|
9740
|
-
{
|
|
9741
|
-
control: form.control,
|
|
9742
|
-
name: "last_name",
|
|
9743
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9744
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
9745
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9746
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9747
|
-
] })
|
|
9748
|
-
}
|
|
9749
|
-
)
|
|
9750
|
-
] }),
|
|
9751
|
-
/* @__PURE__ */ jsx(
|
|
9752
|
-
Form$2.Field,
|
|
9753
|
-
{
|
|
9754
|
-
control: form.control,
|
|
9755
|
-
name: "company",
|
|
9756
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9757
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
9758
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9759
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9760
|
-
] })
|
|
9761
|
-
}
|
|
9762
|
-
),
|
|
9763
|
-
/* @__PURE__ */ jsx(
|
|
9764
|
-
Form$2.Field,
|
|
9765
|
-
{
|
|
9766
|
-
control: form.control,
|
|
9767
|
-
name: "address_1",
|
|
9768
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9769
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
9770
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9771
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9772
|
-
] })
|
|
9773
|
-
}
|
|
9774
|
-
),
|
|
9775
|
-
/* @__PURE__ */ jsx(
|
|
9776
|
-
Form$2.Field,
|
|
9777
|
-
{
|
|
9778
|
-
control: form.control,
|
|
9779
|
-
name: "address_2",
|
|
9780
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9781
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
9782
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9783
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9784
|
-
] })
|
|
9785
|
-
}
|
|
9786
|
-
),
|
|
9787
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9788
|
-
/* @__PURE__ */ jsx(
|
|
9789
|
-
Form$2.Field,
|
|
9790
|
-
{
|
|
9791
|
-
control: form.control,
|
|
9792
|
-
name: "postal_code",
|
|
9793
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9794
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
9795
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9796
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9797
|
-
] })
|
|
9798
|
-
}
|
|
9799
|
-
),
|
|
9800
|
-
/* @__PURE__ */ jsx(
|
|
9801
|
-
Form$2.Field,
|
|
9802
|
-
{
|
|
9803
|
-
control: form.control,
|
|
9804
|
-
name: "city",
|
|
9805
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9806
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
9807
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9808
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9809
|
-
] })
|
|
9810
|
-
}
|
|
9811
|
-
)
|
|
9812
|
-
] }),
|
|
9813
|
-
/* @__PURE__ */ jsx(
|
|
9814
|
-
Form$2.Field,
|
|
9815
|
-
{
|
|
9816
|
-
control: form.control,
|
|
9817
|
-
name: "province",
|
|
9818
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9819
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
9820
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9821
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9822
|
-
] })
|
|
9823
|
-
}
|
|
9824
|
-
),
|
|
9825
|
-
/* @__PURE__ */ jsx(
|
|
9826
|
-
Form$2.Field,
|
|
9827
|
-
{
|
|
9828
|
-
control: form.control,
|
|
9829
|
-
name: "phone",
|
|
9830
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9831
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
9832
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9833
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9834
|
-
] })
|
|
9835
|
-
}
|
|
9836
|
-
)
|
|
9837
|
-
] }) }),
|
|
9838
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9839
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9840
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9841
|
-
] }) })
|
|
9842
|
-
]
|
|
9843
|
-
}
|
|
9844
|
-
) });
|
|
9845
|
-
};
|
|
9846
|
-
const schema$3 = addressSchema;
|
|
9847
9589
|
const NumberInput = forwardRef(
|
|
9848
9590
|
({
|
|
9849
9591
|
value,
|
|
@@ -10728,96 +10470,373 @@ const CustomItemForm = ({ orderId, currencyCode }) => {
|
|
|
10728
10470
|
]
|
|
10729
10471
|
},
|
|
10730
10472
|
{
|
|
10731
|
-
onSuccess: () => {
|
|
10732
|
-
setIsOpen(STACKED_MODAL_ID, false);
|
|
10733
|
-
},
|
|
10473
|
+
onSuccess: () => {
|
|
10474
|
+
setIsOpen(STACKED_MODAL_ID, false);
|
|
10475
|
+
},
|
|
10476
|
+
onError: (e) => {
|
|
10477
|
+
toast.error(e.message);
|
|
10478
|
+
}
|
|
10479
|
+
}
|
|
10480
|
+
);
|
|
10481
|
+
});
|
|
10482
|
+
return /* @__PURE__ */ jsx(Form$2, { ...form, children: /* @__PURE__ */ jsx(KeyboundForm, { onSubmit, children: /* @__PURE__ */ jsxs(StackedFocusModal.Content, { children: [
|
|
10483
|
+
/* @__PURE__ */ jsx(StackedFocusModal.Header, {}),
|
|
10484
|
+
/* @__PURE__ */ jsx(StackedFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 px-2 py-16", children: [
|
|
10485
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
10486
|
+
/* @__PURE__ */ jsx(StackedFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Add custom item" }) }),
|
|
10487
|
+
/* @__PURE__ */ jsx(StackedFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Add a custom item to the order. This will add a new line item that is not associated with an existing product." }) })
|
|
10488
|
+
] }),
|
|
10489
|
+
/* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
|
|
10490
|
+
/* @__PURE__ */ jsx(
|
|
10491
|
+
Form$2.Field,
|
|
10492
|
+
{
|
|
10493
|
+
control: form.control,
|
|
10494
|
+
name: "title",
|
|
10495
|
+
render: ({ field }) => /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
10496
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
10497
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Title" }),
|
|
10498
|
+
/* @__PURE__ */ jsx(Form$2.Hint, { children: "Enter the title of the item" })
|
|
10499
|
+
] }),
|
|
10500
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
10501
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
10502
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10503
|
+
] })
|
|
10504
|
+
] }) })
|
|
10505
|
+
}
|
|
10506
|
+
),
|
|
10507
|
+
/* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
|
|
10508
|
+
/* @__PURE__ */ jsx(
|
|
10509
|
+
Form$2.Field,
|
|
10510
|
+
{
|
|
10511
|
+
control: form.control,
|
|
10512
|
+
name: "unit_price",
|
|
10513
|
+
render: ({ field: { onChange, ...field } }) => /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
10514
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
10515
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Unit price" }),
|
|
10516
|
+
/* @__PURE__ */ jsx(Form$2.Hint, { children: "Enter the unit price of the item" })
|
|
10517
|
+
] }),
|
|
10518
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
10519
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
10520
|
+
CurrencyInput,
|
|
10521
|
+
{
|
|
10522
|
+
symbol: getNativeSymbol(currencyCode),
|
|
10523
|
+
code: currencyCode,
|
|
10524
|
+
onValueChange: (_value, _name, values) => onChange(values == null ? void 0 : values.value),
|
|
10525
|
+
...field
|
|
10526
|
+
}
|
|
10527
|
+
) }),
|
|
10528
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10529
|
+
] })
|
|
10530
|
+
] }) })
|
|
10531
|
+
}
|
|
10532
|
+
),
|
|
10533
|
+
/* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
|
|
10534
|
+
/* @__PURE__ */ jsx(
|
|
10535
|
+
Form$2.Field,
|
|
10536
|
+
{
|
|
10537
|
+
control: form.control,
|
|
10538
|
+
name: "quantity",
|
|
10539
|
+
render: ({ field }) => /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
10540
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
10541
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Quantity" }),
|
|
10542
|
+
/* @__PURE__ */ jsx(Form$2.Hint, { children: "Enter the quantity of the item" })
|
|
10543
|
+
] }),
|
|
10544
|
+
/* @__PURE__ */ jsxs("div", { className: "w-full flex-1", children: [
|
|
10545
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx("div", { className: "w-full flex-1", children: /* @__PURE__ */ jsx(NumberInput, { ...field, className: "w-full" }) }) }),
|
|
10546
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10547
|
+
] })
|
|
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 PROMOTION_QUERY_KEY = "promotions";
|
|
10564
|
+
const promotionsQueryKeys = {
|
|
10565
|
+
list: (query2) => [
|
|
10566
|
+
PROMOTION_QUERY_KEY,
|
|
10567
|
+
query2 ? query2 : void 0
|
|
10568
|
+
],
|
|
10569
|
+
detail: (id, query2) => [
|
|
10570
|
+
PROMOTION_QUERY_KEY,
|
|
10571
|
+
id,
|
|
10572
|
+
query2 ? query2 : void 0
|
|
10573
|
+
]
|
|
10574
|
+
};
|
|
10575
|
+
const usePromotions = (query2, options) => {
|
|
10576
|
+
const { data, ...rest } = useQuery({
|
|
10577
|
+
queryKey: promotionsQueryKeys.list(query2),
|
|
10578
|
+
queryFn: async () => sdk.admin.promotion.list(query2),
|
|
10579
|
+
...options
|
|
10580
|
+
});
|
|
10581
|
+
return { ...data, ...rest };
|
|
10582
|
+
};
|
|
10583
|
+
const Promotions = () => {
|
|
10584
|
+
const { id } = useParams();
|
|
10585
|
+
const {
|
|
10586
|
+
order: preview,
|
|
10587
|
+
isError: isPreviewError,
|
|
10588
|
+
error: previewError
|
|
10589
|
+
} = useOrderPreview(id, void 0);
|
|
10590
|
+
useInitiateOrderEdit({ preview });
|
|
10591
|
+
const { onCancel } = useCancelOrderEdit({ preview });
|
|
10592
|
+
if (isPreviewError) {
|
|
10593
|
+
throw previewError;
|
|
10594
|
+
}
|
|
10595
|
+
const isReady = !!preview;
|
|
10596
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { onClose: onCancel, children: [
|
|
10597
|
+
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Promotions" }) }) }),
|
|
10598
|
+
isReady && /* @__PURE__ */ jsx(PromotionForm, { preview })
|
|
10599
|
+
] });
|
|
10600
|
+
};
|
|
10601
|
+
const PromotionForm = ({ preview }) => {
|
|
10602
|
+
const { items, shipping_methods } = preview;
|
|
10603
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
10604
|
+
const [comboboxValue, setComboboxValue] = useState("");
|
|
10605
|
+
const { handleSuccess } = useRouteModal();
|
|
10606
|
+
const { mutateAsync: addPromotions, isPending: isAddingPromotions } = useDraftOrderAddPromotions(preview.id);
|
|
10607
|
+
const promoIds = getPromotionIds(items, shipping_methods);
|
|
10608
|
+
const { promotions, isPending, isError, error } = usePromotions(
|
|
10609
|
+
{
|
|
10610
|
+
id: promoIds
|
|
10611
|
+
},
|
|
10612
|
+
{
|
|
10613
|
+
enabled: !!promoIds.length
|
|
10614
|
+
}
|
|
10615
|
+
);
|
|
10616
|
+
const comboboxData = useComboboxData({
|
|
10617
|
+
queryKey: ["promotions", "combobox", promoIds],
|
|
10618
|
+
queryFn: async (params) => {
|
|
10619
|
+
return await sdk.admin.promotion.list({
|
|
10620
|
+
...params,
|
|
10621
|
+
id: {
|
|
10622
|
+
$nin: promoIds
|
|
10623
|
+
}
|
|
10624
|
+
});
|
|
10625
|
+
},
|
|
10626
|
+
getOptions: (data) => {
|
|
10627
|
+
return data.promotions.map((promotion) => ({
|
|
10628
|
+
label: promotion.code,
|
|
10629
|
+
value: promotion.code
|
|
10630
|
+
}));
|
|
10631
|
+
}
|
|
10632
|
+
});
|
|
10633
|
+
const add = async (value) => {
|
|
10634
|
+
if (!value) {
|
|
10635
|
+
return;
|
|
10636
|
+
}
|
|
10637
|
+
addPromotions(
|
|
10638
|
+
{
|
|
10639
|
+
promo_codes: [value]
|
|
10640
|
+
},
|
|
10641
|
+
{
|
|
10734
10642
|
onError: (e) => {
|
|
10735
10643
|
toast.error(e.message);
|
|
10644
|
+
comboboxData.onSearchValueChange("");
|
|
10645
|
+
setComboboxValue("");
|
|
10646
|
+
},
|
|
10647
|
+
onSuccess: () => {
|
|
10648
|
+
comboboxData.onSearchValueChange("");
|
|
10649
|
+
setComboboxValue("");
|
|
10736
10650
|
}
|
|
10737
10651
|
}
|
|
10738
10652
|
);
|
|
10739
|
-
}
|
|
10740
|
-
|
|
10741
|
-
|
|
10742
|
-
|
|
10743
|
-
|
|
10744
|
-
|
|
10745
|
-
|
|
10653
|
+
};
|
|
10654
|
+
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
10655
|
+
const { mutateAsync: requestOrderEdit } = useOrderEditRequest(preview.id);
|
|
10656
|
+
const onSubmit = async () => {
|
|
10657
|
+
setIsSubmitting(true);
|
|
10658
|
+
let requestSucceeded = false;
|
|
10659
|
+
await requestOrderEdit(void 0, {
|
|
10660
|
+
onError: (e) => {
|
|
10661
|
+
toast.error(e.message);
|
|
10662
|
+
},
|
|
10663
|
+
onSuccess: () => {
|
|
10664
|
+
requestSucceeded = true;
|
|
10665
|
+
}
|
|
10666
|
+
});
|
|
10667
|
+
if (!requestSucceeded) {
|
|
10668
|
+
setIsSubmitting(false);
|
|
10669
|
+
return;
|
|
10670
|
+
}
|
|
10671
|
+
await confirmOrderEdit(void 0, {
|
|
10672
|
+
onError: (e) => {
|
|
10673
|
+
toast.error(e.message);
|
|
10674
|
+
},
|
|
10675
|
+
onSuccess: () => {
|
|
10676
|
+
handleSuccess();
|
|
10677
|
+
},
|
|
10678
|
+
onSettled: () => {
|
|
10679
|
+
setIsSubmitting(false);
|
|
10680
|
+
}
|
|
10681
|
+
});
|
|
10682
|
+
};
|
|
10683
|
+
if (isError) {
|
|
10684
|
+
throw error;
|
|
10685
|
+
}
|
|
10686
|
+
return /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", onSubmit, children: [
|
|
10687
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
10688
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
10689
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
10690
|
+
/* @__PURE__ */ jsx(Label$1, { size: "small", weight: "plus", htmlFor: "promotion-combobox", children: "Apply promotions" }),
|
|
10691
|
+
/* @__PURE__ */ jsx(Hint$1, { id: "promotion-combobox-hint", children: "Manage promotions that should be applied to the order." })
|
|
10692
|
+
] }),
|
|
10693
|
+
/* @__PURE__ */ jsx(
|
|
10694
|
+
Combobox,
|
|
10695
|
+
{
|
|
10696
|
+
id: "promotion-combobox",
|
|
10697
|
+
"aria-describedby": "promotion-combobox-hint",
|
|
10698
|
+
isFetchingNextPage: comboboxData.isFetchingNextPage,
|
|
10699
|
+
fetchNextPage: comboboxData.fetchNextPage,
|
|
10700
|
+
options: comboboxData.options,
|
|
10701
|
+
onSearchValueChange: comboboxData.onSearchValueChange,
|
|
10702
|
+
searchValue: comboboxData.searchValue,
|
|
10703
|
+
disabled: comboboxData.disabled || isAddingPromotions,
|
|
10704
|
+
onChange: add,
|
|
10705
|
+
value: comboboxValue
|
|
10706
|
+
}
|
|
10707
|
+
)
|
|
10746
10708
|
] }),
|
|
10747
10709
|
/* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
|
|
10710
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2", children: promotions == null ? void 0 : promotions.map((promotion) => /* @__PURE__ */ jsx(
|
|
10711
|
+
PromotionItem,
|
|
10712
|
+
{
|
|
10713
|
+
promotion,
|
|
10714
|
+
orderId: preview.id,
|
|
10715
|
+
isLoading: isPending
|
|
10716
|
+
},
|
|
10717
|
+
promotion.id
|
|
10718
|
+
)) })
|
|
10719
|
+
] }) }),
|
|
10720
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
10721
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
10748
10722
|
/* @__PURE__ */ jsx(
|
|
10749
|
-
|
|
10723
|
+
Button,
|
|
10750
10724
|
{
|
|
10751
|
-
|
|
10752
|
-
|
|
10753
|
-
|
|
10754
|
-
|
|
10755
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Title" }),
|
|
10756
|
-
/* @__PURE__ */ jsx(Form$2.Hint, { children: "Enter the title of the item" })
|
|
10757
|
-
] }),
|
|
10758
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
10759
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
10760
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10761
|
-
] })
|
|
10762
|
-
] }) })
|
|
10725
|
+
size: "small",
|
|
10726
|
+
type: "submit",
|
|
10727
|
+
isLoading: isSubmitting || isAddingPromotions,
|
|
10728
|
+
children: "Save"
|
|
10763
10729
|
}
|
|
10764
|
-
)
|
|
10765
|
-
|
|
10766
|
-
|
|
10767
|
-
|
|
10730
|
+
)
|
|
10731
|
+
] }) })
|
|
10732
|
+
] });
|
|
10733
|
+
};
|
|
10734
|
+
const PromotionItem = ({
|
|
10735
|
+
promotion,
|
|
10736
|
+
orderId,
|
|
10737
|
+
isLoading
|
|
10738
|
+
}) => {
|
|
10739
|
+
var _a;
|
|
10740
|
+
const { mutateAsync: removePromotions, isPending } = useDraftOrderRemovePromotions(orderId);
|
|
10741
|
+
const onRemove = async () => {
|
|
10742
|
+
removePromotions(
|
|
10743
|
+
{
|
|
10744
|
+
promo_codes: [promotion.code]
|
|
10745
|
+
},
|
|
10746
|
+
{
|
|
10747
|
+
onError: (e) => {
|
|
10748
|
+
toast.error(e.message);
|
|
10749
|
+
}
|
|
10750
|
+
}
|
|
10751
|
+
);
|
|
10752
|
+
};
|
|
10753
|
+
const displayValue = getDisplayValue(promotion);
|
|
10754
|
+
return /* @__PURE__ */ jsxs(
|
|
10755
|
+
"div",
|
|
10756
|
+
{
|
|
10757
|
+
className: clx(
|
|
10758
|
+
"bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2",
|
|
10768
10759
|
{
|
|
10769
|
-
|
|
10770
|
-
name: "unit_price",
|
|
10771
|
-
render: ({ field: { onChange, ...field } }) => /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
10772
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
10773
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Unit price" }),
|
|
10774
|
-
/* @__PURE__ */ jsx(Form$2.Hint, { children: "Enter the unit price of the item" })
|
|
10775
|
-
] }),
|
|
10776
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
10777
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
10778
|
-
CurrencyInput,
|
|
10779
|
-
{
|
|
10780
|
-
symbol: getNativeSymbol(currencyCode),
|
|
10781
|
-
code: currencyCode,
|
|
10782
|
-
onValueChange: (_value, _name, values) => onChange(values == null ? void 0 : values.value),
|
|
10783
|
-
...field
|
|
10784
|
-
}
|
|
10785
|
-
) }),
|
|
10786
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10787
|
-
] })
|
|
10788
|
-
] }) })
|
|
10760
|
+
"animate-pulse": isLoading
|
|
10789
10761
|
}
|
|
10790
10762
|
),
|
|
10791
|
-
|
|
10792
|
-
|
|
10793
|
-
|
|
10794
|
-
|
|
10795
|
-
|
|
10796
|
-
|
|
10797
|
-
|
|
10798
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
10799
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Quantity" }),
|
|
10800
|
-
/* @__PURE__ */ jsx(Form$2.Hint, { children: "Enter the quantity of the item" })
|
|
10763
|
+
children: [
|
|
10764
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
10765
|
+
/* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: promotion.code }),
|
|
10766
|
+
/* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle flex items-center gap-1.5", children: [
|
|
10767
|
+
displayValue && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
10768
|
+
/* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: displayValue }),
|
|
10769
|
+
/* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: "·" })
|
|
10801
10770
|
] }),
|
|
10802
|
-
/* @__PURE__ */
|
|
10803
|
-
|
|
10804
|
-
|
|
10805
|
-
|
|
10806
|
-
|
|
10807
|
-
|
|
10808
|
-
|
|
10809
|
-
|
|
10810
|
-
|
|
10811
|
-
|
|
10812
|
-
|
|
10813
|
-
|
|
10814
|
-
|
|
10771
|
+
/* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", className: "capitalize", children: (_a = promotion.application_method) == null ? void 0 : _a.allocation })
|
|
10772
|
+
] })
|
|
10773
|
+
] }),
|
|
10774
|
+
/* @__PURE__ */ jsx(
|
|
10775
|
+
IconButton,
|
|
10776
|
+
{
|
|
10777
|
+
size: "small",
|
|
10778
|
+
type: "button",
|
|
10779
|
+
variant: "transparent",
|
|
10780
|
+
onClick: onRemove,
|
|
10781
|
+
isLoading: isPending || isLoading,
|
|
10782
|
+
children: /* @__PURE__ */ jsx(XMark, {})
|
|
10783
|
+
}
|
|
10784
|
+
)
|
|
10785
|
+
]
|
|
10786
|
+
},
|
|
10787
|
+
promotion.id
|
|
10788
|
+
);
|
|
10815
10789
|
};
|
|
10816
|
-
|
|
10817
|
-
|
|
10818
|
-
|
|
10819
|
-
|
|
10790
|
+
function getDisplayValue(promotion) {
|
|
10791
|
+
var _a, _b, _c, _d;
|
|
10792
|
+
const value = (_a = promotion.application_method) == null ? void 0 : _a.value;
|
|
10793
|
+
if (!value) {
|
|
10794
|
+
return null;
|
|
10795
|
+
}
|
|
10796
|
+
if (((_b = promotion.application_method) == null ? void 0 : _b.type) === "fixed") {
|
|
10797
|
+
const currency = (_c = promotion.application_method) == null ? void 0 : _c.currency_code;
|
|
10798
|
+
if (!currency) {
|
|
10799
|
+
return null;
|
|
10800
|
+
}
|
|
10801
|
+
return getLocaleAmount(value, currency);
|
|
10802
|
+
} else if (((_d = promotion.application_method) == null ? void 0 : _d.type) === "percentage") {
|
|
10803
|
+
return formatPercentage(value);
|
|
10804
|
+
}
|
|
10805
|
+
return null;
|
|
10806
|
+
}
|
|
10807
|
+
const formatter = new Intl.NumberFormat([], {
|
|
10808
|
+
style: "percent",
|
|
10809
|
+
minimumFractionDigits: 2
|
|
10820
10810
|
});
|
|
10811
|
+
const formatPercentage = (value, isPercentageValue = false) => {
|
|
10812
|
+
let val = value || 0;
|
|
10813
|
+
if (!isPercentageValue) {
|
|
10814
|
+
val = val / 100;
|
|
10815
|
+
}
|
|
10816
|
+
return formatter.format(val);
|
|
10817
|
+
};
|
|
10818
|
+
function getPromotionIds(items, shippingMethods) {
|
|
10819
|
+
const promotionIds = /* @__PURE__ */ new Set();
|
|
10820
|
+
for (const item of items) {
|
|
10821
|
+
if (item.adjustments) {
|
|
10822
|
+
for (const adjustment of item.adjustments) {
|
|
10823
|
+
if (adjustment.promotion_id) {
|
|
10824
|
+
promotionIds.add(adjustment.promotion_id);
|
|
10825
|
+
}
|
|
10826
|
+
}
|
|
10827
|
+
}
|
|
10828
|
+
}
|
|
10829
|
+
for (const shippingMethod of shippingMethods) {
|
|
10830
|
+
if (shippingMethod.adjustments) {
|
|
10831
|
+
for (const adjustment of shippingMethod.adjustments) {
|
|
10832
|
+
if (adjustment.promotion_id) {
|
|
10833
|
+
promotionIds.add(adjustment.promotion_id);
|
|
10834
|
+
}
|
|
10835
|
+
}
|
|
10836
|
+
}
|
|
10837
|
+
}
|
|
10838
|
+
return Array.from(promotionIds);
|
|
10839
|
+
}
|
|
10821
10840
|
const InlineTip = forwardRef(
|
|
10822
10841
|
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
10823
10842
|
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
@@ -11196,7 +11215,7 @@ const SalesChannelForm = ({ order }) => {
|
|
|
11196
11215
|
defaultValues: {
|
|
11197
11216
|
sales_channel_id: order.sales_channel_id || ""
|
|
11198
11217
|
},
|
|
11199
|
-
resolver: zodResolver(schema$
|
|
11218
|
+
resolver: zodResolver(schema$4)
|
|
11200
11219
|
});
|
|
11201
11220
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11202
11221
|
const { handleSuccess } = useRouteModal();
|
|
@@ -11271,7 +11290,7 @@ const SalesChannelField = ({ control, order }) => {
|
|
|
11271
11290
|
}
|
|
11272
11291
|
);
|
|
11273
11292
|
};
|
|
11274
|
-
const schema$
|
|
11293
|
+
const schema$4 = objectType({
|
|
11275
11294
|
sales_channel_id: stringType().min(1)
|
|
11276
11295
|
});
|
|
11277
11296
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
@@ -12113,7 +12132,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12113
12132
|
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12114
12133
|
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12115
12134
|
},
|
|
12116
|
-
resolver: zodResolver(schema$
|
|
12135
|
+
resolver: zodResolver(schema$3)
|
|
12117
12136
|
});
|
|
12118
12137
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12119
12138
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12283,7 +12302,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12283
12302
|
}
|
|
12284
12303
|
) });
|
|
12285
12304
|
};
|
|
12286
|
-
const schema$
|
|
12305
|
+
const schema$3 = addressSchema;
|
|
12287
12306
|
const TransferOwnership = () => {
|
|
12288
12307
|
const { id } = useParams();
|
|
12289
12308
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -12307,7 +12326,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12307
12326
|
defaultValues: {
|
|
12308
12327
|
customer_id: order.customer_id || ""
|
|
12309
12328
|
},
|
|
12310
|
-
resolver: zodResolver(schema)
|
|
12329
|
+
resolver: zodResolver(schema$2)
|
|
12311
12330
|
});
|
|
12312
12331
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12313
12332
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12757,286 +12776,267 @@ const Illustration = () => {
|
|
|
12757
12776
|
}
|
|
12758
12777
|
);
|
|
12759
12778
|
};
|
|
12760
|
-
const schema = objectType({
|
|
12779
|
+
const schema$2 = objectType({
|
|
12761
12780
|
customer_id: stringType().min(1)
|
|
12762
12781
|
});
|
|
12763
|
-
const
|
|
12764
|
-
const promotionsQueryKeys = {
|
|
12765
|
-
list: (query2) => [
|
|
12766
|
-
PROMOTION_QUERY_KEY,
|
|
12767
|
-
query2 ? query2 : void 0
|
|
12768
|
-
],
|
|
12769
|
-
detail: (id, query2) => [
|
|
12770
|
-
PROMOTION_QUERY_KEY,
|
|
12771
|
-
id,
|
|
12772
|
-
query2 ? query2 : void 0
|
|
12773
|
-
]
|
|
12774
|
-
};
|
|
12775
|
-
const usePromotions = (query2, options) => {
|
|
12776
|
-
const { data, ...rest } = useQuery({
|
|
12777
|
-
queryKey: promotionsQueryKeys.list(query2),
|
|
12778
|
-
queryFn: async () => sdk.admin.promotion.list(query2),
|
|
12779
|
-
...options
|
|
12780
|
-
});
|
|
12781
|
-
return { ...data, ...rest };
|
|
12782
|
-
};
|
|
12783
|
-
const Promotions = () => {
|
|
12782
|
+
const Email = () => {
|
|
12784
12783
|
const { id } = useParams();
|
|
12785
|
-
const {
|
|
12786
|
-
|
|
12787
|
-
|
|
12788
|
-
|
|
12789
|
-
|
|
12790
|
-
useInitiateOrderEdit({ preview });
|
|
12791
|
-
const { onCancel } = useCancelOrderEdit({ preview });
|
|
12792
|
-
if (isPreviewError) {
|
|
12793
|
-
throw previewError;
|
|
12784
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
12785
|
+
fields: "+email"
|
|
12786
|
+
});
|
|
12787
|
+
if (isError) {
|
|
12788
|
+
throw error;
|
|
12794
12789
|
}
|
|
12795
|
-
const isReady = !!
|
|
12796
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, {
|
|
12797
|
-
/* @__PURE__ */
|
|
12798
|
-
|
|
12790
|
+
const isReady = !isPending && !!order;
|
|
12791
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12792
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12793
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
|
|
12794
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
12795
|
+
] }),
|
|
12796
|
+
isReady && /* @__PURE__ */ jsx(EmailForm, { order })
|
|
12799
12797
|
] });
|
|
12800
12798
|
};
|
|
12801
|
-
const
|
|
12802
|
-
const
|
|
12803
|
-
|
|
12804
|
-
|
|
12805
|
-
const { handleSuccess } = useRouteModal();
|
|
12806
|
-
const { mutateAsync: addPromotions, isPending: isAddingPromotions } = useDraftOrderAddPromotions(preview.id);
|
|
12807
|
-
const promoIds = getPromotionIds(items, shipping_methods);
|
|
12808
|
-
const { promotions, isPending, isError, error } = usePromotions(
|
|
12809
|
-
{
|
|
12810
|
-
id: promoIds
|
|
12811
|
-
},
|
|
12812
|
-
{
|
|
12813
|
-
enabled: !!promoIds.length
|
|
12814
|
-
}
|
|
12815
|
-
);
|
|
12816
|
-
const comboboxData = useComboboxData({
|
|
12817
|
-
queryKey: ["promotions", "combobox", promoIds],
|
|
12818
|
-
queryFn: async (params) => {
|
|
12819
|
-
return await sdk.admin.promotion.list({
|
|
12820
|
-
...params,
|
|
12821
|
-
id: {
|
|
12822
|
-
$nin: promoIds
|
|
12823
|
-
}
|
|
12824
|
-
});
|
|
12799
|
+
const EmailForm = ({ order }) => {
|
|
12800
|
+
const form = useForm({
|
|
12801
|
+
defaultValues: {
|
|
12802
|
+
email: order.email ?? ""
|
|
12825
12803
|
},
|
|
12826
|
-
|
|
12827
|
-
return data.promotions.map((promotion) => ({
|
|
12828
|
-
label: promotion.code,
|
|
12829
|
-
value: promotion.code
|
|
12830
|
-
}));
|
|
12831
|
-
}
|
|
12804
|
+
resolver: zodResolver(schema$1)
|
|
12832
12805
|
});
|
|
12833
|
-
const
|
|
12834
|
-
|
|
12835
|
-
|
|
12836
|
-
|
|
12837
|
-
|
|
12838
|
-
{
|
|
12839
|
-
promo_codes: [value]
|
|
12840
|
-
},
|
|
12806
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12807
|
+
const { handleSuccess } = useRouteModal();
|
|
12808
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12809
|
+
await mutateAsync(
|
|
12810
|
+
{ email: data.email },
|
|
12841
12811
|
{
|
|
12842
|
-
onError: (e) => {
|
|
12843
|
-
toast.error(e.message);
|
|
12844
|
-
comboboxData.onSearchValueChange("");
|
|
12845
|
-
setComboboxValue("");
|
|
12846
|
-
},
|
|
12847
12812
|
onSuccess: () => {
|
|
12848
|
-
|
|
12849
|
-
|
|
12813
|
+
handleSuccess();
|
|
12814
|
+
},
|
|
12815
|
+
onError: (error) => {
|
|
12816
|
+
toast.error(error.message);
|
|
12850
12817
|
}
|
|
12851
12818
|
}
|
|
12852
12819
|
);
|
|
12853
|
-
};
|
|
12854
|
-
|
|
12855
|
-
|
|
12856
|
-
|
|
12857
|
-
|
|
12858
|
-
|
|
12859
|
-
|
|
12860
|
-
|
|
12861
|
-
|
|
12862
|
-
|
|
12863
|
-
|
|
12864
|
-
|
|
12865
|
-
|
|
12866
|
-
|
|
12867
|
-
|
|
12868
|
-
|
|
12869
|
-
|
|
12820
|
+
});
|
|
12821
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12822
|
+
KeyboundForm,
|
|
12823
|
+
{
|
|
12824
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12825
|
+
onSubmit,
|
|
12826
|
+
children: [
|
|
12827
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
12828
|
+
Form$2.Field,
|
|
12829
|
+
{
|
|
12830
|
+
control: form.control,
|
|
12831
|
+
name: "email",
|
|
12832
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12833
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
|
|
12834
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12835
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12836
|
+
] })
|
|
12837
|
+
}
|
|
12838
|
+
) }),
|
|
12839
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12840
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12841
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12842
|
+
] }) })
|
|
12843
|
+
]
|
|
12870
12844
|
}
|
|
12871
|
-
|
|
12872
|
-
|
|
12873
|
-
|
|
12874
|
-
|
|
12875
|
-
|
|
12876
|
-
|
|
12877
|
-
|
|
12878
|
-
|
|
12879
|
-
|
|
12880
|
-
|
|
12881
|
-
});
|
|
12882
|
-
};
|
|
12845
|
+
) });
|
|
12846
|
+
};
|
|
12847
|
+
const schema$1 = objectType({
|
|
12848
|
+
email: stringType().email()
|
|
12849
|
+
});
|
|
12850
|
+
const BillingAddress = () => {
|
|
12851
|
+
const { id } = useParams();
|
|
12852
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
12853
|
+
fields: "+billing_address"
|
|
12854
|
+
});
|
|
12883
12855
|
if (isError) {
|
|
12884
12856
|
throw error;
|
|
12885
12857
|
}
|
|
12886
|
-
|
|
12887
|
-
|
|
12888
|
-
|
|
12889
|
-
|
|
12890
|
-
|
|
12891
|
-
|
|
12892
|
-
|
|
12893
|
-
/* @__PURE__ */ jsx(
|
|
12894
|
-
Combobox,
|
|
12895
|
-
{
|
|
12896
|
-
id: "promotion-combobox",
|
|
12897
|
-
"aria-describedby": "promotion-combobox-hint",
|
|
12898
|
-
isFetchingNextPage: comboboxData.isFetchingNextPage,
|
|
12899
|
-
fetchNextPage: comboboxData.fetchNextPage,
|
|
12900
|
-
options: comboboxData.options,
|
|
12901
|
-
onSearchValueChange: comboboxData.onSearchValueChange,
|
|
12902
|
-
searchValue: comboboxData.searchValue,
|
|
12903
|
-
disabled: comboboxData.disabled || isAddingPromotions,
|
|
12904
|
-
onChange: add,
|
|
12905
|
-
value: comboboxValue
|
|
12906
|
-
}
|
|
12907
|
-
)
|
|
12908
|
-
] }),
|
|
12909
|
-
/* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
|
|
12910
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2", children: promotions == null ? void 0 : promotions.map((promotion) => /* @__PURE__ */ jsx(
|
|
12911
|
-
PromotionItem,
|
|
12912
|
-
{
|
|
12913
|
-
promotion,
|
|
12914
|
-
orderId: preview.id,
|
|
12915
|
-
isLoading: isPending
|
|
12916
|
-
},
|
|
12917
|
-
promotion.id
|
|
12918
|
-
)) })
|
|
12919
|
-
] }) }),
|
|
12920
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12921
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12922
|
-
/* @__PURE__ */ jsx(
|
|
12923
|
-
Button,
|
|
12924
|
-
{
|
|
12925
|
-
size: "small",
|
|
12926
|
-
type: "submit",
|
|
12927
|
-
isLoading: isSubmitting || isAddingPromotions,
|
|
12928
|
-
children: "Save"
|
|
12929
|
-
}
|
|
12930
|
-
)
|
|
12931
|
-
] }) })
|
|
12858
|
+
const isReady = !isPending && !!order;
|
|
12859
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12860
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12861
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
|
|
12862
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
12863
|
+
] }),
|
|
12864
|
+
isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
|
|
12932
12865
|
] });
|
|
12933
12866
|
};
|
|
12934
|
-
const
|
|
12935
|
-
|
|
12936
|
-
|
|
12937
|
-
|
|
12938
|
-
|
|
12939
|
-
|
|
12940
|
-
|
|
12941
|
-
|
|
12942
|
-
|
|
12943
|
-
|
|
12944
|
-
|
|
12945
|
-
|
|
12867
|
+
const BillingAddressForm = ({ order }) => {
|
|
12868
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12869
|
+
const form = useForm({
|
|
12870
|
+
defaultValues: {
|
|
12871
|
+
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12872
|
+
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12873
|
+
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
12874
|
+
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12875
|
+
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12876
|
+
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
12877
|
+
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
12878
|
+
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12879
|
+
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12880
|
+
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
12881
|
+
},
|
|
12882
|
+
resolver: zodResolver(schema)
|
|
12883
|
+
});
|
|
12884
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12885
|
+
const { handleSuccess } = useRouteModal();
|
|
12886
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12887
|
+
await mutateAsync(
|
|
12888
|
+
{ billing_address: data },
|
|
12946
12889
|
{
|
|
12947
|
-
|
|
12948
|
-
|
|
12890
|
+
onSuccess: () => {
|
|
12891
|
+
handleSuccess();
|
|
12892
|
+
},
|
|
12893
|
+
onError: (error) => {
|
|
12894
|
+
toast.error(error.message);
|
|
12949
12895
|
}
|
|
12950
12896
|
}
|
|
12951
12897
|
);
|
|
12952
|
-
};
|
|
12953
|
-
|
|
12954
|
-
|
|
12955
|
-
"div",
|
|
12898
|
+
});
|
|
12899
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12900
|
+
KeyboundForm,
|
|
12956
12901
|
{
|
|
12957
|
-
className:
|
|
12958
|
-
|
|
12959
|
-
{
|
|
12960
|
-
"animate-pulse": isLoading
|
|
12961
|
-
}
|
|
12962
|
-
),
|
|
12902
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12903
|
+
onSubmit,
|
|
12963
12904
|
children: [
|
|
12964
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
12965
|
-
/* @__PURE__ */ jsx(
|
|
12966
|
-
|
|
12967
|
-
|
|
12968
|
-
|
|
12969
|
-
|
|
12970
|
-
|
|
12971
|
-
|
|
12972
|
-
|
|
12973
|
-
|
|
12974
|
-
|
|
12975
|
-
|
|
12976
|
-
|
|
12977
|
-
|
|
12978
|
-
|
|
12979
|
-
|
|
12980
|
-
|
|
12981
|
-
|
|
12982
|
-
|
|
12983
|
-
|
|
12984
|
-
|
|
12905
|
+
/* @__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: [
|
|
12906
|
+
/* @__PURE__ */ jsx(
|
|
12907
|
+
Form$2.Field,
|
|
12908
|
+
{
|
|
12909
|
+
control: form.control,
|
|
12910
|
+
name: "country_code",
|
|
12911
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12912
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
12913
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
12914
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12915
|
+
] })
|
|
12916
|
+
}
|
|
12917
|
+
),
|
|
12918
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12919
|
+
/* @__PURE__ */ jsx(
|
|
12920
|
+
Form$2.Field,
|
|
12921
|
+
{
|
|
12922
|
+
control: form.control,
|
|
12923
|
+
name: "first_name",
|
|
12924
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12925
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
12926
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12927
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12928
|
+
] })
|
|
12929
|
+
}
|
|
12930
|
+
),
|
|
12931
|
+
/* @__PURE__ */ jsx(
|
|
12932
|
+
Form$2.Field,
|
|
12933
|
+
{
|
|
12934
|
+
control: form.control,
|
|
12935
|
+
name: "last_name",
|
|
12936
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12937
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
12938
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12939
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12940
|
+
] })
|
|
12941
|
+
}
|
|
12942
|
+
)
|
|
12943
|
+
] }),
|
|
12944
|
+
/* @__PURE__ */ jsx(
|
|
12945
|
+
Form$2.Field,
|
|
12946
|
+
{
|
|
12947
|
+
control: form.control,
|
|
12948
|
+
name: "company",
|
|
12949
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12950
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12951
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12952
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12953
|
+
] })
|
|
12954
|
+
}
|
|
12955
|
+
),
|
|
12956
|
+
/* @__PURE__ */ jsx(
|
|
12957
|
+
Form$2.Field,
|
|
12958
|
+
{
|
|
12959
|
+
control: form.control,
|
|
12960
|
+
name: "address_1",
|
|
12961
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12962
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
12963
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12964
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12965
|
+
] })
|
|
12966
|
+
}
|
|
12967
|
+
),
|
|
12968
|
+
/* @__PURE__ */ jsx(
|
|
12969
|
+
Form$2.Field,
|
|
12970
|
+
{
|
|
12971
|
+
control: form.control,
|
|
12972
|
+
name: "address_2",
|
|
12973
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12974
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12975
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12976
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12977
|
+
] })
|
|
12978
|
+
}
|
|
12979
|
+
),
|
|
12980
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12981
|
+
/* @__PURE__ */ jsx(
|
|
12982
|
+
Form$2.Field,
|
|
12983
|
+
{
|
|
12984
|
+
control: form.control,
|
|
12985
|
+
name: "postal_code",
|
|
12986
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12987
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
12988
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12989
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12990
|
+
] })
|
|
12991
|
+
}
|
|
12992
|
+
),
|
|
12993
|
+
/* @__PURE__ */ jsx(
|
|
12994
|
+
Form$2.Field,
|
|
12995
|
+
{
|
|
12996
|
+
control: form.control,
|
|
12997
|
+
name: "city",
|
|
12998
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12999
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
13000
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13001
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13002
|
+
] })
|
|
13003
|
+
}
|
|
13004
|
+
)
|
|
13005
|
+
] }),
|
|
13006
|
+
/* @__PURE__ */ jsx(
|
|
13007
|
+
Form$2.Field,
|
|
13008
|
+
{
|
|
13009
|
+
control: form.control,
|
|
13010
|
+
name: "province",
|
|
13011
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13012
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
13013
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13014
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13015
|
+
] })
|
|
13016
|
+
}
|
|
13017
|
+
),
|
|
13018
|
+
/* @__PURE__ */ jsx(
|
|
13019
|
+
Form$2.Field,
|
|
13020
|
+
{
|
|
13021
|
+
control: form.control,
|
|
13022
|
+
name: "phone",
|
|
13023
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13024
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
13025
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13026
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13027
|
+
] })
|
|
13028
|
+
}
|
|
13029
|
+
)
|
|
13030
|
+
] }) }),
|
|
13031
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13032
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
13033
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
13034
|
+
] }) })
|
|
12985
13035
|
]
|
|
12986
|
-
},
|
|
12987
|
-
promotion.id
|
|
12988
|
-
);
|
|
12989
|
-
};
|
|
12990
|
-
function getDisplayValue(promotion) {
|
|
12991
|
-
var _a, _b, _c, _d;
|
|
12992
|
-
const value = (_a = promotion.application_method) == null ? void 0 : _a.value;
|
|
12993
|
-
if (!value) {
|
|
12994
|
-
return null;
|
|
12995
|
-
}
|
|
12996
|
-
if (((_b = promotion.application_method) == null ? void 0 : _b.type) === "fixed") {
|
|
12997
|
-
const currency = (_c = promotion.application_method) == null ? void 0 : _c.currency_code;
|
|
12998
|
-
if (!currency) {
|
|
12999
|
-
return null;
|
|
13000
13036
|
}
|
|
13001
|
-
|
|
13002
|
-
} else if (((_d = promotion.application_method) == null ? void 0 : _d.type) === "percentage") {
|
|
13003
|
-
return formatPercentage(value);
|
|
13004
|
-
}
|
|
13005
|
-
return null;
|
|
13006
|
-
}
|
|
13007
|
-
const formatter = new Intl.NumberFormat([], {
|
|
13008
|
-
style: "percent",
|
|
13009
|
-
minimumFractionDigits: 2
|
|
13010
|
-
});
|
|
13011
|
-
const formatPercentage = (value, isPercentageValue = false) => {
|
|
13012
|
-
let val = value || 0;
|
|
13013
|
-
if (!isPercentageValue) {
|
|
13014
|
-
val = val / 100;
|
|
13015
|
-
}
|
|
13016
|
-
return formatter.format(val);
|
|
13037
|
+
) });
|
|
13017
13038
|
};
|
|
13018
|
-
|
|
13019
|
-
const promotionIds = /* @__PURE__ */ new Set();
|
|
13020
|
-
for (const item of items) {
|
|
13021
|
-
if (item.adjustments) {
|
|
13022
|
-
for (const adjustment of item.adjustments) {
|
|
13023
|
-
if (adjustment.promotion_id) {
|
|
13024
|
-
promotionIds.add(adjustment.promotion_id);
|
|
13025
|
-
}
|
|
13026
|
-
}
|
|
13027
|
-
}
|
|
13028
|
-
}
|
|
13029
|
-
for (const shippingMethod of shippingMethods) {
|
|
13030
|
-
if (shippingMethod.adjustments) {
|
|
13031
|
-
for (const adjustment of shippingMethod.adjustments) {
|
|
13032
|
-
if (adjustment.promotion_id) {
|
|
13033
|
-
promotionIds.add(adjustment.promotion_id);
|
|
13034
|
-
}
|
|
13035
|
-
}
|
|
13036
|
-
}
|
|
13037
|
-
}
|
|
13038
|
-
return Array.from(promotionIds);
|
|
13039
|
-
}
|
|
13039
|
+
const schema = addressSchema;
|
|
13040
13040
|
const widgetModule = { widgets: [] };
|
|
13041
13041
|
const routeModule = {
|
|
13042
13042
|
routes: [
|
|
@@ -13061,18 +13061,14 @@ const routeModule = {
|
|
|
13061
13061
|
Component: CustomItems,
|
|
13062
13062
|
path: "/draft-orders/:id/custom-items"
|
|
13063
13063
|
},
|
|
13064
|
-
{
|
|
13065
|
-
Component: Email,
|
|
13066
|
-
path: "/draft-orders/:id/email"
|
|
13067
|
-
},
|
|
13068
|
-
{
|
|
13069
|
-
Component: BillingAddress,
|
|
13070
|
-
path: "/draft-orders/:id/billing-address"
|
|
13071
|
-
},
|
|
13072
13064
|
{
|
|
13073
13065
|
Component: Items,
|
|
13074
13066
|
path: "/draft-orders/:id/items"
|
|
13075
13067
|
},
|
|
13068
|
+
{
|
|
13069
|
+
Component: Promotions,
|
|
13070
|
+
path: "/draft-orders/:id/promotions"
|
|
13071
|
+
},
|
|
13076
13072
|
{
|
|
13077
13073
|
Component: Metadata,
|
|
13078
13074
|
path: "/draft-orders/:id/metadata"
|
|
@@ -13094,8 +13090,12 @@ const routeModule = {
|
|
|
13094
13090
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13095
13091
|
},
|
|
13096
13092
|
{
|
|
13097
|
-
Component:
|
|
13098
|
-
path: "/draft-orders/:id/
|
|
13093
|
+
Component: Email,
|
|
13094
|
+
path: "/draft-orders/:id/email"
|
|
13095
|
+
},
|
|
13096
|
+
{
|
|
13097
|
+
Component: BillingAddress,
|
|
13098
|
+
path: "/draft-orders/:id/billing-address"
|
|
13099
13099
|
}
|
|
13100
13100
|
]
|
|
13101
13101
|
}
|