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