@medusajs/draft-order 2.11.1-preview-20251023090208 → 2.11.1-preview-20251023150219

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,196 +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
9568
  const CustomItems = () => {
9759
9569
  return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9760
9570
  /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
@@ -9763,7 +9573,7 @@ const CustomItems = () => {
9763
9573
  };
9764
9574
  const CustomItemsForm = () => {
9765
9575
  const form = useForm({
9766
- resolver: zodResolver(schema$4)
9576
+ resolver: zodResolver(schema$5)
9767
9577
  });
9768
9578
  return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9769
9579
  /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
@@ -9773,75 +9583,7 @@ const CustomItemsForm = () => {
9773
9583
  ] }) })
9774
9584
  ] }) });
9775
9585
  };
9776
- const schema$4 = objectType({
9777
- email: stringType().email()
9778
- });
9779
- const Email = () => {
9780
- const { id } = useParams();
9781
- const { order, isPending, isError, error } = useOrder(id, {
9782
- fields: "+email"
9783
- });
9784
- if (isError) {
9785
- throw error;
9786
- }
9787
- const isReady = !isPending && !!order;
9788
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9789
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
9790
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
9791
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
9792
- ] }),
9793
- isReady && /* @__PURE__ */ jsx(EmailForm, { order })
9794
- ] });
9795
- };
9796
- const EmailForm = ({ order }) => {
9797
- const form = useForm({
9798
- defaultValues: {
9799
- email: order.email ?? ""
9800
- },
9801
- resolver: zodResolver(schema$3)
9802
- });
9803
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9804
- const { handleSuccess } = useRouteModal();
9805
- const onSubmit = form.handleSubmit(async (data) => {
9806
- await mutateAsync(
9807
- { email: data.email },
9808
- {
9809
- onSuccess: () => {
9810
- handleSuccess();
9811
- },
9812
- onError: (error) => {
9813
- toast.error(error.message);
9814
- }
9815
- }
9816
- );
9817
- });
9818
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
9819
- KeyboundForm,
9820
- {
9821
- className: "flex flex-1 flex-col overflow-hidden",
9822
- onSubmit,
9823
- children: [
9824
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
9825
- Form$2.Field,
9826
- {
9827
- control: form.control,
9828
- name: "email",
9829
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9830
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
9831
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9832
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9833
- ] })
9834
- }
9835
- ) }),
9836
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9837
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9838
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9839
- ] }) })
9840
- ]
9841
- }
9842
- ) });
9843
- };
9844
- const schema$3 = objectType({
9586
+ const schema$5 = objectType({
9845
9587
  email: stringType().email()
9846
9588
  });
9847
9589
  const NumberInput = forwardRef(
@@ -11473,7 +11215,7 @@ const SalesChannelForm = ({ order }) => {
11473
11215
  defaultValues: {
11474
11216
  sales_channel_id: order.sales_channel_id || ""
11475
11217
  },
11476
- resolver: zodResolver(schema$2)
11218
+ resolver: zodResolver(schema$4)
11477
11219
  });
11478
11220
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11479
11221
  const { handleSuccess } = useRouteModal();
@@ -11508,49 +11250,252 @@ const SalesChannelForm = ({ order }) => {
11508
11250
  }
11509
11251
  ) });
11510
11252
  };
11511
- const SalesChannelField = ({ control, order }) => {
11512
- const salesChannels = useComboboxData({
11513
- queryFn: async (params) => {
11514
- return await sdk.admin.salesChannel.list(params);
11515
- },
11516
- queryKey: ["sales-channels"],
11517
- getOptions: (data) => {
11518
- return data.sales_channels.map((salesChannel) => ({
11519
- label: salesChannel.name,
11520
- value: salesChannel.id
11521
- }));
11522
- },
11523
- defaultValue: order.sales_channel_id || void 0
11524
- });
11525
- return /* @__PURE__ */ jsx(
11526
- Form$2.Field,
11527
- {
11528
- control,
11529
- name: "sales_channel_id",
11530
- render: ({ field }) => {
11531
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11532
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
11533
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
11534
- Combobox,
11535
- {
11536
- options: salesChannels.options,
11537
- fetchNextPage: salesChannels.fetchNextPage,
11538
- isFetchingNextPage: salesChannels.isFetchingNextPage,
11539
- searchValue: salesChannels.searchValue,
11540
- onSearchValueChange: salesChannels.onSearchValueChange,
11541
- placeholder: "Select sales channel",
11542
- ...field
11543
- }
11544
- ) }),
11545
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11546
- ] });
11547
- }
11548
- }
11549
- );
11550
- };
11551
- const schema$2 = objectType({
11552
- sales_channel_id: stringType().min(1)
11553
- });
11253
+ const SalesChannelField = ({ control, order }) => {
11254
+ const salesChannels = useComboboxData({
11255
+ queryFn: async (params) => {
11256
+ return await sdk.admin.salesChannel.list(params);
11257
+ },
11258
+ queryKey: ["sales-channels"],
11259
+ getOptions: (data) => {
11260
+ return data.sales_channels.map((salesChannel) => ({
11261
+ label: salesChannel.name,
11262
+ value: salesChannel.id
11263
+ }));
11264
+ },
11265
+ defaultValue: order.sales_channel_id || void 0
11266
+ });
11267
+ return /* @__PURE__ */ jsx(
11268
+ Form$2.Field,
11269
+ {
11270
+ control,
11271
+ name: "sales_channel_id",
11272
+ render: ({ field }) => {
11273
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11274
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
11275
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
11276
+ Combobox,
11277
+ {
11278
+ options: salesChannels.options,
11279
+ fetchNextPage: salesChannels.fetchNextPage,
11280
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
11281
+ searchValue: salesChannels.searchValue,
11282
+ onSearchValueChange: salesChannels.onSearchValueChange,
11283
+ placeholder: "Select sales channel",
11284
+ ...field
11285
+ }
11286
+ ) }),
11287
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11288
+ ] });
11289
+ }
11290
+ }
11291
+ );
11292
+ };
11293
+ const schema$4 = objectType({
11294
+ sales_channel_id: stringType().min(1)
11295
+ });
11296
+ const ShippingAddress = () => {
11297
+ const { id } = useParams();
11298
+ const { order, isPending, isError, error } = useOrder(id, {
11299
+ fields: "+shipping_address"
11300
+ });
11301
+ if (isError) {
11302
+ throw error;
11303
+ }
11304
+ const isReady = !isPending && !!order;
11305
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11306
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11307
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
11308
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
11309
+ ] }),
11310
+ isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
11311
+ ] });
11312
+ };
11313
+ const ShippingAddressForm = ({ order }) => {
11314
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11315
+ const form = useForm({
11316
+ defaultValues: {
11317
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
11318
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
11319
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
11320
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
11321
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
11322
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
11323
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
11324
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
11325
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
11326
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
11327
+ },
11328
+ resolver: zodResolver(schema$3)
11329
+ });
11330
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11331
+ const { handleSuccess } = useRouteModal();
11332
+ const onSubmit = form.handleSubmit(async (data) => {
11333
+ await mutateAsync(
11334
+ {
11335
+ shipping_address: {
11336
+ first_name: data.first_name,
11337
+ last_name: data.last_name,
11338
+ company: data.company,
11339
+ address_1: data.address_1,
11340
+ address_2: data.address_2,
11341
+ city: data.city,
11342
+ province: data.province,
11343
+ country_code: data.country_code,
11344
+ postal_code: data.postal_code,
11345
+ phone: data.phone
11346
+ }
11347
+ },
11348
+ {
11349
+ onSuccess: () => {
11350
+ handleSuccess();
11351
+ },
11352
+ onError: (error) => {
11353
+ toast.error(error.message);
11354
+ }
11355
+ }
11356
+ );
11357
+ });
11358
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11359
+ KeyboundForm,
11360
+ {
11361
+ className: "flex flex-1 flex-col overflow-hidden",
11362
+ onSubmit,
11363
+ children: [
11364
+ /* @__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: [
11365
+ /* @__PURE__ */ jsx(
11366
+ Form$2.Field,
11367
+ {
11368
+ control: form.control,
11369
+ name: "country_code",
11370
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11371
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
11372
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
11373
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11374
+ ] })
11375
+ }
11376
+ ),
11377
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11378
+ /* @__PURE__ */ jsx(
11379
+ Form$2.Field,
11380
+ {
11381
+ control: form.control,
11382
+ name: "first_name",
11383
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11384
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
11385
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11386
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11387
+ ] })
11388
+ }
11389
+ ),
11390
+ /* @__PURE__ */ jsx(
11391
+ Form$2.Field,
11392
+ {
11393
+ control: form.control,
11394
+ name: "last_name",
11395
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11396
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
11397
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11398
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11399
+ ] })
11400
+ }
11401
+ )
11402
+ ] }),
11403
+ /* @__PURE__ */ jsx(
11404
+ Form$2.Field,
11405
+ {
11406
+ control: form.control,
11407
+ name: "company",
11408
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11409
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
11410
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11411
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11412
+ ] })
11413
+ }
11414
+ ),
11415
+ /* @__PURE__ */ jsx(
11416
+ Form$2.Field,
11417
+ {
11418
+ control: form.control,
11419
+ name: "address_1",
11420
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11421
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
11422
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11423
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11424
+ ] })
11425
+ }
11426
+ ),
11427
+ /* @__PURE__ */ jsx(
11428
+ Form$2.Field,
11429
+ {
11430
+ control: form.control,
11431
+ name: "address_2",
11432
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11433
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11434
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11435
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11436
+ ] })
11437
+ }
11438
+ ),
11439
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11440
+ /* @__PURE__ */ jsx(
11441
+ Form$2.Field,
11442
+ {
11443
+ control: form.control,
11444
+ name: "postal_code",
11445
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11446
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
11447
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11448
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11449
+ ] })
11450
+ }
11451
+ ),
11452
+ /* @__PURE__ */ jsx(
11453
+ Form$2.Field,
11454
+ {
11455
+ control: form.control,
11456
+ name: "city",
11457
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11458
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
11459
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11460
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11461
+ ] })
11462
+ }
11463
+ )
11464
+ ] }),
11465
+ /* @__PURE__ */ jsx(
11466
+ Form$2.Field,
11467
+ {
11468
+ control: form.control,
11469
+ name: "province",
11470
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11471
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11472
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11473
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11474
+ ] })
11475
+ }
11476
+ ),
11477
+ /* @__PURE__ */ jsx(
11478
+ Form$2.Field,
11479
+ {
11480
+ control: form.control,
11481
+ name: "phone",
11482
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11483
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
11484
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11485
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11486
+ ] })
11487
+ }
11488
+ )
11489
+ ] }) }),
11490
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11491
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11492
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11493
+ ] }) })
11494
+ ]
11495
+ }
11496
+ ) });
11497
+ };
11498
+ const schema$3 = addressSchema;
11554
11499
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11555
11500
  const Shipping = () => {
11556
11501
  var _a;
@@ -12301,266 +12246,63 @@ const ShippingOptionField = ({
12301
12246
  render: ({ field }) => {
12302
12247
  return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12303
12248
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12304
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Shipping option" }),
12305
- /* @__PURE__ */ jsx(Form$2.Hint, { children: "Choose the shipping option to use." })
12306
- ] }),
12307
- /* @__PURE__ */ jsx(
12308
- ConditionalTooltip,
12309
- {
12310
- content: tooltipContent,
12311
- showTooltip: !locationId || !shippingProfileId,
12312
- children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12313
- Combobox,
12314
- {
12315
- options: shippingOptions.options,
12316
- fetchNextPage: shippingOptions.fetchNextPage,
12317
- isFetchingNextPage: shippingOptions.isFetchingNextPage,
12318
- searchValue: shippingOptions.searchValue,
12319
- onSearchValueChange: shippingOptions.onSearchValueChange,
12320
- placeholder: "Select shipping option",
12321
- ...field,
12322
- disabled: !locationId || !shippingProfileId
12323
- }
12324
- ) }) })
12325
- }
12326
- )
12327
- ] }) });
12328
- }
12329
- }
12330
- );
12331
- };
12332
- const CustomAmountField = ({
12333
- control,
12334
- currencyCode
12335
- }) => {
12336
- return /* @__PURE__ */ jsx(
12337
- Form$2.Field,
12338
- {
12339
- control,
12340
- name: "custom_amount",
12341
- render: ({ field: { onChange, ...field } }) => {
12342
- return /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12343
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12344
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Custom amount" }),
12345
- /* @__PURE__ */ jsx(Form$2.Hint, { children: "Set a custom amount for the shipping option." })
12346
- ] }),
12347
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12348
- CurrencyInput,
12349
- {
12350
- ...field,
12351
- onValueChange: (value) => onChange(value),
12352
- symbol: getNativeSymbol(currencyCode),
12353
- code: currencyCode
12354
- }
12355
- ) })
12356
- ] });
12357
- }
12358
- }
12359
- );
12360
- };
12361
- const ShippingAddress = () => {
12362
- const { id } = useParams();
12363
- const { order, isPending, isError, error } = useOrder(id, {
12364
- fields: "+shipping_address"
12365
- });
12366
- if (isError) {
12367
- throw error;
12368
- }
12369
- const isReady = !isPending && !!order;
12370
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12371
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12372
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
12373
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12374
- ] }),
12375
- isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
12376
- ] });
12377
- };
12378
- const ShippingAddressForm = ({ order }) => {
12379
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12380
- const form = useForm({
12381
- defaultValues: {
12382
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12383
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12384
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12385
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12386
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12387
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12388
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12389
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12390
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12391
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12392
- },
12393
- resolver: zodResolver(schema$1)
12394
- });
12395
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12396
- const { handleSuccess } = useRouteModal();
12397
- const onSubmit = form.handleSubmit(async (data) => {
12398
- await mutateAsync(
12399
- {
12400
- shipping_address: {
12401
- first_name: data.first_name,
12402
- last_name: data.last_name,
12403
- company: data.company,
12404
- address_1: data.address_1,
12405
- address_2: data.address_2,
12406
- city: data.city,
12407
- province: data.province,
12408
- country_code: data.country_code,
12409
- postal_code: data.postal_code,
12410
- phone: data.phone
12411
- }
12412
- },
12413
- {
12414
- onSuccess: () => {
12415
- handleSuccess();
12416
- },
12417
- onError: (error) => {
12418
- toast.error(error.message);
12419
- }
12420
- }
12421
- );
12422
- });
12423
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12424
- KeyboundForm,
12425
- {
12426
- className: "flex flex-1 flex-col overflow-hidden",
12427
- onSubmit,
12428
- children: [
12429
- /* @__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: [
12430
- /* @__PURE__ */ jsx(
12431
- Form$2.Field,
12432
- {
12433
- control: form.control,
12434
- name: "country_code",
12435
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12436
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
12437
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
12438
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12439
- ] })
12440
- }
12441
- ),
12442
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12443
- /* @__PURE__ */ jsx(
12444
- Form$2.Field,
12445
- {
12446
- control: form.control,
12447
- name: "first_name",
12448
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12449
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
12450
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12451
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12452
- ] })
12453
- }
12454
- ),
12455
- /* @__PURE__ */ jsx(
12456
- Form$2.Field,
12457
- {
12458
- control: form.control,
12459
- name: "last_name",
12460
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12461
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
12462
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12463
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12464
- ] })
12465
- }
12466
- )
12249
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Shipping option" }),
12250
+ /* @__PURE__ */ jsx(Form$2.Hint, { children: "Choose the shipping option to use." })
12467
12251
  ] }),
12468
12252
  /* @__PURE__ */ jsx(
12469
- Form$2.Field,
12470
- {
12471
- control: form.control,
12472
- name: "company",
12473
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12474
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
12475
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12476
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12477
- ] })
12478
- }
12479
- ),
12480
- /* @__PURE__ */ jsx(
12481
- Form$2.Field,
12482
- {
12483
- control: form.control,
12484
- name: "address_1",
12485
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12486
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
12487
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12488
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12489
- ] })
12490
- }
12491
- ),
12492
- /* @__PURE__ */ jsx(
12493
- Form$2.Field,
12253
+ ConditionalTooltip,
12494
12254
  {
12495
- control: form.control,
12496
- name: "address_2",
12497
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12498
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12499
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12500
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12501
- ] })
12255
+ content: tooltipContent,
12256
+ showTooltip: !locationId || !shippingProfileId,
12257
+ children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12258
+ Combobox,
12259
+ {
12260
+ options: shippingOptions.options,
12261
+ fetchNextPage: shippingOptions.fetchNextPage,
12262
+ isFetchingNextPage: shippingOptions.isFetchingNextPage,
12263
+ searchValue: shippingOptions.searchValue,
12264
+ onSearchValueChange: shippingOptions.onSearchValueChange,
12265
+ placeholder: "Select shipping option",
12266
+ ...field,
12267
+ disabled: !locationId || !shippingProfileId
12268
+ }
12269
+ ) }) })
12502
12270
  }
12503
- ),
12504
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12505
- /* @__PURE__ */ jsx(
12506
- Form$2.Field,
12507
- {
12508
- control: form.control,
12509
- name: "postal_code",
12510
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12511
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
12512
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12513
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12514
- ] })
12515
- }
12516
- ),
12517
- /* @__PURE__ */ jsx(
12518
- Form$2.Field,
12519
- {
12520
- control: form.control,
12521
- name: "city",
12522
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12523
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
12524
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12525
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12526
- ] })
12527
- }
12528
- )
12271
+ )
12272
+ ] }) });
12273
+ }
12274
+ }
12275
+ );
12276
+ };
12277
+ const CustomAmountField = ({
12278
+ control,
12279
+ currencyCode
12280
+ }) => {
12281
+ return /* @__PURE__ */ jsx(
12282
+ Form$2.Field,
12283
+ {
12284
+ control,
12285
+ name: "custom_amount",
12286
+ render: ({ field: { onChange, ...field } }) => {
12287
+ return /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12288
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12289
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Custom amount" }),
12290
+ /* @__PURE__ */ jsx(Form$2.Hint, { children: "Set a custom amount for the shipping option." })
12529
12291
  ] }),
12530
- /* @__PURE__ */ jsx(
12531
- Form$2.Field,
12532
- {
12533
- control: form.control,
12534
- name: "province",
12535
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12536
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12537
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12538
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12539
- ] })
12540
- }
12541
- ),
12542
- /* @__PURE__ */ jsx(
12543
- Form$2.Field,
12292
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12293
+ CurrencyInput,
12544
12294
  {
12545
- control: form.control,
12546
- name: "phone",
12547
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12548
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
12549
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12550
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12551
- ] })
12295
+ ...field,
12296
+ onValueChange: (value) => onChange(value),
12297
+ symbol: getNativeSymbol(currencyCode),
12298
+ code: currencyCode
12552
12299
  }
12553
- )
12554
- ] }) }),
12555
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12556
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12557
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12558
- ] }) })
12559
- ]
12300
+ ) })
12301
+ ] });
12302
+ }
12560
12303
  }
12561
- ) });
12304
+ );
12562
12305
  };
12563
- const schema$1 = addressSchema;
12564
12306
  const TransferOwnership = () => {
12565
12307
  const { id } = useParams();
12566
12308
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12584,7 +12326,7 @@ const TransferOwnershipForm = ({ order }) => {
12584
12326
  defaultValues: {
12585
12327
  customer_id: order.customer_id || ""
12586
12328
  },
12587
- resolver: zodResolver(schema)
12329
+ resolver: zodResolver(schema$2)
12588
12330
  });
12589
12331
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12590
12332
  const { handleSuccess } = useRouteModal();
@@ -12974,69 +12716,327 @@ const Illustration = () => {
12974
12716
  strokeLinejoin: "round"
12975
12717
  }
12976
12718
  ) }),
12977
- /* @__PURE__ */ jsxs("defs", { children: [
12978
- /* @__PURE__ */ jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsx(
12979
- "rect",
12719
+ /* @__PURE__ */ jsxs("defs", { children: [
12720
+ /* @__PURE__ */ jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsx(
12721
+ "rect",
12722
+ {
12723
+ width: "12",
12724
+ height: "12",
12725
+ fill: "white",
12726
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
12727
+ }
12728
+ ) }),
12729
+ /* @__PURE__ */ jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsx(
12730
+ "rect",
12731
+ {
12732
+ width: "12",
12733
+ height: "12",
12734
+ fill: "white",
12735
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
12736
+ }
12737
+ ) }),
12738
+ /* @__PURE__ */ jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsx(
12739
+ "rect",
12740
+ {
12741
+ width: "12",
12742
+ height: "12",
12743
+ fill: "white",
12744
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
12745
+ }
12746
+ ) }),
12747
+ /* @__PURE__ */ jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsx(
12748
+ "rect",
12749
+ {
12750
+ width: "12",
12751
+ height: "12",
12752
+ fill: "white",
12753
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
12754
+ }
12755
+ ) }),
12756
+ /* @__PURE__ */ jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsx(
12757
+ "rect",
12758
+ {
12759
+ width: "12",
12760
+ height: "12",
12761
+ fill: "white",
12762
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
12763
+ }
12764
+ ) }),
12765
+ /* @__PURE__ */ jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsx(
12766
+ "rect",
12767
+ {
12768
+ width: "12",
12769
+ height: "12",
12770
+ fill: "white",
12771
+ transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
12772
+ }
12773
+ ) })
12774
+ ] })
12775
+ ]
12776
+ }
12777
+ );
12778
+ };
12779
+ const schema$2 = objectType({
12780
+ customer_id: stringType().min(1)
12781
+ });
12782
+ const Email = () => {
12783
+ const { id } = useParams();
12784
+ const { order, isPending, isError, error } = useOrder(id, {
12785
+ fields: "+email"
12786
+ });
12787
+ if (isError) {
12788
+ throw error;
12789
+ }
12790
+ const isReady = !isPending && !!order;
12791
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12792
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12793
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
12794
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
12795
+ ] }),
12796
+ isReady && /* @__PURE__ */ jsx(EmailForm, { order })
12797
+ ] });
12798
+ };
12799
+ const EmailForm = ({ order }) => {
12800
+ const form = useForm({
12801
+ defaultValues: {
12802
+ email: order.email ?? ""
12803
+ },
12804
+ resolver: zodResolver(schema$1)
12805
+ });
12806
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12807
+ const { handleSuccess } = useRouteModal();
12808
+ const onSubmit = form.handleSubmit(async (data) => {
12809
+ await mutateAsync(
12810
+ { email: data.email },
12811
+ {
12812
+ onSuccess: () => {
12813
+ handleSuccess();
12814
+ },
12815
+ onError: (error) => {
12816
+ toast.error(error.message);
12817
+ }
12818
+ }
12819
+ );
12820
+ });
12821
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12822
+ KeyboundForm,
12823
+ {
12824
+ className: "flex flex-1 flex-col overflow-hidden",
12825
+ onSubmit,
12826
+ children: [
12827
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
12828
+ Form$2.Field,
12829
+ {
12830
+ control: form.control,
12831
+ name: "email",
12832
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12833
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
12834
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12835
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12836
+ ] })
12837
+ }
12838
+ ) }),
12839
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12840
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12841
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12842
+ ] }) })
12843
+ ]
12844
+ }
12845
+ ) });
12846
+ };
12847
+ const schema$1 = objectType({
12848
+ email: stringType().email()
12849
+ });
12850
+ const BillingAddress = () => {
12851
+ const { id } = useParams();
12852
+ const { order, isPending, isError, error } = useOrder(id, {
12853
+ fields: "+billing_address"
12854
+ });
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) ?? ""
12881
+ },
12882
+ resolver: zodResolver(schema)
12883
+ });
12884
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12885
+ const { handleSuccess } = useRouteModal();
12886
+ const onSubmit = form.handleSubmit(async (data) => {
12887
+ await mutateAsync(
12888
+ { billing_address: data },
12889
+ {
12890
+ onSuccess: () => {
12891
+ handleSuccess();
12892
+ },
12893
+ onError: (error) => {
12894
+ toast.error(error.message);
12895
+ }
12896
+ }
12897
+ );
12898
+ });
12899
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12900
+ KeyboundForm,
12901
+ {
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,
12980
12908
  {
12981
- width: "12",
12982
- height: "12",
12983
- fill: "white",
12984
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
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
+ ] })
12985
12916
  }
12986
- ) }),
12987
- /* @__PURE__ */ jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsx(
12988
- "rect",
12917
+ ),
12918
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12919
+ /* @__PURE__ */ jsx(
12920
+ Form$2.Field,
12921
+ {
12922
+ control: form.control,
12923
+ name: "first_name",
12924
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12925
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
12926
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12927
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12928
+ ] })
12929
+ }
12930
+ ),
12931
+ /* @__PURE__ */ jsx(
12932
+ Form$2.Field,
12933
+ {
12934
+ control: form.control,
12935
+ name: "last_name",
12936
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12937
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
12938
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12939
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12940
+ ] })
12941
+ }
12942
+ )
12943
+ ] }),
12944
+ /* @__PURE__ */ jsx(
12945
+ Form$2.Field,
12989
12946
  {
12990
- width: "12",
12991
- height: "12",
12992
- fill: "white",
12993
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
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
+ ] })
12994
12954
  }
12995
- ) }),
12996
- /* @__PURE__ */ jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsx(
12997
- "rect",
12955
+ ),
12956
+ /* @__PURE__ */ jsx(
12957
+ Form$2.Field,
12998
12958
  {
12999
- width: "12",
13000
- height: "12",
13001
- fill: "white",
13002
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
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
+ ] })
13003
12966
  }
13004
- ) }),
13005
- /* @__PURE__ */ jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsx(
13006
- "rect",
12967
+ ),
12968
+ /* @__PURE__ */ jsx(
12969
+ Form$2.Field,
13007
12970
  {
13008
- width: "12",
13009
- height: "12",
13010
- fill: "white",
13011
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
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
+ ] })
13012
12978
  }
13013
- ) }),
13014
- /* @__PURE__ */ jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsx(
13015
- "rect",
12979
+ ),
12980
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12981
+ /* @__PURE__ */ jsx(
12982
+ Form$2.Field,
12983
+ {
12984
+ control: form.control,
12985
+ name: "postal_code",
12986
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12987
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
12988
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12989
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12990
+ ] })
12991
+ }
12992
+ ),
12993
+ /* @__PURE__ */ jsx(
12994
+ Form$2.Field,
12995
+ {
12996
+ control: form.control,
12997
+ name: "city",
12998
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12999
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
13000
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13001
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13002
+ ] })
13003
+ }
13004
+ )
13005
+ ] }),
13006
+ /* @__PURE__ */ jsx(
13007
+ Form$2.Field,
13016
13008
  {
13017
- width: "12",
13018
- height: "12",
13019
- fill: "white",
13020
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
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
+ ] })
13021
13016
  }
13022
- ) }),
13023
- /* @__PURE__ */ jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsx(
13024
- "rect",
13017
+ ),
13018
+ /* @__PURE__ */ jsx(
13019
+ Form$2.Field,
13025
13020
  {
13026
- width: "12",
13027
- height: "12",
13028
- fill: "white",
13029
- transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
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
+ ] })
13030
13028
  }
13031
- ) })
13032
- ] })
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
+ ] }) })
13033
13035
  ]
13034
13036
  }
13035
- );
13037
+ ) });
13036
13038
  };
13037
- const schema = objectType({
13038
- customer_id: stringType().min(1)
13039
- });
13039
+ const schema = addressSchema;
13040
13040
  const widgetModule = { widgets: [] };
13041
13041
  const routeModule = {
13042
13042
  routes: [
@@ -13057,18 +13057,10 @@ const routeModule = {
13057
13057
  handle,
13058
13058
  loader,
13059
13059
  children: [
13060
- {
13061
- Component: BillingAddress,
13062
- path: "/draft-orders/:id/billing-address"
13063
- },
13064
13060
  {
13065
13061
  Component: CustomItems,
13066
13062
  path: "/draft-orders/:id/custom-items"
13067
13063
  },
13068
- {
13069
- Component: Email,
13070
- path: "/draft-orders/:id/email"
13071
- },
13072
13064
  {
13073
13065
  Component: Items,
13074
13066
  path: "/draft-orders/:id/items"
@@ -13085,17 +13077,25 @@ const routeModule = {
13085
13077
  Component: SalesChannel,
13086
13078
  path: "/draft-orders/:id/sales-channel"
13087
13079
  },
13088
- {
13089
- Component: Shipping,
13090
- path: "/draft-orders/:id/shipping"
13091
- },
13092
13080
  {
13093
13081
  Component: ShippingAddress,
13094
13082
  path: "/draft-orders/:id/shipping-address"
13095
13083
  },
13084
+ {
13085
+ Component: Shipping,
13086
+ path: "/draft-orders/:id/shipping"
13087
+ },
13096
13088
  {
13097
13089
  Component: TransferOwnership,
13098
13090
  path: "/draft-orders/:id/transfer-ownership"
13091
+ },
13092
+ {
13093
+ Component: Email,
13094
+ path: "/draft-orders/:id/email"
13095
+ },
13096
+ {
13097
+ Component: BillingAddress,
13098
+ path: "/draft-orders/:id/billing-address"
13099
13099
  }
13100
13100
  ]
13101
13101
  }