@medusajs/draft-order 2.11.2-preview-20251026090153 → 2.11.2-snapshot-20251026124930

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.
@@ -9565,217 +9565,6 @@ const ID = () => {
9565
9565
  /* @__PURE__ */ jsx(Outlet, {})
9566
9566
  ] });
9567
9567
  };
9568
- const BillingAddress = () => {
9569
- const { id } = useParams();
9570
- const { order, isPending, isError, error } = useOrder(id, {
9571
- fields: "+billing_address"
9572
- });
9573
- if (isError) {
9574
- throw error;
9575
- }
9576
- const isReady = !isPending && !!order;
9577
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9578
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
9579
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
9580
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9581
- ] }),
9582
- isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
9583
- ] });
9584
- };
9585
- const BillingAddressForm = ({ order }) => {
9586
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9587
- const form = useForm({
9588
- defaultValues: {
9589
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9590
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9591
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9592
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9593
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9594
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9595
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9596
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9597
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9598
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9599
- },
9600
- resolver: zodResolver(schema$5)
9601
- });
9602
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9603
- const { handleSuccess } = useRouteModal();
9604
- const onSubmit = form.handleSubmit(async (data) => {
9605
- await mutateAsync(
9606
- { billing_address: data },
9607
- {
9608
- onSuccess: () => {
9609
- handleSuccess();
9610
- },
9611
- onError: (error) => {
9612
- toast.error(error.message);
9613
- }
9614
- }
9615
- );
9616
- });
9617
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
9618
- KeyboundForm,
9619
- {
9620
- className: "flex flex-1 flex-col overflow-hidden",
9621
- onSubmit,
9622
- children: [
9623
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
9624
- /* @__PURE__ */ jsx(
9625
- Form$2.Field,
9626
- {
9627
- control: form.control,
9628
- name: "country_code",
9629
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9630
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
9631
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
9632
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9633
- ] })
9634
- }
9635
- ),
9636
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9637
- /* @__PURE__ */ jsx(
9638
- Form$2.Field,
9639
- {
9640
- control: form.control,
9641
- name: "first_name",
9642
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9643
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
9644
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9645
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9646
- ] })
9647
- }
9648
- ),
9649
- /* @__PURE__ */ jsx(
9650
- Form$2.Field,
9651
- {
9652
- control: form.control,
9653
- name: "last_name",
9654
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9655
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
9656
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9657
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9658
- ] })
9659
- }
9660
- )
9661
- ] }),
9662
- /* @__PURE__ */ jsx(
9663
- Form$2.Field,
9664
- {
9665
- control: form.control,
9666
- name: "company",
9667
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9668
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
9669
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9670
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9671
- ] })
9672
- }
9673
- ),
9674
- /* @__PURE__ */ jsx(
9675
- Form$2.Field,
9676
- {
9677
- control: form.control,
9678
- name: "address_1",
9679
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9680
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
9681
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9682
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9683
- ] })
9684
- }
9685
- ),
9686
- /* @__PURE__ */ jsx(
9687
- Form$2.Field,
9688
- {
9689
- control: form.control,
9690
- name: "address_2",
9691
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9692
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9693
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9694
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9695
- ] })
9696
- }
9697
- ),
9698
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9699
- /* @__PURE__ */ jsx(
9700
- Form$2.Field,
9701
- {
9702
- control: form.control,
9703
- name: "postal_code",
9704
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9705
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
9706
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9707
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9708
- ] })
9709
- }
9710
- ),
9711
- /* @__PURE__ */ jsx(
9712
- Form$2.Field,
9713
- {
9714
- control: form.control,
9715
- name: "city",
9716
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9717
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
9718
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9719
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9720
- ] })
9721
- }
9722
- )
9723
- ] }),
9724
- /* @__PURE__ */ jsx(
9725
- Form$2.Field,
9726
- {
9727
- control: form.control,
9728
- name: "province",
9729
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9730
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9731
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9732
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9733
- ] })
9734
- }
9735
- ),
9736
- /* @__PURE__ */ jsx(
9737
- Form$2.Field,
9738
- {
9739
- control: form.control,
9740
- name: "phone",
9741
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9742
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
9743
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9744
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9745
- ] })
9746
- }
9747
- )
9748
- ] }) }),
9749
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9750
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9751
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9752
- ] }) })
9753
- ]
9754
- }
9755
- ) });
9756
- };
9757
- const schema$5 = addressSchema;
9758
- const CustomItems = () => {
9759
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9760
- /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9761
- /* @__PURE__ */ jsx(CustomItemsForm, {})
9762
- ] });
9763
- };
9764
- const CustomItemsForm = () => {
9765
- const form = useForm({
9766
- resolver: zodResolver(schema$4)
9767
- });
9768
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9769
- /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
9770
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9771
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9772
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
9773
- ] }) })
9774
- ] }) });
9775
- };
9776
- const schema$4 = objectType({
9777
- email: stringType().email()
9778
- });
9779
9568
  const Email = () => {
9780
9569
  const { id } = useParams();
9781
9570
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9798,7 +9587,7 @@ const EmailForm = ({ order }) => {
9798
9587
  defaultValues: {
9799
9588
  email: order.email ?? ""
9800
9589
  },
9801
- resolver: zodResolver(schema$3)
9590
+ resolver: zodResolver(schema$5)
9802
9591
  });
9803
9592
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9804
9593
  const { handleSuccess } = useRouteModal();
@@ -9841,7 +9630,7 @@ const EmailForm = ({ order }) => {
9841
9630
  }
9842
9631
  ) });
9843
9632
  };
9844
- const schema$3 = objectType({
9633
+ const schema$5 = objectType({
9845
9634
  email: stringType().email()
9846
9635
  });
9847
9636
  const NumberInput = forwardRef(
@@ -11445,6 +11234,27 @@ function getPromotionIds(items, shippingMethods) {
11445
11234
  }
11446
11235
  return Array.from(promotionIds);
11447
11236
  }
11237
+ const CustomItems = () => {
11238
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11239
+ /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
11240
+ /* @__PURE__ */ jsx(CustomItemsForm, {})
11241
+ ] });
11242
+ };
11243
+ const CustomItemsForm = () => {
11244
+ const form = useForm({
11245
+ resolver: zodResolver(schema$4)
11246
+ });
11247
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
11248
+ /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
11249
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11250
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11251
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
11252
+ ] }) })
11253
+ ] }) });
11254
+ };
11255
+ const schema$4 = objectType({
11256
+ email: stringType().email()
11257
+ });
11448
11258
  const SalesChannel = () => {
11449
11259
  const { id } = useParams();
11450
11260
  const { draft_order, isPending, isError, error } = useDraftOrder(
@@ -11473,7 +11283,7 @@ const SalesChannelForm = ({ order }) => {
11473
11283
  defaultValues: {
11474
11284
  sales_channel_id: order.sales_channel_id || ""
11475
11285
  },
11476
- resolver: zodResolver(schema$2)
11286
+ resolver: zodResolver(schema$3)
11477
11287
  });
11478
11288
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11479
11289
  const { handleSuccess } = useRouteModal();
@@ -11548,845 +11358,166 @@ const SalesChannelField = ({ control, order }) => {
11548
11358
  }
11549
11359
  );
11550
11360
  };
11551
- const schema$2 = objectType({
11361
+ const schema$3 = objectType({
11552
11362
  sales_channel_id: stringType().min(1)
11553
11363
  });
11554
- const ShippingAddress = () => {
11364
+ const STACKED_FOCUS_MODAL_ID = "shipping-form";
11365
+ const Shipping = () => {
11366
+ var _a;
11555
11367
  const { id } = useParams();
11556
11368
  const { order, isPending, isError, error } = useOrder(id, {
11557
- fields: "+shipping_address"
11369
+ fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
11558
11370
  });
11371
+ const {
11372
+ order: preview,
11373
+ isPending: isPreviewPending,
11374
+ isError: isPreviewError,
11375
+ error: previewError
11376
+ } = useOrderPreview(id);
11377
+ useInitiateOrderEdit({ preview });
11378
+ const { onCancel } = useCancelOrderEdit({ preview });
11559
11379
  if (isError) {
11560
11380
  throw error;
11561
11381
  }
11562
- const isReady = !isPending && !!order;
11563
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11564
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11565
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
11566
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
11567
- ] }),
11568
- isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
11569
- ] });
11382
+ if (isPreviewError) {
11383
+ throw previewError;
11384
+ }
11385
+ const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
11386
+ const isReady = preview && !isPreviewPending && order && !isPending;
11387
+ return /* @__PURE__ */ jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
11388
+ /* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
11389
+ /* @__PURE__ */ jsx(RouteFocusModal.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 py-16 px-6", children: [
11390
+ /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
11391
+ /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
11392
+ ] }) }) }),
11393
+ /* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
11394
+ ] }) : isReady ? /* @__PURE__ */ jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxs("div", { children: [
11395
+ /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
11396
+ /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
11397
+ ] }) });
11570
11398
  };
11571
- const ShippingAddressForm = ({ order }) => {
11572
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11573
- const form = useForm({
11574
- defaultValues: {
11575
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
11576
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
11577
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
11578
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
11579
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
11580
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
11581
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
11582
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
11583
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
11584
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
11399
+ const ShippingForm = ({ preview, order }) => {
11400
+ var _a;
11401
+ const { setIsOpen } = useStackedModal();
11402
+ const [isSubmitting, setIsSubmitting] = useState(false);
11403
+ const [data, setData] = useState(null);
11404
+ const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
11405
+ const { shipping_options } = useShippingOptions(
11406
+ {
11407
+ id: appliedShippingOptionIds,
11408
+ fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
11585
11409
  },
11586
- resolver: zodResolver(schema$1)
11587
- });
11588
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11410
+ {
11411
+ enabled: appliedShippingOptionIds.length > 0
11412
+ }
11413
+ );
11414
+ const uniqueShippingProfiles = useMemo(() => {
11415
+ const profiles = /* @__PURE__ */ new Map();
11416
+ getUniqueShippingProfiles(order.items).forEach((profile) => {
11417
+ profiles.set(profile.id, profile);
11418
+ });
11419
+ shipping_options == null ? void 0 : shipping_options.forEach((option) => {
11420
+ profiles.set(option.shipping_profile_id, option.shipping_profile);
11421
+ });
11422
+ return Array.from(profiles.values());
11423
+ }, [order.items, shipping_options]);
11589
11424
  const { handleSuccess } = useRouteModal();
11590
- const onSubmit = form.handleSubmit(async (data) => {
11591
- await mutateAsync(
11592
- {
11593
- shipping_address: {
11594
- first_name: data.first_name,
11595
- last_name: data.last_name,
11596
- company: data.company,
11597
- address_1: data.address_1,
11598
- address_2: data.address_2,
11599
- city: data.city,
11600
- province: data.province,
11601
- country_code: data.country_code,
11602
- postal_code: data.postal_code,
11603
- phone: data.phone
11604
- }
11425
+ const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
11426
+ const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
11427
+ const { mutateAsync: removeShippingMethod } = useDraftOrderRemoveShippingMethod(preview.id);
11428
+ const { mutateAsync: removeActionShippingMethod } = useDraftOrderRemoveActionShippingMethod(preview.id);
11429
+ const onSubmit = async () => {
11430
+ setIsSubmitting(true);
11431
+ let requestSucceeded = false;
11432
+ await requestOrderEdit(void 0, {
11433
+ onError: (e) => {
11434
+ toast.error(`Failed to request order edit: ${e.message}`);
11605
11435
  },
11606
- {
11607
- onSuccess: () => {
11608
- handleSuccess();
11609
- },
11610
- onError: (error) => {
11611
- toast.error(error.message);
11436
+ onSuccess: () => {
11437
+ requestSucceeded = true;
11438
+ }
11439
+ });
11440
+ if (!requestSucceeded) {
11441
+ setIsSubmitting(false);
11442
+ return;
11443
+ }
11444
+ await confirmOrderEdit(void 0, {
11445
+ onError: (e) => {
11446
+ toast.error(`Failed to confirm order edit: ${e.message}`);
11447
+ },
11448
+ onSuccess: () => {
11449
+ handleSuccess();
11450
+ },
11451
+ onSettled: () => {
11452
+ setIsSubmitting(false);
11453
+ }
11454
+ });
11455
+ };
11456
+ const onKeydown = useCallback(
11457
+ (e) => {
11458
+ if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
11459
+ if (data || isSubmitting) {
11460
+ return;
11612
11461
  }
11462
+ onSubmit();
11613
11463
  }
11614
- );
11615
- });
11616
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11617
- KeyboundForm,
11618
- {
11619
- className: "flex flex-1 flex-col overflow-hidden",
11620
- onSubmit,
11621
- children: [
11622
- /* @__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: [
11623
- /* @__PURE__ */ jsx(
11624
- Form$2.Field,
11625
- {
11626
- control: form.control,
11627
- name: "country_code",
11628
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11629
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
11630
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
11631
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11632
- ] })
11633
- }
11634
- ),
11635
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11464
+ },
11465
+ [data, isSubmitting, onSubmit]
11466
+ );
11467
+ useEffect(() => {
11468
+ document.addEventListener("keydown", onKeydown);
11469
+ return () => {
11470
+ document.removeEventListener("keydown", onKeydown);
11471
+ };
11472
+ }, [onKeydown]);
11473
+ return /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
11474
+ /* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
11475
+ /* @__PURE__ */ jsxs(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: [
11476
+ /* @__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 py-16 px-6", children: [
11477
+ /* @__PURE__ */ jsxs("div", { children: [
11478
+ /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
11479
+ /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Choose which shipping method(s) to use for the items in the order." }) })
11480
+ ] }),
11481
+ /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
11482
+ /* @__PURE__ */ jsx(Accordion.Root, { type: "multiple", children: /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle rounded-xl shadow-elevation-card-rest", children: [
11483
+ /* @__PURE__ */ jsxs("div", { className: "px-4 py-2 flex items-center justify-between", children: [
11636
11484
  /* @__PURE__ */ jsx(
11637
- Form$2.Field,
11485
+ Text,
11638
11486
  {
11639
- control: form.control,
11640
- name: "first_name",
11641
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11642
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
11643
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11644
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11645
- ] })
11487
+ size: "xsmall",
11488
+ weight: "plus",
11489
+ className: "text-ui-fg-muted",
11490
+ children: "Shipping profile"
11646
11491
  }
11647
11492
  ),
11648
11493
  /* @__PURE__ */ jsx(
11649
- Form$2.Field,
11494
+ Text,
11650
11495
  {
11651
- control: form.control,
11652
- name: "last_name",
11653
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11654
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
11655
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11656
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11657
- ] })
11496
+ size: "xsmall",
11497
+ weight: "plus",
11498
+ className: "text-ui-fg-muted",
11499
+ children: "Action"
11658
11500
  }
11659
11501
  )
11660
11502
  ] }),
11661
- /* @__PURE__ */ jsx(
11662
- Form$2.Field,
11663
- {
11664
- control: form.control,
11665
- name: "company",
11666
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11667
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
11668
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11669
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11670
- ] })
11671
- }
11672
- ),
11673
- /* @__PURE__ */ jsx(
11674
- Form$2.Field,
11675
- {
11676
- control: form.control,
11677
- name: "address_1",
11678
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11679
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
11680
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11681
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11682
- ] })
11683
- }
11684
- ),
11685
- /* @__PURE__ */ jsx(
11686
- Form$2.Field,
11687
- {
11688
- control: form.control,
11689
- name: "address_2",
11690
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11691
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11692
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11693
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11694
- ] })
11695
- }
11696
- ),
11697
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11698
- /* @__PURE__ */ jsx(
11699
- Form$2.Field,
11700
- {
11701
- control: form.control,
11702
- name: "postal_code",
11703
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11704
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
11705
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11706
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11707
- ] })
11708
- }
11709
- ),
11710
- /* @__PURE__ */ jsx(
11711
- Form$2.Field,
11712
- {
11713
- control: form.control,
11714
- name: "city",
11715
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11716
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
11717
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11718
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11719
- ] })
11720
- }
11721
- )
11722
- ] }),
11723
- /* @__PURE__ */ jsx(
11724
- Form$2.Field,
11725
- {
11726
- control: form.control,
11727
- name: "province",
11728
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11729
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11730
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11731
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11732
- ] })
11733
- }
11734
- ),
11735
- /* @__PURE__ */ jsx(
11736
- Form$2.Field,
11737
- {
11738
- control: form.control,
11739
- name: "phone",
11740
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11741
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
11742
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11743
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11744
- ] })
11745
- }
11746
- )
11747
- ] }) }),
11748
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11749
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11750
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11751
- ] }) })
11752
- ]
11753
- }
11754
- ) });
11755
- };
11756
- const schema$1 = addressSchema;
11757
- const TransferOwnership = () => {
11758
- const { id } = useParams();
11759
- const { draft_order, isPending, isError, error } = useDraftOrder(id, {
11760
- fields: "id,customer_id,customer.*"
11761
- });
11762
- if (isError) {
11763
- throw error;
11764
- }
11765
- const isReady = !isPending && !!draft_order;
11766
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11767
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11768
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Ownership" }) }),
11769
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Transfer the ownership of this draft order to a new customer" }) })
11770
- ] }),
11771
- isReady && /* @__PURE__ */ jsx(TransferOwnershipForm, { order: draft_order })
11772
- ] });
11773
- };
11774
- const TransferOwnershipForm = ({ order }) => {
11775
- var _a, _b;
11776
- const form = useForm({
11777
- defaultValues: {
11778
- customer_id: order.customer_id || ""
11779
- },
11780
- resolver: zodResolver(schema)
11781
- });
11782
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11783
- const { handleSuccess } = useRouteModal();
11784
- const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
11785
- const currentCustomer = order.customer ? {
11786
- label: name ? `${name} (${order.customer.email})` : order.customer.email,
11787
- value: order.customer.id
11788
- } : null;
11789
- const onSubmit = form.handleSubmit(async (data) => {
11790
- await mutateAsync(
11791
- { customer_id: data.customer_id },
11792
- {
11793
- onSuccess: () => {
11794
- toast.success("Customer updated");
11795
- handleSuccess();
11796
- },
11797
- onError: (error) => {
11798
- toast.error(error.message);
11799
- }
11800
- }
11801
- );
11802
- });
11803
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11804
- KeyboundForm,
11805
- {
11806
- className: "flex flex-1 flex-col overflow-hidden",
11807
- onSubmit,
11808
- children: [
11809
- /* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
11810
- /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsx(Illustration, {}) }),
11811
- currentCustomer && /* @__PURE__ */ jsxs("div", { className: "flex flex-col space-y-3", children: [
11812
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
11813
- /* @__PURE__ */ jsx(Label$1, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
11814
- /* @__PURE__ */ jsx(Hint$1, { children: "The customer that is currently associated with this draft order." })
11815
- ] }),
11816
- /* @__PURE__ */ jsxs(Select, { disabled: true, value: currentCustomer.value, children: [
11817
- /* @__PURE__ */ jsx(Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsx(Select.Value, {}) }),
11818
- /* @__PURE__ */ jsx(Select.Content, { children: /* @__PURE__ */ jsx(Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
11819
- ] })
11820
- ] }),
11821
- /* @__PURE__ */ jsx(
11822
- CustomerField,
11823
- {
11824
- control: form.control,
11825
- currentCustomerId: order.customer_id
11826
- }
11827
- )
11828
- ] }),
11829
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
11830
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "secondary", size: "small", children: "Cancel" }) }),
11831
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11832
- ] }) })
11833
- ]
11834
- }
11835
- ) });
11836
- };
11837
- const CustomerField = ({ control, currentCustomerId }) => {
11838
- const customers = useComboboxData({
11839
- queryFn: async (params) => {
11840
- return await sdk.admin.customer.list({
11841
- ...params,
11842
- id: currentCustomerId ? { $nin: [currentCustomerId] } : void 0
11843
- });
11844
- },
11845
- queryKey: ["customers"],
11846
- getOptions: (data) => {
11847
- return data.customers.map((customer) => {
11848
- const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
11849
- return {
11850
- label: name ? `${name} (${customer.email})` : customer.email,
11851
- value: customer.id
11852
- };
11853
- });
11854
- }
11855
- });
11856
- return /* @__PURE__ */ jsx(
11857
- Form$2.Field,
11858
- {
11859
- name: "customer_id",
11860
- control,
11861
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { className: "space-y-3", children: [
11862
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
11863
- /* @__PURE__ */ jsx(Form$2.Label, { children: "New customer" }),
11864
- /* @__PURE__ */ jsx(Form$2.Hint, { children: "The customer to transfer this draft order to." })
11865
- ] }),
11866
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
11867
- Combobox,
11868
- {
11869
- options: customers.options,
11870
- fetchNextPage: customers.fetchNextPage,
11871
- isFetchingNextPage: customers.isFetchingNextPage,
11872
- searchValue: customers.searchValue,
11873
- onSearchValueChange: customers.onSearchValueChange,
11874
- placeholder: "Select customer",
11875
- ...field
11876
- }
11877
- ) }),
11878
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11879
- ] })
11880
- }
11881
- );
11882
- };
11883
- const Illustration = () => {
11884
- return /* @__PURE__ */ jsxs(
11885
- "svg",
11886
- {
11887
- width: "280",
11888
- height: "180",
11889
- viewBox: "0 0 280 180",
11890
- fill: "none",
11891
- xmlns: "http://www.w3.org/2000/svg",
11892
- children: [
11893
- /* @__PURE__ */ jsx(
11894
- "rect",
11895
- {
11896
- x: "0.00428286",
11897
- y: "-0.742904",
11898
- width: "33.5",
11899
- height: "65.5",
11900
- rx: "6.75",
11901
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 88.438)",
11902
- fill: "#D4D4D8",
11903
- stroke: "#52525B",
11904
- strokeWidth: "1.5"
11905
- }
11906
- ),
11907
- /* @__PURE__ */ jsx(
11908
- "rect",
11909
- {
11910
- x: "0.00428286",
11911
- y: "-0.742904",
11912
- width: "33.5",
11913
- height: "65.5",
11914
- rx: "6.75",
11915
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 85.4381)",
11916
- fill: "white",
11917
- stroke: "#52525B",
11918
- strokeWidth: "1.5"
11919
- }
11920
- ),
11921
- /* @__PURE__ */ jsx(
11922
- "path",
11923
- {
11924
- d: "M180.579 107.142L179.126 107.959",
11925
- stroke: "#52525B",
11926
- strokeWidth: "1.5",
11927
- strokeLinecap: "round",
11928
- strokeLinejoin: "round"
11929
- }
11930
- ),
11931
- /* @__PURE__ */ jsx(
11932
- "path",
11933
- {
11934
- opacity: "0.88",
11935
- d: "M182.305 109.546L180.257 109.534",
11936
- stroke: "#52525B",
11937
- strokeWidth: "1.5",
11938
- strokeLinecap: "round",
11939
- strokeLinejoin: "round"
11940
- }
11941
- ),
11942
- /* @__PURE__ */ jsx(
11943
- "path",
11944
- {
11945
- opacity: "0.75",
11946
- d: "M180.551 111.93L179.108 111.096",
11947
- stroke: "#52525B",
11948
- strokeWidth: "1.5",
11949
- strokeLinecap: "round",
11950
- strokeLinejoin: "round"
11951
- }
11952
- ),
11953
- /* @__PURE__ */ jsx(
11954
- "path",
11955
- {
11956
- opacity: "0.63",
11957
- d: "M176.347 112.897L176.354 111.73",
11958
- stroke: "#52525B",
11959
- strokeWidth: "1.5",
11960
- strokeLinecap: "round",
11961
- strokeLinejoin: "round"
11962
- }
11963
- ),
11964
- /* @__PURE__ */ jsx(
11965
- "path",
11966
- {
11967
- opacity: "0.5",
11968
- d: "M172.153 111.881L173.606 111.064",
11969
- stroke: "#52525B",
11970
- strokeWidth: "1.5",
11971
- strokeLinecap: "round",
11972
- strokeLinejoin: "round"
11973
- }
11974
- ),
11975
- /* @__PURE__ */ jsx(
11976
- "path",
11977
- {
11978
- opacity: "0.38",
11979
- d: "M170.428 109.478L172.476 109.489",
11980
- stroke: "#52525B",
11981
- strokeWidth: "1.5",
11982
- strokeLinecap: "round",
11983
- strokeLinejoin: "round"
11984
- }
11985
- ),
11986
- /* @__PURE__ */ jsx(
11987
- "path",
11988
- {
11989
- opacity: "0.25",
11990
- d: "M172.181 107.094L173.624 107.928",
11991
- stroke: "#52525B",
11992
- strokeWidth: "1.5",
11993
- strokeLinecap: "round",
11994
- strokeLinejoin: "round"
11995
- }
11996
- ),
11997
- /* @__PURE__ */ jsx(
11998
- "path",
11999
- {
12000
- opacity: "0.13",
12001
- d: "M176.386 106.126L176.379 107.294",
12002
- stroke: "#52525B",
12003
- strokeWidth: "1.5",
12004
- strokeLinecap: "round",
12005
- strokeLinejoin: "round"
12006
- }
12007
- ),
12008
- /* @__PURE__ */ jsx(
12009
- "rect",
12010
- {
12011
- width: "12",
12012
- height: "3",
12013
- rx: "1.5",
12014
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 196.447 92.2925)",
12015
- fill: "#D4D4D8"
12016
- }
12017
- ),
12018
- /* @__PURE__ */ jsx(
12019
- "rect",
12020
- {
12021
- x: "0.00428286",
12022
- y: "-0.742904",
12023
- width: "33.5",
12024
- height: "65.5",
12025
- rx: "6.75",
12026
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 46.4147)",
12027
- fill: "#D4D4D8",
12028
- stroke: "#52525B",
12029
- strokeWidth: "1.5"
12030
- }
12031
- ),
12032
- /* @__PURE__ */ jsx(
12033
- "rect",
12034
- {
12035
- x: "0.00428286",
12036
- y: "-0.742904",
12037
- width: "33.5",
12038
- height: "65.5",
12039
- rx: "6.75",
12040
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 43.4147)",
12041
- fill: "white",
12042
- stroke: "#52525B",
12043
- strokeWidth: "1.5"
12044
- }
12045
- ),
12046
- /* @__PURE__ */ jsx(
12047
- "rect",
12048
- {
12049
- width: "12",
12050
- height: "3",
12051
- rx: "1.5",
12052
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 123.714 50.2691)",
12053
- fill: "#D4D4D8"
12054
- }
12055
- ),
12056
- /* @__PURE__ */ jsx(
12057
- "rect",
12058
- {
12059
- width: "17",
12060
- height: "3",
12061
- rx: "1.5",
12062
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 97.5557 66.958)",
12063
- fill: "#D4D4D8"
12064
- }
12065
- ),
12066
- /* @__PURE__ */ jsx(
12067
- "rect",
12068
- {
12069
- width: "12",
12070
- height: "3",
12071
- rx: "1.5",
12072
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 93.1978 69.4093)",
12073
- fill: "#D4D4D8"
12074
- }
12075
- ),
12076
- /* @__PURE__ */ jsx(
12077
- "path",
12078
- {
12079
- d: "M92.3603 63.9563C90.9277 63.1286 88.59 63.1152 87.148 63.9263C85.7059 64.7374 85.6983 66.0702 87.1308 66.8979C88.5634 67.7256 90.9011 67.7391 92.3432 66.928C93.7852 66.1168 93.7929 64.784 92.3603 63.9563ZM88.4382 66.1625C87.7221 65.7488 87.726 65.0822 88.4468 64.6767C89.1676 64.2713 90.3369 64.278 91.0529 64.6917C91.769 65.1055 91.7652 65.7721 91.0444 66.1775C90.3236 66.583 89.1543 66.5762 88.4382 66.1625Z",
12080
- fill: "#A1A1AA"
12081
- }
12082
- ),
12083
- /* @__PURE__ */ jsx(
12084
- "rect",
12085
- {
12086
- width: "17",
12087
- height: "3",
12088
- rx: "1.5",
12089
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 109.758 60.0944)",
12090
- fill: "#A1A1AA"
12091
- }
12092
- ),
12093
- /* @__PURE__ */ jsx(
12094
- "rect",
12095
- {
12096
- width: "12",
12097
- height: "3",
12098
- rx: "1.5",
12099
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 105.4 62.5457)",
12100
- fill: "#A1A1AA"
12101
- }
12102
- ),
12103
- /* @__PURE__ */ jsx(
12104
- "path",
12105
- {
12106
- d: "M104.562 57.0927C103.13 56.265 100.792 56.2515 99.3501 57.0626C97.9081 57.8738 97.9004 59.2065 99.333 60.0343C100.766 60.862 103.103 60.8754 104.545 60.0643C105.987 59.2532 105.995 57.9204 104.562 57.0927ZM103.858 58.8972L100.815 59.1265C100.683 59.1367 100.55 59.1134 100.449 59.063C100.44 59.0585 100.432 59.0545 100.425 59.05C100.339 59.0005 100.29 58.9336 100.291 58.8637L100.294 58.1201C100.294 57.9752 100.501 57.8585 100.756 57.86C101.01 57.8615 101.217 57.98 101.216 58.1256L101.214 58.5669L103.732 58.3769C103.984 58.3578 104.217 58.4584 104.251 58.603C104.286 58.7468 104.11 58.8788 103.858 58.8977L103.858 58.8972Z",
12107
- fill: "#52525B"
12108
- }
12109
- ),
12110
- /* @__PURE__ */ jsx("g", { clipPath: "url(#clip0_20915_38670)", children: /* @__PURE__ */ jsx(
12111
- "path",
12112
- {
12113
- d: "M133.106 81.8022L140.49 81.8447L140.515 77.6349",
12114
- stroke: "#A1A1AA",
12115
- strokeWidth: "1.5",
12116
- strokeLinecap: "round",
12117
- strokeLinejoin: "round"
12118
- }
12119
- ) }),
12120
- /* @__PURE__ */ jsx("g", { clipPath: "url(#clip1_20915_38670)", children: /* @__PURE__ */ jsx(
12121
- "path",
12122
- {
12123
- d: "M143.496 87.8055L150.881 87.8481L150.905 83.6383",
12124
- stroke: "#A1A1AA",
12125
- strokeWidth: "1.5",
12126
- strokeLinecap: "round",
12127
- strokeLinejoin: "round"
12128
- }
12129
- ) }),
12130
- /* @__PURE__ */ jsx("g", { clipPath: "url(#clip2_20915_38670)", children: /* @__PURE__ */ jsx(
12131
- "path",
12132
- {
12133
- d: "M153.887 93.8088L161.271 93.8514L161.295 89.6416",
12134
- stroke: "#A1A1AA",
12135
- strokeWidth: "1.5",
12136
- strokeLinecap: "round",
12137
- strokeLinejoin: "round"
12138
- }
12139
- ) }),
12140
- /* @__PURE__ */ jsx("g", { clipPath: "url(#clip3_20915_38670)", children: /* @__PURE__ */ jsx(
12141
- "path",
12142
- {
12143
- d: "M126.114 89.1912L118.729 89.1486L118.705 93.3584",
12144
- stroke: "#A1A1AA",
12145
- strokeWidth: "1.5",
12146
- strokeLinecap: "round",
12147
- strokeLinejoin: "round"
12148
- }
12149
- ) }),
12150
- /* @__PURE__ */ jsx("g", { clipPath: "url(#clip4_20915_38670)", children: /* @__PURE__ */ jsx(
12151
- "path",
12152
- {
12153
- d: "M136.504 95.1945L129.12 95.1519L129.095 99.3617",
12154
- stroke: "#A1A1AA",
12155
- strokeWidth: "1.5",
12156
- strokeLinecap: "round",
12157
- strokeLinejoin: "round"
12158
- }
12159
- ) }),
12160
- /* @__PURE__ */ jsx("g", { clipPath: "url(#clip5_20915_38670)", children: /* @__PURE__ */ jsx(
12161
- "path",
12162
- {
12163
- d: "M146.894 101.198L139.51 101.155L139.486 105.365",
12164
- stroke: "#A1A1AA",
12165
- strokeWidth: "1.5",
12166
- strokeLinecap: "round",
12167
- strokeLinejoin: "round"
12168
- }
12169
- ) }),
12170
- /* @__PURE__ */ jsxs("defs", { children: [
12171
- /* @__PURE__ */ jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsx(
12172
- "rect",
12173
- {
12174
- width: "12",
12175
- height: "12",
12176
- fill: "white",
12177
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
12178
- }
12179
- ) }),
12180
- /* @__PURE__ */ jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsx(
12181
- "rect",
12182
- {
12183
- width: "12",
12184
- height: "12",
12185
- fill: "white",
12186
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
12187
- }
12188
- ) }),
12189
- /* @__PURE__ */ jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsx(
12190
- "rect",
12191
- {
12192
- width: "12",
12193
- height: "12",
12194
- fill: "white",
12195
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
12196
- }
12197
- ) }),
12198
- /* @__PURE__ */ jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsx(
12199
- "rect",
12200
- {
12201
- width: "12",
12202
- height: "12",
12203
- fill: "white",
12204
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
12205
- }
12206
- ) }),
12207
- /* @__PURE__ */ jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsx(
12208
- "rect",
12209
- {
12210
- width: "12",
12211
- height: "12",
12212
- fill: "white",
12213
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
12214
- }
12215
- ) }),
12216
- /* @__PURE__ */ jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsx(
12217
- "rect",
12218
- {
12219
- width: "12",
12220
- height: "12",
12221
- fill: "white",
12222
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
12223
- }
12224
- ) })
12225
- ] })
12226
- ]
12227
- }
12228
- );
12229
- };
12230
- const schema = objectType({
12231
- customer_id: stringType().min(1)
12232
- });
12233
- const STACKED_FOCUS_MODAL_ID = "shipping-form";
12234
- const Shipping = () => {
12235
- var _a;
12236
- const { id } = useParams();
12237
- const { order, isPending, isError, error } = useOrder(id, {
12238
- fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
12239
- });
12240
- const {
12241
- order: preview,
12242
- isPending: isPreviewPending,
12243
- isError: isPreviewError,
12244
- error: previewError
12245
- } = useOrderPreview(id);
12246
- useInitiateOrderEdit({ preview });
12247
- const { onCancel } = useCancelOrderEdit({ preview });
12248
- if (isError) {
12249
- throw error;
12250
- }
12251
- if (isPreviewError) {
12252
- throw previewError;
12253
- }
12254
- const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
12255
- const isReady = preview && !isPreviewPending && order && !isPending;
12256
- return /* @__PURE__ */ jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
12257
- /* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
12258
- /* @__PURE__ */ jsx(RouteFocusModal.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 py-16 px-6", children: [
12259
- /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
12260
- /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
12261
- ] }) }) }),
12262
- /* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
12263
- ] }) : isReady ? /* @__PURE__ */ jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxs("div", { children: [
12264
- /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
12265
- /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
12266
- ] }) });
12267
- };
12268
- const ShippingForm = ({ preview, order }) => {
12269
- var _a;
12270
- const { setIsOpen } = useStackedModal();
12271
- const [isSubmitting, setIsSubmitting] = useState(false);
12272
- const [data, setData] = useState(null);
12273
- const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
12274
- const { shipping_options } = useShippingOptions(
12275
- {
12276
- id: appliedShippingOptionIds,
12277
- fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
12278
- },
12279
- {
12280
- enabled: appliedShippingOptionIds.length > 0
12281
- }
12282
- );
12283
- const uniqueShippingProfiles = useMemo(() => {
12284
- const profiles = /* @__PURE__ */ new Map();
12285
- getUniqueShippingProfiles(order.items).forEach((profile) => {
12286
- profiles.set(profile.id, profile);
12287
- });
12288
- shipping_options == null ? void 0 : shipping_options.forEach((option) => {
12289
- profiles.set(option.shipping_profile_id, option.shipping_profile);
12290
- });
12291
- return Array.from(profiles.values());
12292
- }, [order.items, shipping_options]);
12293
- const { handleSuccess } = useRouteModal();
12294
- const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
12295
- const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
12296
- const { mutateAsync: removeShippingMethod } = useDraftOrderRemoveShippingMethod(preview.id);
12297
- const { mutateAsync: removeActionShippingMethod } = useDraftOrderRemoveActionShippingMethod(preview.id);
12298
- const onSubmit = async () => {
12299
- setIsSubmitting(true);
12300
- let requestSucceeded = false;
12301
- await requestOrderEdit(void 0, {
12302
- onError: (e) => {
12303
- toast.error(`Failed to request order edit: ${e.message}`);
12304
- },
12305
- onSuccess: () => {
12306
- requestSucceeded = true;
12307
- }
12308
- });
12309
- if (!requestSucceeded) {
12310
- setIsSubmitting(false);
12311
- return;
12312
- }
12313
- await confirmOrderEdit(void 0, {
12314
- onError: (e) => {
12315
- toast.error(`Failed to confirm order edit: ${e.message}`);
12316
- },
12317
- onSuccess: () => {
12318
- handleSuccess();
12319
- },
12320
- onSettled: () => {
12321
- setIsSubmitting(false);
12322
- }
12323
- });
12324
- };
12325
- const onKeydown = useCallback(
12326
- (e) => {
12327
- if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
12328
- if (data || isSubmitting) {
12329
- return;
12330
- }
12331
- onSubmit();
12332
- }
12333
- },
12334
- [data, isSubmitting, onSubmit]
12335
- );
12336
- useEffect(() => {
12337
- document.addEventListener("keydown", onKeydown);
12338
- return () => {
12339
- document.removeEventListener("keydown", onKeydown);
12340
- };
12341
- }, [onKeydown]);
12342
- return /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
12343
- /* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
12344
- /* @__PURE__ */ jsxs(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: [
12345
- /* @__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 py-16 px-6", children: [
12346
- /* @__PURE__ */ jsxs("div", { children: [
12347
- /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
12348
- /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Choose which shipping method(s) to use for the items in the order." }) })
12349
- ] }),
12350
- /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
12351
- /* @__PURE__ */ jsx(Accordion.Root, { type: "multiple", children: /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle rounded-xl shadow-elevation-card-rest", children: [
12352
- /* @__PURE__ */ jsxs("div", { className: "px-4 py-2 flex items-center justify-between", children: [
12353
- /* @__PURE__ */ jsx(
12354
- Text,
12355
- {
12356
- size: "xsmall",
12357
- weight: "plus",
12358
- className: "text-ui-fg-muted",
12359
- children: "Shipping profile"
12360
- }
12361
- ),
12362
- /* @__PURE__ */ jsx(
12363
- Text,
12364
- {
12365
- size: "xsmall",
12366
- weight: "plus",
12367
- className: "text-ui-fg-muted",
12368
- children: "Action"
12369
- }
12370
- )
12371
- ] }),
12372
- /* @__PURE__ */ jsx("div", { className: "px-[5px] pb-[5px]", children: uniqueShippingProfiles.map((profile) => {
12373
- var _a2, _b, _c, _d, _e, _f, _g;
12374
- const items = getItemsWithShippingProfile(
12375
- profile.id,
12376
- order.items
12377
- );
12378
- const hasItems = items.length > 0;
12379
- const shippingOption = shipping_options == null ? void 0 : shipping_options.find(
12380
- (option) => option.shipping_profile_id === profile.id
12381
- );
12382
- const shippingMethod = preview.shipping_methods.find(
12383
- (method) => method.shipping_option_id === (shippingOption == null ? void 0 : shippingOption.id)
12384
- );
12385
- const addShippingMethodAction = (_a2 = shippingMethod == null ? void 0 : shippingMethod.actions) == null ? void 0 : _a2.find(
12386
- (action) => action.action === "SHIPPING_ADD"
12387
- );
12388
- return /* @__PURE__ */ jsxs(
12389
- Accordion.Item,
11503
+ /* @__PURE__ */ jsx("div", { className: "px-[5px] pb-[5px]", children: uniqueShippingProfiles.map((profile) => {
11504
+ var _a2, _b, _c, _d, _e, _f, _g;
11505
+ const items = getItemsWithShippingProfile(
11506
+ profile.id,
11507
+ order.items
11508
+ );
11509
+ const hasItems = items.length > 0;
11510
+ const shippingOption = shipping_options == null ? void 0 : shipping_options.find(
11511
+ (option) => option.shipping_profile_id === profile.id
11512
+ );
11513
+ const shippingMethod = preview.shipping_methods.find(
11514
+ (method) => method.shipping_option_id === (shippingOption == null ? void 0 : shippingOption.id)
11515
+ );
11516
+ const addShippingMethodAction = (_a2 = shippingMethod == null ? void 0 : shippingMethod.actions) == null ? void 0 : _a2.find(
11517
+ (action) => action.action === "SHIPPING_ADD"
11518
+ );
11519
+ return /* @__PURE__ */ jsxs(
11520
+ Accordion.Item,
12390
11521
  {
12391
11522
  value: profile.id,
12392
11523
  className: "bg-ui-bg-base shadow-elevation-card-rest rounded-lg",
@@ -12614,429 +11745,1298 @@ const ShippingForm = ({ preview, order }) => {
12614
11745
  ] })
12615
11746
  ]
12616
11747
  },
12617
- profile.id
12618
- );
12619
- }) })
11748
+ profile.id
11749
+ );
11750
+ }) })
11751
+ ] }) })
11752
+ ] }) }),
11753
+ /* @__PURE__ */ jsx(
11754
+ StackedFocusModal,
11755
+ {
11756
+ id: STACKED_FOCUS_MODAL_ID,
11757
+ onOpenChangeCallback: (open) => {
11758
+ if (!open) {
11759
+ setData(null);
11760
+ }
11761
+ return open;
11762
+ },
11763
+ children: data && /* @__PURE__ */ jsx(ShippingProfileForm, { data, order, preview })
11764
+ }
11765
+ )
11766
+ ] }),
11767
+ /* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-x-2", children: [
11768
+ /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
11769
+ /* @__PURE__ */ jsx(
11770
+ Button,
11771
+ {
11772
+ size: "small",
11773
+ type: "button",
11774
+ isLoading: isSubmitting,
11775
+ onClick: onSubmit,
11776
+ children: "Save"
11777
+ }
11778
+ )
11779
+ ] }) })
11780
+ ] });
11781
+ };
11782
+ const StackedModalTrigger = ({
11783
+ shippingProfileId,
11784
+ shippingOption,
11785
+ shippingMethod,
11786
+ setData,
11787
+ children
11788
+ }) => {
11789
+ const { setIsOpen, getIsOpen } = useStackedModal();
11790
+ const isOpen = getIsOpen(STACKED_FOCUS_MODAL_ID);
11791
+ const onToggle = () => {
11792
+ if (isOpen) {
11793
+ setIsOpen(STACKED_FOCUS_MODAL_ID, false);
11794
+ setData(null);
11795
+ } else {
11796
+ setIsOpen(STACKED_FOCUS_MODAL_ID, true);
11797
+ setData({
11798
+ shippingProfileId,
11799
+ shippingOption,
11800
+ shippingMethod
11801
+ });
11802
+ }
11803
+ };
11804
+ return /* @__PURE__ */ jsx(
11805
+ Button,
11806
+ {
11807
+ size: "small",
11808
+ variant: "secondary",
11809
+ onClick: onToggle,
11810
+ className: "text-ui-fg-primary shrink-0",
11811
+ children
11812
+ }
11813
+ );
11814
+ };
11815
+ const ShippingProfileForm = ({
11816
+ data,
11817
+ order,
11818
+ preview
11819
+ }) => {
11820
+ var _a, _b, _c, _d, _e, _f;
11821
+ const { setIsOpen } = useStackedModal();
11822
+ const form = useForm({
11823
+ resolver: zodResolver(shippingMethodSchema),
11824
+ defaultValues: {
11825
+ location_id: (_d = (_c = (_b = (_a = data.shippingOption) == null ? void 0 : _a.service_zone) == null ? void 0 : _b.fulfillment_set) == null ? void 0 : _c.location) == null ? void 0 : _d.id,
11826
+ shipping_option_id: (_e = data.shippingOption) == null ? void 0 : _e.id,
11827
+ custom_amount: (_f = data.shippingMethod) == null ? void 0 : _f.amount
11828
+ }
11829
+ });
11830
+ const { mutateAsync: addShippingMethod, isPending } = useDraftOrderAddShippingMethod(order.id);
11831
+ const {
11832
+ mutateAsync: updateShippingMethod,
11833
+ isPending: isUpdatingShippingMethod
11834
+ } = useDraftOrderUpdateShippingMethod(order.id);
11835
+ const onSubmit = form.handleSubmit(async (values) => {
11836
+ if (isEqual(values, form.formState.defaultValues)) {
11837
+ setIsOpen(STACKED_FOCUS_MODAL_ID, false);
11838
+ return;
11839
+ }
11840
+ if (data.shippingMethod) {
11841
+ await updateShippingMethod(
11842
+ {
11843
+ method_id: data.shippingMethod.id,
11844
+ shipping_option_id: values.shipping_option_id,
11845
+ custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
11846
+ },
11847
+ {
11848
+ onError: (e) => {
11849
+ toast.error(e.message);
11850
+ },
11851
+ onSuccess: () => {
11852
+ setIsOpen(STACKED_FOCUS_MODAL_ID, false);
11853
+ }
11854
+ }
11855
+ );
11856
+ return;
11857
+ }
11858
+ await addShippingMethod(
11859
+ {
11860
+ shipping_option_id: values.shipping_option_id,
11861
+ custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
11862
+ },
11863
+ {
11864
+ onError: (e) => {
11865
+ toast.error(e.message);
11866
+ },
11867
+ onSuccess: () => {
11868
+ setIsOpen(STACKED_FOCUS_MODAL_ID, false);
11869
+ }
11870
+ }
11871
+ );
11872
+ });
11873
+ return /* @__PURE__ */ jsx(StackedFocusModal.Content, { children: /* @__PURE__ */ jsx(Form$2, { ...form, children: /* @__PURE__ */ jsxs(
11874
+ KeyboundForm,
11875
+ {
11876
+ className: "flex h-full flex-col overflow-hidden",
11877
+ onSubmit,
11878
+ children: [
11879
+ /* @__PURE__ */ jsx(StackedFocusModal.Header, {}),
11880
+ /* @__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 py-16 px-6", children: [
11881
+ /* @__PURE__ */ jsxs("div", { children: [
11882
+ /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
11883
+ /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Add a shipping method for the selected shipping profile. You can see the items that will be shipped using this method in the preview below." }) })
11884
+ ] }),
11885
+ /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
11886
+ /* @__PURE__ */ jsx(
11887
+ LocationField,
11888
+ {
11889
+ control: form.control,
11890
+ setValue: form.setValue
11891
+ }
11892
+ ),
11893
+ /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
11894
+ /* @__PURE__ */ jsx(
11895
+ ShippingOptionField,
11896
+ {
11897
+ shippingProfileId: data.shippingProfileId,
11898
+ preview,
11899
+ control: form.control
11900
+ }
11901
+ ),
11902
+ /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
11903
+ /* @__PURE__ */ jsx(
11904
+ CustomAmountField,
11905
+ {
11906
+ control: form.control,
11907
+ currencyCode: order.currency_code
11908
+ }
11909
+ ),
11910
+ /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
11911
+ /* @__PURE__ */ jsx(
11912
+ ItemsPreview,
11913
+ {
11914
+ order,
11915
+ shippingProfileId: data.shippingProfileId
11916
+ }
11917
+ )
11918
+ ] }) }) }),
11919
+ /* @__PURE__ */ jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-x-2", children: [
11920
+ /* @__PURE__ */ jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
11921
+ /* @__PURE__ */ jsx(
11922
+ Button,
11923
+ {
11924
+ size: "small",
11925
+ type: "submit",
11926
+ isLoading: isPending || isUpdatingShippingMethod,
11927
+ children: data.shippingMethod ? "Update" : "Add"
11928
+ }
11929
+ )
11930
+ ] }) })
11931
+ ]
11932
+ }
11933
+ ) }) });
11934
+ };
11935
+ const shippingMethodSchema = objectType({
11936
+ location_id: stringType(),
11937
+ shipping_option_id: stringType(),
11938
+ custom_amount: unionType([numberType(), stringType()]).optional()
11939
+ });
11940
+ const ItemsPreview = ({ order, shippingProfileId }) => {
11941
+ const matches = order.items.filter(
11942
+ (item) => {
11943
+ var _a, _b, _c;
11944
+ return ((_c = (_b = (_a = item.variant) == null ? void 0 : _a.product) == null ? void 0 : _b.shipping_profile) == null ? void 0 : _c.id) === shippingProfileId;
11945
+ }
11946
+ );
11947
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-6", children: [
11948
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 items-center gap-3", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
11949
+ /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: "Items to ship" }),
11950
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Items with the selected shipping profile." })
11951
+ ] }) }),
11952
+ /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
11953
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-3 px-4 py-2 text-ui-fg-muted", children: [
11954
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: "Item" }) }),
11955
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: "Quantity" }) })
11956
+ ] }),
11957
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1.5 px-[5px] pb-[5px]", children: matches.length > 0 ? matches == null ? void 0 : matches.map((item) => /* @__PURE__ */ jsxs(
11958
+ "div",
11959
+ {
11960
+ className: "grid grid-cols-2 gap-3 px-4 py-2 bg-ui-bg-base shadow-elevation-card-rest rounded-lg items-center",
11961
+ children: [
11962
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-3", children: [
11963
+ /* @__PURE__ */ jsx(
11964
+ Thumbnail,
11965
+ {
11966
+ thumbnail: item.thumbnail,
11967
+ alt: item.product_title ?? void 0
11968
+ }
11969
+ ),
11970
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
11971
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-1", children: [
11972
+ /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: item.product_title }),
11973
+ /* @__PURE__ */ jsxs(
11974
+ Text,
11975
+ {
11976
+ size: "small",
11977
+ leading: "compact",
11978
+ className: "text-ui-fg-subtle",
11979
+ children: [
11980
+ "(",
11981
+ item.variant_title,
11982
+ ")"
11983
+ ]
11984
+ }
11985
+ )
11986
+ ] }),
11987
+ /* @__PURE__ */ jsx(
11988
+ Text,
11989
+ {
11990
+ size: "small",
11991
+ leading: "compact",
11992
+ className: "text-ui-fg-subtle",
11993
+ children: item.variant_sku
11994
+ }
11995
+ )
11996
+ ] })
11997
+ ] }),
11998
+ /* @__PURE__ */ jsxs(
11999
+ Text,
12000
+ {
12001
+ size: "small",
12002
+ leading: "compact",
12003
+ className: "text-ui-fg-subtle",
12004
+ children: [
12005
+ item.quantity,
12006
+ "x"
12007
+ ]
12008
+ }
12009
+ )
12010
+ ]
12011
+ },
12012
+ item.id
12013
+ )) : /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center gap-x-3 bg-ui-bg-base rounded-lg p-4 shadow-elevation-card-rest flex-col gap-1", children: [
12014
+ /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: "No items found" }),
12015
+ /* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-subtle", children: [
12016
+ 'No items found for "',
12017
+ query,
12018
+ '".'
12019
+ ] })
12020
+ ] }) })
12021
+ ] })
12022
+ ] });
12023
+ };
12024
+ const LocationField = ({ control, setValue }) => {
12025
+ const locations = useComboboxData({
12026
+ queryKey: ["locations"],
12027
+ queryFn: async (params) => {
12028
+ return await sdk.admin.stockLocation.list(params);
12029
+ },
12030
+ getOptions: (data) => {
12031
+ return data.stock_locations.map((location) => ({
12032
+ label: location.name,
12033
+ value: location.id
12034
+ }));
12035
+ }
12036
+ });
12037
+ return /* @__PURE__ */ jsx(
12038
+ Form$2.Field,
12039
+ {
12040
+ control,
12041
+ name: "location_id",
12042
+ render: ({ field: { onChange, ...field } }) => {
12043
+ return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12044
+ /* @__PURE__ */ jsxs("div", { children: [
12045
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Location" }),
12046
+ /* @__PURE__ */ jsx(Form$2.Hint, { children: "Choose where you want to ship the items from." })
12047
+ ] }),
12048
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12049
+ Combobox,
12050
+ {
12051
+ options: locations.options,
12052
+ fetchNextPage: locations.fetchNextPage,
12053
+ isFetchingNextPage: locations.isFetchingNextPage,
12054
+ searchValue: locations.searchValue,
12055
+ onSearchValueChange: locations.onSearchValueChange,
12056
+ placeholder: "Select location",
12057
+ onChange: (value) => {
12058
+ setValue("shipping_option_id", "", {
12059
+ shouldDirty: true,
12060
+ shouldTouch: true
12061
+ });
12062
+ onChange(value);
12063
+ },
12064
+ ...field
12065
+ }
12066
+ ) })
12067
+ ] }) });
12068
+ }
12069
+ }
12070
+ );
12071
+ };
12072
+ const ShippingOptionField = ({
12073
+ shippingProfileId,
12074
+ preview,
12075
+ control
12076
+ }) => {
12077
+ var _a;
12078
+ const locationId = useWatch({ control, name: "location_id" });
12079
+ const shippingOptions = useComboboxData({
12080
+ queryKey: ["shipping_options", locationId, shippingProfileId],
12081
+ queryFn: async (params) => {
12082
+ return await sdk.admin.shippingOption.list({
12083
+ ...params,
12084
+ stock_location_id: locationId,
12085
+ shipping_profile_id: shippingProfileId
12086
+ });
12087
+ },
12088
+ getOptions: (data) => {
12089
+ return data.shipping_options.map((option) => {
12090
+ var _a2;
12091
+ if ((_a2 = option.rules) == null ? void 0 : _a2.find(
12092
+ (r) => r.attribute === "is_return" && r.value === "true"
12093
+ )) {
12094
+ return void 0;
12095
+ }
12096
+ return {
12097
+ label: option.name,
12098
+ value: option.id
12099
+ };
12100
+ }).filter(Boolean);
12101
+ },
12102
+ enabled: !!locationId && !!shippingProfileId,
12103
+ defaultValue: ((_a = preview.shipping_methods[0]) == null ? void 0 : _a.shipping_option_id) || void 0
12104
+ });
12105
+ const tooltipContent = !locationId && !shippingProfileId ? "Choose a location and shipping profile first." : !locationId ? "Choose a location first." : "Choose a shipping profile first.";
12106
+ return /* @__PURE__ */ jsx(
12107
+ Form$2.Field,
12108
+ {
12109
+ control,
12110
+ name: "shipping_option_id",
12111
+ render: ({ field }) => {
12112
+ return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12113
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12114
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Shipping option" }),
12115
+ /* @__PURE__ */ jsx(Form$2.Hint, { children: "Choose the shipping option to use." })
12116
+ ] }),
12117
+ /* @__PURE__ */ jsx(
12118
+ ConditionalTooltip,
12119
+ {
12120
+ content: tooltipContent,
12121
+ showTooltip: !locationId || !shippingProfileId,
12122
+ children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12123
+ Combobox,
12124
+ {
12125
+ options: shippingOptions.options,
12126
+ fetchNextPage: shippingOptions.fetchNextPage,
12127
+ isFetchingNextPage: shippingOptions.isFetchingNextPage,
12128
+ searchValue: shippingOptions.searchValue,
12129
+ onSearchValueChange: shippingOptions.onSearchValueChange,
12130
+ placeholder: "Select shipping option",
12131
+ ...field,
12132
+ disabled: !locationId || !shippingProfileId
12133
+ }
12134
+ ) }) })
12135
+ }
12136
+ )
12137
+ ] }) });
12138
+ }
12139
+ }
12140
+ );
12141
+ };
12142
+ const CustomAmountField = ({
12143
+ control,
12144
+ currencyCode
12145
+ }) => {
12146
+ return /* @__PURE__ */ jsx(
12147
+ Form$2.Field,
12148
+ {
12149
+ control,
12150
+ name: "custom_amount",
12151
+ render: ({ field: { onChange, ...field } }) => {
12152
+ return /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12153
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12154
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Custom amount" }),
12155
+ /* @__PURE__ */ jsx(Form$2.Hint, { children: "Set a custom amount for the shipping option." })
12156
+ ] }),
12157
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12158
+ CurrencyInput,
12159
+ {
12160
+ ...field,
12161
+ onValueChange: (value) => onChange(value),
12162
+ symbol: getNativeSymbol(currencyCode),
12163
+ code: currencyCode
12164
+ }
12165
+ ) })
12166
+ ] });
12167
+ }
12168
+ }
12169
+ );
12170
+ };
12171
+ const TransferOwnership = () => {
12172
+ const { id } = useParams();
12173
+ const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12174
+ fields: "id,customer_id,customer.*"
12175
+ });
12176
+ if (isError) {
12177
+ throw error;
12178
+ }
12179
+ const isReady = !isPending && !!draft_order;
12180
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12181
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12182
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Ownership" }) }),
12183
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Transfer the ownership of this draft order to a new customer" }) })
12184
+ ] }),
12185
+ isReady && /* @__PURE__ */ jsx(TransferOwnershipForm, { order: draft_order })
12186
+ ] });
12187
+ };
12188
+ const TransferOwnershipForm = ({ order }) => {
12189
+ var _a, _b;
12190
+ const form = useForm({
12191
+ defaultValues: {
12192
+ customer_id: order.customer_id || ""
12193
+ },
12194
+ resolver: zodResolver(schema$2)
12195
+ });
12196
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12197
+ const { handleSuccess } = useRouteModal();
12198
+ const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
12199
+ const currentCustomer = order.customer ? {
12200
+ label: name ? `${name} (${order.customer.email})` : order.customer.email,
12201
+ value: order.customer.id
12202
+ } : null;
12203
+ const onSubmit = form.handleSubmit(async (data) => {
12204
+ await mutateAsync(
12205
+ { customer_id: data.customer_id },
12206
+ {
12207
+ onSuccess: () => {
12208
+ toast.success("Customer updated");
12209
+ handleSuccess();
12210
+ },
12211
+ onError: (error) => {
12212
+ toast.error(error.message);
12213
+ }
12214
+ }
12215
+ );
12216
+ });
12217
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12218
+ KeyboundForm,
12219
+ {
12220
+ className: "flex flex-1 flex-col overflow-hidden",
12221
+ onSubmit,
12222
+ children: [
12223
+ /* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
12224
+ /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsx(Illustration, {}) }),
12225
+ currentCustomer && /* @__PURE__ */ jsxs("div", { className: "flex flex-col space-y-3", children: [
12226
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12227
+ /* @__PURE__ */ jsx(Label$1, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
12228
+ /* @__PURE__ */ jsx(Hint$1, { children: "The customer that is currently associated with this draft order." })
12229
+ ] }),
12230
+ /* @__PURE__ */ jsxs(Select, { disabled: true, value: currentCustomer.value, children: [
12231
+ /* @__PURE__ */ jsx(Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsx(Select.Value, {}) }),
12232
+ /* @__PURE__ */ jsx(Select.Content, { children: /* @__PURE__ */ jsx(Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
12233
+ ] })
12234
+ ] }),
12235
+ /* @__PURE__ */ jsx(
12236
+ CustomerField,
12237
+ {
12238
+ control: form.control,
12239
+ currentCustomerId: order.customer_id
12240
+ }
12241
+ )
12242
+ ] }),
12243
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
12244
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "secondary", size: "small", children: "Cancel" }) }),
12245
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12620
12246
  ] }) })
12621
- ] }) }),
12622
- /* @__PURE__ */ jsx(
12623
- StackedFocusModal,
12624
- {
12625
- id: STACKED_FOCUS_MODAL_ID,
12626
- onOpenChangeCallback: (open) => {
12627
- if (!open) {
12628
- setData(null);
12247
+ ]
12248
+ }
12249
+ ) });
12250
+ };
12251
+ const CustomerField = ({ control, currentCustomerId }) => {
12252
+ const customers = useComboboxData({
12253
+ queryFn: async (params) => {
12254
+ return await sdk.admin.customer.list({
12255
+ ...params,
12256
+ id: currentCustomerId ? { $nin: [currentCustomerId] } : void 0
12257
+ });
12258
+ },
12259
+ queryKey: ["customers"],
12260
+ getOptions: (data) => {
12261
+ return data.customers.map((customer) => {
12262
+ const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
12263
+ return {
12264
+ label: name ? `${name} (${customer.email})` : customer.email,
12265
+ value: customer.id
12266
+ };
12267
+ });
12268
+ }
12269
+ });
12270
+ return /* @__PURE__ */ jsx(
12271
+ Form$2.Field,
12272
+ {
12273
+ name: "customer_id",
12274
+ control,
12275
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { className: "space-y-3", children: [
12276
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12277
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "New customer" }),
12278
+ /* @__PURE__ */ jsx(Form$2.Hint, { children: "The customer to transfer this draft order to." })
12279
+ ] }),
12280
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12281
+ Combobox,
12282
+ {
12283
+ options: customers.options,
12284
+ fetchNextPage: customers.fetchNextPage,
12285
+ isFetchingNextPage: customers.isFetchingNextPage,
12286
+ searchValue: customers.searchValue,
12287
+ onSearchValueChange: customers.onSearchValueChange,
12288
+ placeholder: "Select customer",
12289
+ ...field
12290
+ }
12291
+ ) }),
12292
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12293
+ ] })
12294
+ }
12295
+ );
12296
+ };
12297
+ const Illustration = () => {
12298
+ return /* @__PURE__ */ jsxs(
12299
+ "svg",
12300
+ {
12301
+ width: "280",
12302
+ height: "180",
12303
+ viewBox: "0 0 280 180",
12304
+ fill: "none",
12305
+ xmlns: "http://www.w3.org/2000/svg",
12306
+ children: [
12307
+ /* @__PURE__ */ jsx(
12308
+ "rect",
12309
+ {
12310
+ x: "0.00428286",
12311
+ y: "-0.742904",
12312
+ width: "33.5",
12313
+ height: "65.5",
12314
+ rx: "6.75",
12315
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 88.438)",
12316
+ fill: "#D4D4D8",
12317
+ stroke: "#52525B",
12318
+ strokeWidth: "1.5"
12319
+ }
12320
+ ),
12321
+ /* @__PURE__ */ jsx(
12322
+ "rect",
12323
+ {
12324
+ x: "0.00428286",
12325
+ y: "-0.742904",
12326
+ width: "33.5",
12327
+ height: "65.5",
12328
+ rx: "6.75",
12329
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 85.4381)",
12330
+ fill: "white",
12331
+ stroke: "#52525B",
12332
+ strokeWidth: "1.5"
12333
+ }
12334
+ ),
12335
+ /* @__PURE__ */ jsx(
12336
+ "path",
12337
+ {
12338
+ d: "M180.579 107.142L179.126 107.959",
12339
+ stroke: "#52525B",
12340
+ strokeWidth: "1.5",
12341
+ strokeLinecap: "round",
12342
+ strokeLinejoin: "round"
12343
+ }
12344
+ ),
12345
+ /* @__PURE__ */ jsx(
12346
+ "path",
12347
+ {
12348
+ opacity: "0.88",
12349
+ d: "M182.305 109.546L180.257 109.534",
12350
+ stroke: "#52525B",
12351
+ strokeWidth: "1.5",
12352
+ strokeLinecap: "round",
12353
+ strokeLinejoin: "round"
12354
+ }
12355
+ ),
12356
+ /* @__PURE__ */ jsx(
12357
+ "path",
12358
+ {
12359
+ opacity: "0.75",
12360
+ d: "M180.551 111.93L179.108 111.096",
12361
+ stroke: "#52525B",
12362
+ strokeWidth: "1.5",
12363
+ strokeLinecap: "round",
12364
+ strokeLinejoin: "round"
12365
+ }
12366
+ ),
12367
+ /* @__PURE__ */ jsx(
12368
+ "path",
12369
+ {
12370
+ opacity: "0.63",
12371
+ d: "M176.347 112.897L176.354 111.73",
12372
+ stroke: "#52525B",
12373
+ strokeWidth: "1.5",
12374
+ strokeLinecap: "round",
12375
+ strokeLinejoin: "round"
12376
+ }
12377
+ ),
12378
+ /* @__PURE__ */ jsx(
12379
+ "path",
12380
+ {
12381
+ opacity: "0.5",
12382
+ d: "M172.153 111.881L173.606 111.064",
12383
+ stroke: "#52525B",
12384
+ strokeWidth: "1.5",
12385
+ strokeLinecap: "round",
12386
+ strokeLinejoin: "round"
12387
+ }
12388
+ ),
12389
+ /* @__PURE__ */ jsx(
12390
+ "path",
12391
+ {
12392
+ opacity: "0.38",
12393
+ d: "M170.428 109.478L172.476 109.489",
12394
+ stroke: "#52525B",
12395
+ strokeWidth: "1.5",
12396
+ strokeLinecap: "round",
12397
+ strokeLinejoin: "round"
12398
+ }
12399
+ ),
12400
+ /* @__PURE__ */ jsx(
12401
+ "path",
12402
+ {
12403
+ opacity: "0.25",
12404
+ d: "M172.181 107.094L173.624 107.928",
12405
+ stroke: "#52525B",
12406
+ strokeWidth: "1.5",
12407
+ strokeLinecap: "round",
12408
+ strokeLinejoin: "round"
12409
+ }
12410
+ ),
12411
+ /* @__PURE__ */ jsx(
12412
+ "path",
12413
+ {
12414
+ opacity: "0.13",
12415
+ d: "M176.386 106.126L176.379 107.294",
12416
+ stroke: "#52525B",
12417
+ strokeWidth: "1.5",
12418
+ strokeLinecap: "round",
12419
+ strokeLinejoin: "round"
12420
+ }
12421
+ ),
12422
+ /* @__PURE__ */ jsx(
12423
+ "rect",
12424
+ {
12425
+ width: "12",
12426
+ height: "3",
12427
+ rx: "1.5",
12428
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 196.447 92.2925)",
12429
+ fill: "#D4D4D8"
12430
+ }
12431
+ ),
12432
+ /* @__PURE__ */ jsx(
12433
+ "rect",
12434
+ {
12435
+ x: "0.00428286",
12436
+ y: "-0.742904",
12437
+ width: "33.5",
12438
+ height: "65.5",
12439
+ rx: "6.75",
12440
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 46.4147)",
12441
+ fill: "#D4D4D8",
12442
+ stroke: "#52525B",
12443
+ strokeWidth: "1.5"
12444
+ }
12445
+ ),
12446
+ /* @__PURE__ */ jsx(
12447
+ "rect",
12448
+ {
12449
+ x: "0.00428286",
12450
+ y: "-0.742904",
12451
+ width: "33.5",
12452
+ height: "65.5",
12453
+ rx: "6.75",
12454
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 43.4147)",
12455
+ fill: "white",
12456
+ stroke: "#52525B",
12457
+ strokeWidth: "1.5"
12458
+ }
12459
+ ),
12460
+ /* @__PURE__ */ jsx(
12461
+ "rect",
12462
+ {
12463
+ width: "12",
12464
+ height: "3",
12465
+ rx: "1.5",
12466
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 123.714 50.2691)",
12467
+ fill: "#D4D4D8"
12468
+ }
12469
+ ),
12470
+ /* @__PURE__ */ jsx(
12471
+ "rect",
12472
+ {
12473
+ width: "17",
12474
+ height: "3",
12475
+ rx: "1.5",
12476
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 97.5557 66.958)",
12477
+ fill: "#D4D4D8"
12478
+ }
12479
+ ),
12480
+ /* @__PURE__ */ jsx(
12481
+ "rect",
12482
+ {
12483
+ width: "12",
12484
+ height: "3",
12485
+ rx: "1.5",
12486
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 93.1978 69.4093)",
12487
+ fill: "#D4D4D8"
12488
+ }
12489
+ ),
12490
+ /* @__PURE__ */ jsx(
12491
+ "path",
12492
+ {
12493
+ d: "M92.3603 63.9563C90.9277 63.1286 88.59 63.1152 87.148 63.9263C85.7059 64.7374 85.6983 66.0702 87.1308 66.8979C88.5634 67.7256 90.9011 67.7391 92.3432 66.928C93.7852 66.1168 93.7929 64.784 92.3603 63.9563ZM88.4382 66.1625C87.7221 65.7488 87.726 65.0822 88.4468 64.6767C89.1676 64.2713 90.3369 64.278 91.0529 64.6917C91.769 65.1055 91.7652 65.7721 91.0444 66.1775C90.3236 66.583 89.1543 66.5762 88.4382 66.1625Z",
12494
+ fill: "#A1A1AA"
12495
+ }
12496
+ ),
12497
+ /* @__PURE__ */ jsx(
12498
+ "rect",
12499
+ {
12500
+ width: "17",
12501
+ height: "3",
12502
+ rx: "1.5",
12503
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 109.758 60.0944)",
12504
+ fill: "#A1A1AA"
12505
+ }
12506
+ ),
12507
+ /* @__PURE__ */ jsx(
12508
+ "rect",
12509
+ {
12510
+ width: "12",
12511
+ height: "3",
12512
+ rx: "1.5",
12513
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 105.4 62.5457)",
12514
+ fill: "#A1A1AA"
12515
+ }
12516
+ ),
12517
+ /* @__PURE__ */ jsx(
12518
+ "path",
12519
+ {
12520
+ d: "M104.562 57.0927C103.13 56.265 100.792 56.2515 99.3501 57.0626C97.9081 57.8738 97.9004 59.2065 99.333 60.0343C100.766 60.862 103.103 60.8754 104.545 60.0643C105.987 59.2532 105.995 57.9204 104.562 57.0927ZM103.858 58.8972L100.815 59.1265C100.683 59.1367 100.55 59.1134 100.449 59.063C100.44 59.0585 100.432 59.0545 100.425 59.05C100.339 59.0005 100.29 58.9336 100.291 58.8637L100.294 58.1201C100.294 57.9752 100.501 57.8585 100.756 57.86C101.01 57.8615 101.217 57.98 101.216 58.1256L101.214 58.5669L103.732 58.3769C103.984 58.3578 104.217 58.4584 104.251 58.603C104.286 58.7468 104.11 58.8788 103.858 58.8977L103.858 58.8972Z",
12521
+ fill: "#52525B"
12522
+ }
12523
+ ),
12524
+ /* @__PURE__ */ jsx("g", { clipPath: "url(#clip0_20915_38670)", children: /* @__PURE__ */ jsx(
12525
+ "path",
12526
+ {
12527
+ d: "M133.106 81.8022L140.49 81.8447L140.515 77.6349",
12528
+ stroke: "#A1A1AA",
12529
+ strokeWidth: "1.5",
12530
+ strokeLinecap: "round",
12531
+ strokeLinejoin: "round"
12532
+ }
12533
+ ) }),
12534
+ /* @__PURE__ */ jsx("g", { clipPath: "url(#clip1_20915_38670)", children: /* @__PURE__ */ jsx(
12535
+ "path",
12536
+ {
12537
+ d: "M143.496 87.8055L150.881 87.8481L150.905 83.6383",
12538
+ stroke: "#A1A1AA",
12539
+ strokeWidth: "1.5",
12540
+ strokeLinecap: "round",
12541
+ strokeLinejoin: "round"
12542
+ }
12543
+ ) }),
12544
+ /* @__PURE__ */ jsx("g", { clipPath: "url(#clip2_20915_38670)", children: /* @__PURE__ */ jsx(
12545
+ "path",
12546
+ {
12547
+ d: "M153.887 93.8088L161.271 93.8514L161.295 89.6416",
12548
+ stroke: "#A1A1AA",
12549
+ strokeWidth: "1.5",
12550
+ strokeLinecap: "round",
12551
+ strokeLinejoin: "round"
12552
+ }
12553
+ ) }),
12554
+ /* @__PURE__ */ jsx("g", { clipPath: "url(#clip3_20915_38670)", children: /* @__PURE__ */ jsx(
12555
+ "path",
12556
+ {
12557
+ d: "M126.114 89.1912L118.729 89.1486L118.705 93.3584",
12558
+ stroke: "#A1A1AA",
12559
+ strokeWidth: "1.5",
12560
+ strokeLinecap: "round",
12561
+ strokeLinejoin: "round"
12562
+ }
12563
+ ) }),
12564
+ /* @__PURE__ */ jsx("g", { clipPath: "url(#clip4_20915_38670)", children: /* @__PURE__ */ jsx(
12565
+ "path",
12566
+ {
12567
+ d: "M136.504 95.1945L129.12 95.1519L129.095 99.3617",
12568
+ stroke: "#A1A1AA",
12569
+ strokeWidth: "1.5",
12570
+ strokeLinecap: "round",
12571
+ strokeLinejoin: "round"
12572
+ }
12573
+ ) }),
12574
+ /* @__PURE__ */ jsx("g", { clipPath: "url(#clip5_20915_38670)", children: /* @__PURE__ */ jsx(
12575
+ "path",
12576
+ {
12577
+ d: "M146.894 101.198L139.51 101.155L139.486 105.365",
12578
+ stroke: "#A1A1AA",
12579
+ strokeWidth: "1.5",
12580
+ strokeLinecap: "round",
12581
+ strokeLinejoin: "round"
12582
+ }
12583
+ ) }),
12584
+ /* @__PURE__ */ jsxs("defs", { children: [
12585
+ /* @__PURE__ */ jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsx(
12586
+ "rect",
12587
+ {
12588
+ width: "12",
12589
+ height: "12",
12590
+ fill: "white",
12591
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
12629
12592
  }
12630
- return open;
12631
- },
12632
- children: data && /* @__PURE__ */ jsx(ShippingProfileForm, { data, order, preview })
12633
- }
12634
- )
12635
- ] }),
12636
- /* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-x-2", children: [
12637
- /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
12638
- /* @__PURE__ */ jsx(
12639
- Button,
12640
- {
12641
- size: "small",
12642
- type: "button",
12643
- isLoading: isSubmitting,
12644
- onClick: onSubmit,
12645
- children: "Save"
12646
- }
12647
- )
12648
- ] }) })
12649
- ] });
12650
- };
12651
- const StackedModalTrigger = ({
12652
- shippingProfileId,
12653
- shippingOption,
12654
- shippingMethod,
12655
- setData,
12656
- children
12657
- }) => {
12658
- const { setIsOpen, getIsOpen } = useStackedModal();
12659
- const isOpen = getIsOpen(STACKED_FOCUS_MODAL_ID);
12660
- const onToggle = () => {
12661
- if (isOpen) {
12662
- setIsOpen(STACKED_FOCUS_MODAL_ID, false);
12663
- setData(null);
12664
- } else {
12665
- setIsOpen(STACKED_FOCUS_MODAL_ID, true);
12666
- setData({
12667
- shippingProfileId,
12668
- shippingOption,
12669
- shippingMethod
12670
- });
12671
- }
12672
- };
12673
- return /* @__PURE__ */ jsx(
12674
- Button,
12675
- {
12676
- size: "small",
12677
- variant: "secondary",
12678
- onClick: onToggle,
12679
- className: "text-ui-fg-primary shrink-0",
12680
- children
12593
+ ) }),
12594
+ /* @__PURE__ */ jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsx(
12595
+ "rect",
12596
+ {
12597
+ width: "12",
12598
+ height: "12",
12599
+ fill: "white",
12600
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
12601
+ }
12602
+ ) }),
12603
+ /* @__PURE__ */ jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsx(
12604
+ "rect",
12605
+ {
12606
+ width: "12",
12607
+ height: "12",
12608
+ fill: "white",
12609
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
12610
+ }
12611
+ ) }),
12612
+ /* @__PURE__ */ jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsx(
12613
+ "rect",
12614
+ {
12615
+ width: "12",
12616
+ height: "12",
12617
+ fill: "white",
12618
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
12619
+ }
12620
+ ) }),
12621
+ /* @__PURE__ */ jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsx(
12622
+ "rect",
12623
+ {
12624
+ width: "12",
12625
+ height: "12",
12626
+ fill: "white",
12627
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
12628
+ }
12629
+ ) }),
12630
+ /* @__PURE__ */ jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsx(
12631
+ "rect",
12632
+ {
12633
+ width: "12",
12634
+ height: "12",
12635
+ fill: "white",
12636
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
12637
+ }
12638
+ ) })
12639
+ ] })
12640
+ ]
12681
12641
  }
12682
12642
  );
12683
12643
  };
12684
- const ShippingProfileForm = ({
12685
- data,
12686
- order,
12687
- preview
12688
- }) => {
12689
- var _a, _b, _c, _d, _e, _f;
12690
- const { setIsOpen } = useStackedModal();
12644
+ const schema$2 = objectType({
12645
+ customer_id: stringType().min(1)
12646
+ });
12647
+ const ShippingAddress = () => {
12648
+ const { id } = useParams();
12649
+ const { order, isPending, isError, error } = useOrder(id, {
12650
+ fields: "+shipping_address"
12651
+ });
12652
+ if (isError) {
12653
+ throw error;
12654
+ }
12655
+ const isReady = !isPending && !!order;
12656
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12657
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12658
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
12659
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12660
+ ] }),
12661
+ isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
12662
+ ] });
12663
+ };
12664
+ const ShippingAddressForm = ({ order }) => {
12665
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12691
12666
  const form = useForm({
12692
- resolver: zodResolver(shippingMethodSchema),
12693
12667
  defaultValues: {
12694
- location_id: (_d = (_c = (_b = (_a = data.shippingOption) == null ? void 0 : _a.service_zone) == null ? void 0 : _b.fulfillment_set) == null ? void 0 : _c.location) == null ? void 0 : _d.id,
12695
- shipping_option_id: (_e = data.shippingOption) == null ? void 0 : _e.id,
12696
- custom_amount: (_f = data.shippingMethod) == null ? void 0 : _f.amount
12697
- }
12668
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12669
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12670
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12671
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12672
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12673
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12674
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12675
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12676
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12677
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12678
+ },
12679
+ resolver: zodResolver(schema$1)
12698
12680
  });
12699
- const { mutateAsync: addShippingMethod, isPending } = useDraftOrderAddShippingMethod(order.id);
12700
- const {
12701
- mutateAsync: updateShippingMethod,
12702
- isPending: isUpdatingShippingMethod
12703
- } = useDraftOrderUpdateShippingMethod(order.id);
12704
- const onSubmit = form.handleSubmit(async (values) => {
12705
- if (isEqual(values, form.formState.defaultValues)) {
12706
- setIsOpen(STACKED_FOCUS_MODAL_ID, false);
12707
- return;
12708
- }
12709
- if (data.shippingMethod) {
12710
- await updateShippingMethod(
12711
- {
12712
- method_id: data.shippingMethod.id,
12713
- shipping_option_id: values.shipping_option_id,
12714
- custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
12715
- },
12716
- {
12717
- onError: (e) => {
12718
- toast.error(e.message);
12719
- },
12720
- onSuccess: () => {
12721
- setIsOpen(STACKED_FOCUS_MODAL_ID, false);
12722
- }
12723
- }
12724
- );
12725
- return;
12726
- }
12727
- await addShippingMethod(
12681
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12682
+ const { handleSuccess } = useRouteModal();
12683
+ const onSubmit = form.handleSubmit(async (data) => {
12684
+ await mutateAsync(
12728
12685
  {
12729
- shipping_option_id: values.shipping_option_id,
12730
- custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
12686
+ shipping_address: {
12687
+ first_name: data.first_name,
12688
+ last_name: data.last_name,
12689
+ company: data.company,
12690
+ address_1: data.address_1,
12691
+ address_2: data.address_2,
12692
+ city: data.city,
12693
+ province: data.province,
12694
+ country_code: data.country_code,
12695
+ postal_code: data.postal_code,
12696
+ phone: data.phone
12697
+ }
12731
12698
  },
12732
12699
  {
12733
- onError: (e) => {
12734
- toast.error(e.message);
12735
- },
12736
12700
  onSuccess: () => {
12737
- setIsOpen(STACKED_FOCUS_MODAL_ID, false);
12701
+ handleSuccess();
12702
+ },
12703
+ onError: (error) => {
12704
+ toast.error(error.message);
12738
12705
  }
12739
12706
  }
12740
12707
  );
12741
12708
  });
12742
- return /* @__PURE__ */ jsx(StackedFocusModal.Content, { children: /* @__PURE__ */ jsx(Form$2, { ...form, children: /* @__PURE__ */ jsxs(
12709
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12743
12710
  KeyboundForm,
12744
12711
  {
12745
- className: "flex h-full flex-col overflow-hidden",
12712
+ className: "flex flex-1 flex-col overflow-hidden",
12746
12713
  onSubmit,
12747
12714
  children: [
12748
- /* @__PURE__ */ jsx(StackedFocusModal.Header, {}),
12749
- /* @__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 py-16 px-6", children: [
12750
- /* @__PURE__ */ jsxs("div", { children: [
12751
- /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
12752
- /* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Add a shipping method for the selected shipping profile. You can see the items that will be shipped using this method in the preview below." }) })
12715
+ /* @__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: [
12716
+ /* @__PURE__ */ jsx(
12717
+ Form$2.Field,
12718
+ {
12719
+ control: form.control,
12720
+ name: "country_code",
12721
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12722
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
12723
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
12724
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12725
+ ] })
12726
+ }
12727
+ ),
12728
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12729
+ /* @__PURE__ */ jsx(
12730
+ Form$2.Field,
12731
+ {
12732
+ control: form.control,
12733
+ name: "first_name",
12734
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12735
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
12736
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12737
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12738
+ ] })
12739
+ }
12740
+ ),
12741
+ /* @__PURE__ */ jsx(
12742
+ Form$2.Field,
12743
+ {
12744
+ control: form.control,
12745
+ name: "last_name",
12746
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12747
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
12748
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12749
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12750
+ ] })
12751
+ }
12752
+ )
12753
12753
  ] }),
12754
- /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
12755
12754
  /* @__PURE__ */ jsx(
12756
- LocationField,
12755
+ Form$2.Field,
12757
12756
  {
12758
12757
  control: form.control,
12759
- setValue: form.setValue
12758
+ name: "company",
12759
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12760
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
12761
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12762
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12763
+ ] })
12760
12764
  }
12761
12765
  ),
12762
- /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
12763
12766
  /* @__PURE__ */ jsx(
12764
- ShippingOptionField,
12767
+ Form$2.Field,
12765
12768
  {
12766
- shippingProfileId: data.shippingProfileId,
12767
- preview,
12768
- control: form.control
12769
+ control: form.control,
12770
+ name: "address_1",
12771
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12772
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
12773
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12774
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12775
+ ] })
12769
12776
  }
12770
12777
  ),
12771
- /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
12772
12778
  /* @__PURE__ */ jsx(
12773
- CustomAmountField,
12779
+ Form$2.Field,
12774
12780
  {
12775
12781
  control: form.control,
12776
- currencyCode: order.currency_code
12782
+ name: "address_2",
12783
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12784
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12785
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12786
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12787
+ ] })
12777
12788
  }
12778
12789
  ),
12779
- /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
12790
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12791
+ /* @__PURE__ */ jsx(
12792
+ Form$2.Field,
12793
+ {
12794
+ control: form.control,
12795
+ name: "postal_code",
12796
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12797
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
12798
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12799
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12800
+ ] })
12801
+ }
12802
+ ),
12803
+ /* @__PURE__ */ jsx(
12804
+ Form$2.Field,
12805
+ {
12806
+ control: form.control,
12807
+ name: "city",
12808
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12809
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
12810
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12811
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12812
+ ] })
12813
+ }
12814
+ )
12815
+ ] }),
12780
12816
  /* @__PURE__ */ jsx(
12781
- ItemsPreview,
12817
+ Form$2.Field,
12782
12818
  {
12783
- order,
12784
- shippingProfileId: data.shippingProfileId
12819
+ control: form.control,
12820
+ name: "province",
12821
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12822
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12823
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12824
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12825
+ ] })
12785
12826
  }
12786
- )
12787
- ] }) }) }),
12788
- /* @__PURE__ */ jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-x-2", children: [
12789
- /* @__PURE__ */ jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
12827
+ ),
12790
12828
  /* @__PURE__ */ jsx(
12791
- Button,
12829
+ Form$2.Field,
12792
12830
  {
12793
- size: "small",
12794
- type: "submit",
12795
- isLoading: isPending || isUpdatingShippingMethod,
12796
- children: data.shippingMethod ? "Update" : "Add"
12831
+ control: form.control,
12832
+ name: "phone",
12833
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12834
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
12835
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12836
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12837
+ ] })
12797
12838
  }
12798
12839
  )
12840
+ ] }) }),
12841
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12842
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12843
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12799
12844
  ] }) })
12800
12845
  ]
12801
12846
  }
12802
- ) }) });
12803
- };
12804
- const shippingMethodSchema = objectType({
12805
- location_id: stringType(),
12806
- shipping_option_id: stringType(),
12807
- custom_amount: unionType([numberType(), stringType()]).optional()
12808
- });
12809
- const ItemsPreview = ({ order, shippingProfileId }) => {
12810
- const matches = order.items.filter(
12811
- (item) => {
12812
- var _a, _b, _c;
12813
- return ((_c = (_b = (_a = item.variant) == null ? void 0 : _a.product) == null ? void 0 : _b.shipping_profile) == null ? void 0 : _c.id) === shippingProfileId;
12814
- }
12815
- );
12816
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-6", children: [
12817
- /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 items-center gap-3", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12818
- /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: "Items to ship" }),
12819
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Items with the selected shipping profile." })
12820
- ] }) }),
12821
- /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
12822
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-3 px-4 py-2 text-ui-fg-muted", children: [
12823
- /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: "Item" }) }),
12824
- /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: "Quantity" }) })
12825
- ] }),
12826
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1.5 px-[5px] pb-[5px]", children: matches.length > 0 ? matches == null ? void 0 : matches.map((item) => /* @__PURE__ */ jsxs(
12827
- "div",
12828
- {
12829
- className: "grid grid-cols-2 gap-3 px-4 py-2 bg-ui-bg-base shadow-elevation-card-rest rounded-lg items-center",
12830
- children: [
12831
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-3", children: [
12832
- /* @__PURE__ */ jsx(
12833
- Thumbnail,
12834
- {
12835
- thumbnail: item.thumbnail,
12836
- alt: item.product_title ?? void 0
12837
- }
12838
- ),
12839
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12840
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-1", children: [
12841
- /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: item.product_title }),
12842
- /* @__PURE__ */ jsxs(
12843
- Text,
12844
- {
12845
- size: "small",
12846
- leading: "compact",
12847
- className: "text-ui-fg-subtle",
12848
- children: [
12849
- "(",
12850
- item.variant_title,
12851
- ")"
12852
- ]
12853
- }
12854
- )
12855
- ] }),
12856
- /* @__PURE__ */ jsx(
12857
- Text,
12858
- {
12859
- size: "small",
12860
- leading: "compact",
12861
- className: "text-ui-fg-subtle",
12862
- children: item.variant_sku
12863
- }
12864
- )
12865
- ] })
12866
- ] }),
12867
- /* @__PURE__ */ jsxs(
12868
- Text,
12869
- {
12870
- size: "small",
12871
- leading: "compact",
12872
- className: "text-ui-fg-subtle",
12873
- children: [
12874
- item.quantity,
12875
- "x"
12876
- ]
12877
- }
12878
- )
12879
- ]
12880
- },
12881
- item.id
12882
- )) : /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center gap-x-3 bg-ui-bg-base rounded-lg p-4 shadow-elevation-card-rest flex-col gap-1", children: [
12883
- /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: "No items found" }),
12884
- /* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-subtle", children: [
12885
- 'No items found for "',
12886
- query,
12887
- '".'
12888
- ] })
12889
- ] }) })
12890
- ] })
12891
- ] });
12847
+ ) });
12892
12848
  };
12893
- const LocationField = ({ control, setValue }) => {
12894
- const locations = useComboboxData({
12895
- queryKey: ["locations"],
12896
- queryFn: async (params) => {
12897
- return await sdk.admin.stockLocation.list(params);
12898
- },
12899
- getOptions: (data) => {
12900
- return data.stock_locations.map((location) => ({
12901
- label: location.name,
12902
- value: location.id
12903
- }));
12904
- }
12849
+ const schema$1 = addressSchema;
12850
+ const BillingAddress = () => {
12851
+ const { id } = useParams();
12852
+ const { order, isPending, isError, error } = useOrder(id, {
12853
+ fields: "+billing_address"
12905
12854
  });
12906
- return /* @__PURE__ */ jsx(
12907
- Form$2.Field,
12908
- {
12909
- control,
12910
- name: "location_id",
12911
- render: ({ field: { onChange, ...field } }) => {
12912
- return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12913
- /* @__PURE__ */ jsxs("div", { children: [
12914
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Location" }),
12915
- /* @__PURE__ */ jsx(Form$2.Hint, { children: "Choose where you want to ship the items from." })
12916
- ] }),
12917
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12918
- Combobox,
12919
- {
12920
- options: locations.options,
12921
- fetchNextPage: locations.fetchNextPage,
12922
- isFetchingNextPage: locations.isFetchingNextPage,
12923
- searchValue: locations.searchValue,
12924
- onSearchValueChange: locations.onSearchValueChange,
12925
- placeholder: "Select location",
12926
- onChange: (value) => {
12927
- setValue("shipping_option_id", "", {
12928
- shouldDirty: true,
12929
- shouldTouch: true
12930
- });
12931
- onChange(value);
12932
- },
12933
- ...field
12934
- }
12935
- ) })
12936
- ] }) });
12937
- }
12938
- }
12939
- );
12940
- };
12941
- const ShippingOptionField = ({
12942
- shippingProfileId,
12943
- preview,
12944
- control
12945
- }) => {
12946
- var _a;
12947
- const locationId = useWatch({ control, name: "location_id" });
12948
- const shippingOptions = useComboboxData({
12949
- queryKey: ["shipping_options", locationId, shippingProfileId],
12950
- queryFn: async (params) => {
12951
- return await sdk.admin.shippingOption.list({
12952
- ...params,
12953
- stock_location_id: locationId,
12954
- shipping_profile_id: shippingProfileId
12955
- });
12855
+ if (isError) {
12856
+ throw error;
12857
+ }
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 })
12865
+ ] });
12866
+ };
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) ?? ""
12956
12881
  },
12957
- getOptions: (data) => {
12958
- return data.shipping_options.map((option) => {
12959
- var _a2;
12960
- if ((_a2 = option.rules) == null ? void 0 : _a2.find(
12961
- (r) => r.attribute === "is_return" && r.value === "true"
12962
- )) {
12963
- return void 0;
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 },
12889
+ {
12890
+ onSuccess: () => {
12891
+ handleSuccess();
12892
+ },
12893
+ onError: (error) => {
12894
+ toast.error(error.message);
12964
12895
  }
12965
- return {
12966
- label: option.name,
12967
- value: option.id
12968
- };
12969
- }).filter(Boolean);
12970
- },
12971
- enabled: !!locationId && !!shippingProfileId,
12972
- defaultValue: ((_a = preview.shipping_methods[0]) == null ? void 0 : _a.shipping_option_id) || void 0
12896
+ }
12897
+ );
12973
12898
  });
12974
- const tooltipContent = !locationId && !shippingProfileId ? "Choose a location and shipping profile first." : !locationId ? "Choose a location first." : "Choose a shipping profile first.";
12975
- return /* @__PURE__ */ jsx(
12976
- Form$2.Field,
12899
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12900
+ KeyboundForm,
12977
12901
  {
12978
- control,
12979
- name: "shipping_option_id",
12980
- render: ({ field }) => {
12981
- return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12982
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12983
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Shipping option" }),
12984
- /* @__PURE__ */ jsx(Form$2.Hint, { children: "Choose the shipping option to use." })
12902
+ className: "flex flex-1 flex-col overflow-hidden",
12903
+ onSubmit,
12904
+ children: [
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
+ )
12985
12943
  ] }),
12986
12944
  /* @__PURE__ */ jsx(
12987
- ConditionalTooltip,
12945
+ Form$2.Field,
12988
12946
  {
12989
- content: tooltipContent,
12990
- showTooltip: !locationId || !shippingProfileId,
12991
- children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12992
- Combobox,
12993
- {
12994
- options: shippingOptions.options,
12995
- fetchNextPage: shippingOptions.fetchNextPage,
12996
- isFetchingNextPage: shippingOptions.isFetchingNextPage,
12997
- searchValue: shippingOptions.searchValue,
12998
- onSearchValueChange: shippingOptions.onSearchValueChange,
12999
- placeholder: "Select shipping option",
13000
- ...field,
13001
- disabled: !locationId || !shippingProfileId
13002
- }
13003
- ) }) })
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
+ ] })
13004
12954
  }
13005
- )
13006
- ] }) });
13007
- }
13008
- }
13009
- );
13010
- };
13011
- const CustomAmountField = ({
13012
- control,
13013
- currencyCode
13014
- }) => {
13015
- return /* @__PURE__ */ jsx(
13016
- Form$2.Field,
13017
- {
13018
- control,
13019
- name: "custom_amount",
13020
- render: ({ field: { onChange, ...field } }) => {
13021
- return /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
13022
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
13023
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Custom amount" }),
13024
- /* @__PURE__ */ jsx(Form$2.Hint, { children: "Set a custom amount for the shipping option." })
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
+ )
13025
13005
  ] }),
13026
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
13027
- CurrencyInput,
13006
+ /* @__PURE__ */ jsx(
13007
+ Form$2.Field,
13028
13008
  {
13029
- ...field,
13030
- onValueChange: (value) => onChange(value),
13031
- symbol: getNativeSymbol(currencyCode),
13032
- code: currencyCode
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
+ ] })
13033
13016
  }
13034
- ) })
13035
- ] });
13036
- }
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
+ ] }) })
13035
+ ]
13037
13036
  }
13038
- );
13037
+ ) });
13039
13038
  };
13039
+ const schema = addressSchema;
13040
13040
  const widgetModule = { widgets: [] };
13041
13041
  const routeModule = {
13042
13042
  routes: [
@@ -13057,14 +13057,6 @@ const routeModule = {
13057
13057
  handle,
13058
13058
  loader,
13059
13059
  children: [
13060
- {
13061
- Component: BillingAddress,
13062
- path: "/draft-orders/:id/billing-address"
13063
- },
13064
- {
13065
- Component: CustomItems,
13066
- path: "/draft-orders/:id/custom-items"
13067
- },
13068
13060
  {
13069
13061
  Component: Email,
13070
13062
  path: "/draft-orders/:id/email"
@@ -13081,21 +13073,29 @@ const routeModule = {
13081
13073
  Component: Promotions,
13082
13074
  path: "/draft-orders/:id/promotions"
13083
13075
  },
13076
+ {
13077
+ Component: CustomItems,
13078
+ path: "/draft-orders/:id/custom-items"
13079
+ },
13084
13080
  {
13085
13081
  Component: SalesChannel,
13086
13082
  path: "/draft-orders/:id/sales-channel"
13087
13083
  },
13088
13084
  {
13089
- Component: ShippingAddress,
13090
- path: "/draft-orders/:id/shipping-address"
13085
+ Component: Shipping,
13086
+ path: "/draft-orders/:id/shipping"
13091
13087
  },
13092
13088
  {
13093
13089
  Component: TransferOwnership,
13094
13090
  path: "/draft-orders/:id/transfer-ownership"
13095
13091
  },
13096
13092
  {
13097
- Component: Shipping,
13098
- path: "/draft-orders/:id/shipping"
13093
+ Component: ShippingAddress,
13094
+ path: "/draft-orders/:id/shipping-address"
13095
+ },
13096
+ {
13097
+ Component: BillingAddress,
13098
+ path: "/draft-orders/:id/billing-address"
13099
13099
  }
13100
13100
  ]
13101
13101
  }