@medusajs/draft-order 2.11.4-snapshot-20251106130942 → 2.11.4-snapshot-20251107094001

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.
@@ -9568,27 +9568,6 @@ const ID = () => {
9568
9568
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
9569
9569
  ] });
9570
9570
  };
9571
- const CustomItems = () => {
9572
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9573
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9574
- /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9575
- ] });
9576
- };
9577
- const CustomItemsForm = () => {
9578
- const form = reactHookForm.useForm({
9579
- resolver: zod.zodResolver(schema$5)
9580
- });
9581
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9582
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9583
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9584
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9585
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9586
- ] }) })
9587
- ] }) });
9588
- };
9589
- const schema$5 = objectType({
9590
- email: stringType().email()
9591
- });
9592
9571
  const BillingAddress = () => {
9593
9572
  const { id } = reactRouterDom.useParams();
9594
9573
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9621,7 +9600,7 @@ const BillingAddressForm = ({ order }) => {
9621
9600
  postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9622
9601
  phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9623
9602
  },
9624
- resolver: zod.zodResolver(schema$4)
9603
+ resolver: zod.zodResolver(schema$5)
9625
9604
  });
9626
9605
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9627
9606
  const { handleSuccess } = useRouteModal();
@@ -9778,7 +9757,96 @@ const BillingAddressForm = ({ order }) => {
9778
9757
  }
9779
9758
  ) });
9780
9759
  };
9781
- const schema$4 = addressSchema;
9760
+ const schema$5 = addressSchema;
9761
+ const Email = () => {
9762
+ const { id } = reactRouterDom.useParams();
9763
+ const { order, isPending, isError, error } = useOrder(id, {
9764
+ fields: "+email"
9765
+ });
9766
+ if (isError) {
9767
+ throw error;
9768
+ }
9769
+ const isReady = !isPending && !!order;
9770
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9771
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9772
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
9773
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
9774
+ ] }),
9775
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
9776
+ ] });
9777
+ };
9778
+ const EmailForm = ({ order }) => {
9779
+ const form = reactHookForm.useForm({
9780
+ defaultValues: {
9781
+ email: order.email ?? ""
9782
+ },
9783
+ resolver: zod.zodResolver(schema$4)
9784
+ });
9785
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9786
+ const { handleSuccess } = useRouteModal();
9787
+ const onSubmit = form.handleSubmit(async (data) => {
9788
+ await mutateAsync(
9789
+ { email: data.email },
9790
+ {
9791
+ onSuccess: () => {
9792
+ handleSuccess();
9793
+ },
9794
+ onError: (error) => {
9795
+ ui.toast.error(error.message);
9796
+ }
9797
+ }
9798
+ );
9799
+ });
9800
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
9801
+ KeyboundForm,
9802
+ {
9803
+ className: "flex flex-1 flex-col overflow-hidden",
9804
+ onSubmit,
9805
+ children: [
9806
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
9807
+ Form$2.Field,
9808
+ {
9809
+ control: form.control,
9810
+ name: "email",
9811
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9812
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
9813
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9814
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9815
+ ] })
9816
+ }
9817
+ ) }),
9818
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9819
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9820
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9821
+ ] }) })
9822
+ ]
9823
+ }
9824
+ ) });
9825
+ };
9826
+ const schema$4 = objectType({
9827
+ email: stringType().email()
9828
+ });
9829
+ const CustomItems = () => {
9830
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9831
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9832
+ /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9833
+ ] });
9834
+ };
9835
+ const CustomItemsForm = () => {
9836
+ const form = reactHookForm.useForm({
9837
+ resolver: zod.zodResolver(schema$3)
9838
+ });
9839
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9840
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9841
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9842
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9843
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9844
+ ] }) })
9845
+ ] }) });
9846
+ };
9847
+ const schema$3 = objectType({
9848
+ email: stringType().email()
9849
+ });
9782
9850
  const NumberInput = React.forwardRef(
9783
9851
  ({
9784
9852
  value,
@@ -10753,74 +10821,6 @@ const customItemSchema = objectType({
10753
10821
  quantity: numberType(),
10754
10822
  unit_price: unionType([numberType(), stringType()])
10755
10823
  });
10756
- const Email = () => {
10757
- const { id } = reactRouterDom.useParams();
10758
- const { order, isPending, isError, error } = useOrder(id, {
10759
- fields: "+email"
10760
- });
10761
- if (isError) {
10762
- throw error;
10763
- }
10764
- const isReady = !isPending && !!order;
10765
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
10766
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
10767
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
10768
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
10769
- ] }),
10770
- isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
10771
- ] });
10772
- };
10773
- const EmailForm = ({ order }) => {
10774
- const form = reactHookForm.useForm({
10775
- defaultValues: {
10776
- email: order.email ?? ""
10777
- },
10778
- resolver: zod.zodResolver(schema$3)
10779
- });
10780
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
10781
- const { handleSuccess } = useRouteModal();
10782
- const onSubmit = form.handleSubmit(async (data) => {
10783
- await mutateAsync(
10784
- { email: data.email },
10785
- {
10786
- onSuccess: () => {
10787
- handleSuccess();
10788
- },
10789
- onError: (error) => {
10790
- ui.toast.error(error.message);
10791
- }
10792
- }
10793
- );
10794
- });
10795
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
10796
- KeyboundForm,
10797
- {
10798
- className: "flex flex-1 flex-col overflow-hidden",
10799
- onSubmit,
10800
- children: [
10801
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
10802
- Form$2.Field,
10803
- {
10804
- control: form.control,
10805
- name: "email",
10806
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10807
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
10808
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10809
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10810
- ] })
10811
- }
10812
- ) }),
10813
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
10814
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
10815
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
10816
- ] }) })
10817
- ]
10818
- }
10819
- ) });
10820
- };
10821
- const schema$3 = objectType({
10822
- email: stringType().email()
10823
- });
10824
10824
  const InlineTip = React.forwardRef(
10825
10825
  ({ variant = "tip", label, className, children, ...props }, ref) => {
10826
10826
  const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
@@ -12361,60 +12361,44 @@ const CustomAmountField = ({
12361
12361
  }
12362
12362
  );
12363
12363
  };
12364
- const ShippingAddress = () => {
12364
+ const TransferOwnership = () => {
12365
12365
  const { id } = reactRouterDom.useParams();
12366
- const { order, isPending, isError, error } = useOrder(id, {
12367
- fields: "+shipping_address"
12366
+ const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12367
+ fields: "id,customer_id,customer.*"
12368
12368
  });
12369
12369
  if (isError) {
12370
12370
  throw error;
12371
12371
  }
12372
- const isReady = !isPending && !!order;
12372
+ const isReady = !isPending && !!draft_order;
12373
12373
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12374
12374
  /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12375
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12376
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12375
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
12376
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Transfer the ownership of this draft order to a new customer" }) })
12377
12377
  ] }),
12378
- isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12378
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
12379
12379
  ] });
12380
12380
  };
12381
- const ShippingAddressForm = ({ order }) => {
12382
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12381
+ const TransferOwnershipForm = ({ order }) => {
12382
+ var _a, _b;
12383
12383
  const form = reactHookForm.useForm({
12384
12384
  defaultValues: {
12385
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12386
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12387
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12388
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12389
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12390
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12391
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12392
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12393
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12394
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12385
+ customer_id: order.customer_id || ""
12395
12386
  },
12396
12387
  resolver: zod.zodResolver(schema$1)
12397
12388
  });
12398
12389
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12399
12390
  const { handleSuccess } = useRouteModal();
12391
+ const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
12392
+ const currentCustomer = order.customer ? {
12393
+ label: name ? `${name} (${order.customer.email})` : order.customer.email,
12394
+ value: order.customer.id
12395
+ } : null;
12400
12396
  const onSubmit = form.handleSubmit(async (data) => {
12401
12397
  await mutateAsync(
12402
- {
12403
- shipping_address: {
12404
- first_name: data.first_name,
12405
- last_name: data.last_name,
12406
- company: data.company,
12407
- address_1: data.address_1,
12408
- address_2: data.address_2,
12409
- city: data.city,
12410
- province: data.province,
12411
- country_code: data.country_code,
12412
- postal_code: data.postal_code,
12413
- phone: data.phone
12414
- }
12415
- },
12398
+ { customer_id: data.customer_id },
12416
12399
  {
12417
12400
  onSuccess: () => {
12401
+ ui.toast.success("Customer updated");
12418
12402
  handleSuccess();
12419
12403
  },
12420
12404
  onError: (error) => {
@@ -12429,210 +12413,23 @@ const ShippingAddressForm = ({ order }) => {
12429
12413
  className: "flex flex-1 flex-col overflow-hidden",
12430
12414
  onSubmit,
12431
12415
  children: [
12432
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
12416
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
12417
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsxRuntime.jsx(Illustration, {}) }),
12418
+ currentCustomer && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col space-y-3", children: [
12419
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
12420
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
12421
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { children: "The customer that is currently associated with this draft order." })
12422
+ ] }),
12423
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { disabled: true, value: currentCustomer.value, children: [
12424
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, {}) }),
12425
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
12426
+ ] })
12427
+ ] }),
12433
12428
  /* @__PURE__ */ jsxRuntime.jsx(
12434
- Form$2.Field,
12429
+ CustomerField,
12435
12430
  {
12436
12431
  control: form.control,
12437
- name: "country_code",
12438
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12439
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12440
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12441
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12442
- ] })
12443
- }
12444
- ),
12445
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12446
- /* @__PURE__ */ jsxRuntime.jsx(
12447
- Form$2.Field,
12448
- {
12449
- control: form.control,
12450
- name: "first_name",
12451
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12452
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12453
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12454
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12455
- ] })
12456
- }
12457
- ),
12458
- /* @__PURE__ */ jsxRuntime.jsx(
12459
- Form$2.Field,
12460
- {
12461
- control: form.control,
12462
- name: "last_name",
12463
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12464
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12465
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12466
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12467
- ] })
12468
- }
12469
- )
12470
- ] }),
12471
- /* @__PURE__ */ jsxRuntime.jsx(
12472
- Form$2.Field,
12473
- {
12474
- control: form.control,
12475
- name: "company",
12476
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12477
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12478
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12479
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12480
- ] })
12481
- }
12482
- ),
12483
- /* @__PURE__ */ jsxRuntime.jsx(
12484
- Form$2.Field,
12485
- {
12486
- control: form.control,
12487
- name: "address_1",
12488
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12489
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12490
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12491
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12492
- ] })
12493
- }
12494
- ),
12495
- /* @__PURE__ */ jsxRuntime.jsx(
12496
- Form$2.Field,
12497
- {
12498
- control: form.control,
12499
- name: "address_2",
12500
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12501
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12502
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12503
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12504
- ] })
12505
- }
12506
- ),
12507
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12508
- /* @__PURE__ */ jsxRuntime.jsx(
12509
- Form$2.Field,
12510
- {
12511
- control: form.control,
12512
- name: "postal_code",
12513
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12514
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12515
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12516
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12517
- ] })
12518
- }
12519
- ),
12520
- /* @__PURE__ */ jsxRuntime.jsx(
12521
- Form$2.Field,
12522
- {
12523
- control: form.control,
12524
- name: "city",
12525
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12526
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
12527
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12528
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12529
- ] })
12530
- }
12531
- )
12532
- ] }),
12533
- /* @__PURE__ */ jsxRuntime.jsx(
12534
- Form$2.Field,
12535
- {
12536
- control: form.control,
12537
- name: "province",
12538
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12539
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12540
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12541
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12542
- ] })
12543
- }
12544
- ),
12545
- /* @__PURE__ */ jsxRuntime.jsx(
12546
- Form$2.Field,
12547
- {
12548
- control: form.control,
12549
- name: "phone",
12550
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12551
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
12552
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12553
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12554
- ] })
12555
- }
12556
- )
12557
- ] }) }),
12558
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12559
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12560
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12561
- ] }) })
12562
- ]
12563
- }
12564
- ) });
12565
- };
12566
- const schema$1 = addressSchema;
12567
- const TransferOwnership = () => {
12568
- const { id } = reactRouterDom.useParams();
12569
- const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12570
- fields: "id,customer_id,customer.*"
12571
- });
12572
- if (isError) {
12573
- throw error;
12574
- }
12575
- const isReady = !isPending && !!draft_order;
12576
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12577
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12578
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
12579
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Transfer the ownership of this draft order to a new customer" }) })
12580
- ] }),
12581
- isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
12582
- ] });
12583
- };
12584
- const TransferOwnershipForm = ({ order }) => {
12585
- var _a, _b;
12586
- const form = reactHookForm.useForm({
12587
- defaultValues: {
12588
- customer_id: order.customer_id || ""
12589
- },
12590
- resolver: zod.zodResolver(schema)
12591
- });
12592
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12593
- const { handleSuccess } = useRouteModal();
12594
- const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
12595
- const currentCustomer = order.customer ? {
12596
- label: name ? `${name} (${order.customer.email})` : order.customer.email,
12597
- value: order.customer.id
12598
- } : null;
12599
- const onSubmit = form.handleSubmit(async (data) => {
12600
- await mutateAsync(
12601
- { customer_id: data.customer_id },
12602
- {
12603
- onSuccess: () => {
12604
- ui.toast.success("Customer updated");
12605
- handleSuccess();
12606
- },
12607
- onError: (error) => {
12608
- ui.toast.error(error.message);
12609
- }
12610
- }
12611
- );
12612
- });
12613
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12614
- KeyboundForm,
12615
- {
12616
- className: "flex flex-1 flex-col overflow-hidden",
12617
- onSubmit,
12618
- children: [
12619
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
12620
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsxRuntime.jsx(Illustration, {}) }),
12621
- currentCustomer && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col space-y-3", children: [
12622
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
12623
- /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
12624
- /* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { children: "The customer that is currently associated with this draft order." })
12625
- ] }),
12626
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { disabled: true, value: currentCustomer.value, children: [
12627
- /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, {}) }),
12628
- /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
12629
- ] })
12630
- ] }),
12631
- /* @__PURE__ */ jsxRuntime.jsx(
12632
- CustomerField,
12633
- {
12634
- control: form.control,
12635
- currentCustomerId: order.customer_id
12432
+ currentCustomerId: order.customer_id
12636
12433
  }
12637
12434
  )
12638
12435
  ] }),
@@ -13037,9 +12834,212 @@ const Illustration = () => {
13037
12834
  }
13038
12835
  );
13039
12836
  };
13040
- const schema = objectType({
12837
+ const schema$1 = objectType({
13041
12838
  customer_id: stringType().min(1)
13042
12839
  });
12840
+ const ShippingAddress = () => {
12841
+ const { id } = reactRouterDom.useParams();
12842
+ const { order, isPending, isError, error } = useOrder(id, {
12843
+ fields: "+shipping_address"
12844
+ });
12845
+ if (isError) {
12846
+ throw error;
12847
+ }
12848
+ const isReady = !isPending && !!order;
12849
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12850
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12851
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12852
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12853
+ ] }),
12854
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12855
+ ] });
12856
+ };
12857
+ const ShippingAddressForm = ({ order }) => {
12858
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12859
+ const form = reactHookForm.useForm({
12860
+ defaultValues: {
12861
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12862
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12863
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12864
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12865
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12866
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12867
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12868
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12869
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12870
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12871
+ },
12872
+ resolver: zod.zodResolver(schema)
12873
+ });
12874
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12875
+ const { handleSuccess } = useRouteModal();
12876
+ const onSubmit = form.handleSubmit(async (data) => {
12877
+ await mutateAsync(
12878
+ {
12879
+ shipping_address: {
12880
+ first_name: data.first_name,
12881
+ last_name: data.last_name,
12882
+ company: data.company,
12883
+ address_1: data.address_1,
12884
+ address_2: data.address_2,
12885
+ city: data.city,
12886
+ province: data.province,
12887
+ country_code: data.country_code,
12888
+ postal_code: data.postal_code,
12889
+ phone: data.phone
12890
+ }
12891
+ },
12892
+ {
12893
+ onSuccess: () => {
12894
+ handleSuccess();
12895
+ },
12896
+ onError: (error) => {
12897
+ ui.toast.error(error.message);
12898
+ }
12899
+ }
12900
+ );
12901
+ });
12902
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12903
+ KeyboundForm,
12904
+ {
12905
+ className: "flex flex-1 flex-col overflow-hidden",
12906
+ onSubmit,
12907
+ children: [
12908
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
12909
+ /* @__PURE__ */ jsxRuntime.jsx(
12910
+ Form$2.Field,
12911
+ {
12912
+ control: form.control,
12913
+ name: "country_code",
12914
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12915
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12916
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12917
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12918
+ ] })
12919
+ }
12920
+ ),
12921
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12922
+ /* @__PURE__ */ jsxRuntime.jsx(
12923
+ Form$2.Field,
12924
+ {
12925
+ control: form.control,
12926
+ name: "first_name",
12927
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12928
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12929
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12930
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12931
+ ] })
12932
+ }
12933
+ ),
12934
+ /* @__PURE__ */ jsxRuntime.jsx(
12935
+ Form$2.Field,
12936
+ {
12937
+ control: form.control,
12938
+ name: "last_name",
12939
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12940
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12941
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12942
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12943
+ ] })
12944
+ }
12945
+ )
12946
+ ] }),
12947
+ /* @__PURE__ */ jsxRuntime.jsx(
12948
+ Form$2.Field,
12949
+ {
12950
+ control: form.control,
12951
+ name: "company",
12952
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12953
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12954
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12955
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12956
+ ] })
12957
+ }
12958
+ ),
12959
+ /* @__PURE__ */ jsxRuntime.jsx(
12960
+ Form$2.Field,
12961
+ {
12962
+ control: form.control,
12963
+ name: "address_1",
12964
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12965
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12966
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12967
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12968
+ ] })
12969
+ }
12970
+ ),
12971
+ /* @__PURE__ */ jsxRuntime.jsx(
12972
+ Form$2.Field,
12973
+ {
12974
+ control: form.control,
12975
+ name: "address_2",
12976
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12977
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12978
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12979
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12980
+ ] })
12981
+ }
12982
+ ),
12983
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12984
+ /* @__PURE__ */ jsxRuntime.jsx(
12985
+ Form$2.Field,
12986
+ {
12987
+ control: form.control,
12988
+ name: "postal_code",
12989
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12990
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12991
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12992
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12993
+ ] })
12994
+ }
12995
+ ),
12996
+ /* @__PURE__ */ jsxRuntime.jsx(
12997
+ Form$2.Field,
12998
+ {
12999
+ control: form.control,
13000
+ name: "city",
13001
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13002
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
13003
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13004
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13005
+ ] })
13006
+ }
13007
+ )
13008
+ ] }),
13009
+ /* @__PURE__ */ jsxRuntime.jsx(
13010
+ Form$2.Field,
13011
+ {
13012
+ control: form.control,
13013
+ name: "province",
13014
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13015
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
13016
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13017
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13018
+ ] })
13019
+ }
13020
+ ),
13021
+ /* @__PURE__ */ jsxRuntime.jsx(
13022
+ Form$2.Field,
13023
+ {
13024
+ control: form.control,
13025
+ name: "phone",
13026
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13027
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
13028
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13029
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13030
+ ] })
13031
+ }
13032
+ )
13033
+ ] }) }),
13034
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
13035
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13036
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13037
+ ] }) })
13038
+ ]
13039
+ }
13040
+ ) });
13041
+ };
13042
+ const schema = addressSchema;
13043
13043
  const widgetModule = { widgets: [] };
13044
13044
  const routeModule = {
13045
13045
  routes: [
@@ -13060,22 +13060,22 @@ const routeModule = {
13060
13060
  handle,
13061
13061
  loader,
13062
13062
  children: [
13063
- {
13064
- Component: CustomItems,
13065
- path: "/draft-orders/:id/custom-items"
13066
- },
13067
13063
  {
13068
13064
  Component: BillingAddress,
13069
13065
  path: "/draft-orders/:id/billing-address"
13070
13066
  },
13071
- {
13072
- Component: Items,
13073
- path: "/draft-orders/:id/items"
13074
- },
13075
13067
  {
13076
13068
  Component: Email,
13077
13069
  path: "/draft-orders/:id/email"
13078
13070
  },
13071
+ {
13072
+ Component: CustomItems,
13073
+ path: "/draft-orders/:id/custom-items"
13074
+ },
13075
+ {
13076
+ Component: Items,
13077
+ path: "/draft-orders/:id/items"
13078
+ },
13079
13079
  {
13080
13080
  Component: Metadata,
13081
13081
  path: "/draft-orders/:id/metadata"
@@ -13092,13 +13092,13 @@ const routeModule = {
13092
13092
  Component: Shipping,
13093
13093
  path: "/draft-orders/:id/shipping"
13094
13094
  },
13095
- {
13096
- Component: ShippingAddress,
13097
- path: "/draft-orders/:id/shipping-address"
13098
- },
13099
13095
  {
13100
13096
  Component: TransferOwnership,
13101
13097
  path: "/draft-orders/:id/transfer-ownership"
13098
+ },
13099
+ {
13100
+ Component: ShippingAddress,
13101
+ path: "/draft-orders/:id/shipping-address"
13102
13102
  }
13103
13103
  ]
13104
13104
  }