@medusajs/draft-order 2.11.4-preview-20251107032027 → 2.11.4-preview-20251107060138

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.
@@ -11441,6 +11441,315 @@ function getPromotionIds(items, shippingMethods) {
11441
11441
  }
11442
11442
  return Array.from(promotionIds);
11443
11443
  }
11444
+ const SalesChannel = () => {
11445
+ const { id } = useParams();
11446
+ const { draft_order, isPending, isError, error } = useDraftOrder(
11447
+ id,
11448
+ {
11449
+ fields: "+sales_channel_id"
11450
+ },
11451
+ {
11452
+ enabled: !!id
11453
+ }
11454
+ );
11455
+ if (isError) {
11456
+ throw error;
11457
+ }
11458
+ const ISrEADY = !!draft_order && !isPending;
11459
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11460
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11461
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
11462
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
11463
+ ] }),
11464
+ ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
11465
+ ] });
11466
+ };
11467
+ const SalesChannelForm = ({ order }) => {
11468
+ const form = useForm({
11469
+ defaultValues: {
11470
+ sales_channel_id: order.sales_channel_id || ""
11471
+ },
11472
+ resolver: zodResolver(schema$2)
11473
+ });
11474
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11475
+ const { handleSuccess } = useRouteModal();
11476
+ const onSubmit = form.handleSubmit(async (data) => {
11477
+ await mutateAsync(
11478
+ {
11479
+ sales_channel_id: data.sales_channel_id
11480
+ },
11481
+ {
11482
+ onSuccess: () => {
11483
+ toast.success("Sales channel updated");
11484
+ handleSuccess();
11485
+ },
11486
+ onError: (error) => {
11487
+ toast.error(error.message);
11488
+ }
11489
+ }
11490
+ );
11491
+ });
11492
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11493
+ KeyboundForm,
11494
+ {
11495
+ className: "flex flex-1 flex-col overflow-hidden",
11496
+ onSubmit,
11497
+ children: [
11498
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
11499
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11500
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11501
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11502
+ ] }) })
11503
+ ]
11504
+ }
11505
+ ) });
11506
+ };
11507
+ const SalesChannelField = ({ control, order }) => {
11508
+ const salesChannels = useComboboxData({
11509
+ queryFn: async (params) => {
11510
+ return await sdk.admin.salesChannel.list(params);
11511
+ },
11512
+ queryKey: ["sales-channels"],
11513
+ getOptions: (data) => {
11514
+ return data.sales_channels.map((salesChannel) => ({
11515
+ label: salesChannel.name,
11516
+ value: salesChannel.id
11517
+ }));
11518
+ },
11519
+ defaultValue: order.sales_channel_id || void 0
11520
+ });
11521
+ return /* @__PURE__ */ jsx(
11522
+ Form$2.Field,
11523
+ {
11524
+ control,
11525
+ name: "sales_channel_id",
11526
+ render: ({ field }) => {
11527
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11528
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
11529
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
11530
+ Combobox,
11531
+ {
11532
+ options: salesChannels.options,
11533
+ fetchNextPage: salesChannels.fetchNextPage,
11534
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
11535
+ searchValue: salesChannels.searchValue,
11536
+ onSearchValueChange: salesChannels.onSearchValueChange,
11537
+ placeholder: "Select sales channel",
11538
+ ...field
11539
+ }
11540
+ ) }),
11541
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11542
+ ] });
11543
+ }
11544
+ }
11545
+ );
11546
+ };
11547
+ const schema$2 = objectType({
11548
+ sales_channel_id: stringType().min(1)
11549
+ });
11550
+ const ShippingAddress = () => {
11551
+ const { id } = useParams();
11552
+ const { order, isPending, isError, error } = useOrder(id, {
11553
+ fields: "+shipping_address"
11554
+ });
11555
+ if (isError) {
11556
+ throw error;
11557
+ }
11558
+ const isReady = !isPending && !!order;
11559
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11560
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11561
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
11562
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
11563
+ ] }),
11564
+ isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
11565
+ ] });
11566
+ };
11567
+ const ShippingAddressForm = ({ order }) => {
11568
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11569
+ const form = useForm({
11570
+ defaultValues: {
11571
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
11572
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
11573
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
11574
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
11575
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
11576
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
11577
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
11578
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
11579
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
11580
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
11581
+ },
11582
+ resolver: zodResolver(schema$1)
11583
+ });
11584
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11585
+ const { handleSuccess } = useRouteModal();
11586
+ const onSubmit = form.handleSubmit(async (data) => {
11587
+ await mutateAsync(
11588
+ {
11589
+ shipping_address: {
11590
+ first_name: data.first_name,
11591
+ last_name: data.last_name,
11592
+ company: data.company,
11593
+ address_1: data.address_1,
11594
+ address_2: data.address_2,
11595
+ city: data.city,
11596
+ province: data.province,
11597
+ country_code: data.country_code,
11598
+ postal_code: data.postal_code,
11599
+ phone: data.phone
11600
+ }
11601
+ },
11602
+ {
11603
+ onSuccess: () => {
11604
+ handleSuccess();
11605
+ },
11606
+ onError: (error) => {
11607
+ toast.error(error.message);
11608
+ }
11609
+ }
11610
+ );
11611
+ });
11612
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11613
+ KeyboundForm,
11614
+ {
11615
+ className: "flex flex-1 flex-col overflow-hidden",
11616
+ onSubmit,
11617
+ children: [
11618
+ /* @__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: [
11619
+ /* @__PURE__ */ jsx(
11620
+ Form$2.Field,
11621
+ {
11622
+ control: form.control,
11623
+ name: "country_code",
11624
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11625
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
11626
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
11627
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11628
+ ] })
11629
+ }
11630
+ ),
11631
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11632
+ /* @__PURE__ */ jsx(
11633
+ Form$2.Field,
11634
+ {
11635
+ control: form.control,
11636
+ name: "first_name",
11637
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11638
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
11639
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11640
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11641
+ ] })
11642
+ }
11643
+ ),
11644
+ /* @__PURE__ */ jsx(
11645
+ Form$2.Field,
11646
+ {
11647
+ control: form.control,
11648
+ name: "last_name",
11649
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11650
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
11651
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11652
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11653
+ ] })
11654
+ }
11655
+ )
11656
+ ] }),
11657
+ /* @__PURE__ */ jsx(
11658
+ Form$2.Field,
11659
+ {
11660
+ control: form.control,
11661
+ name: "company",
11662
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11663
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
11664
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11665
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11666
+ ] })
11667
+ }
11668
+ ),
11669
+ /* @__PURE__ */ jsx(
11670
+ Form$2.Field,
11671
+ {
11672
+ control: form.control,
11673
+ name: "address_1",
11674
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11675
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
11676
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11677
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11678
+ ] })
11679
+ }
11680
+ ),
11681
+ /* @__PURE__ */ jsx(
11682
+ Form$2.Field,
11683
+ {
11684
+ control: form.control,
11685
+ name: "address_2",
11686
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11687
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11688
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11689
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11690
+ ] })
11691
+ }
11692
+ ),
11693
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11694
+ /* @__PURE__ */ jsx(
11695
+ Form$2.Field,
11696
+ {
11697
+ control: form.control,
11698
+ name: "postal_code",
11699
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11700
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
11701
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11702
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11703
+ ] })
11704
+ }
11705
+ ),
11706
+ /* @__PURE__ */ jsx(
11707
+ Form$2.Field,
11708
+ {
11709
+ control: form.control,
11710
+ name: "city",
11711
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11712
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
11713
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11714
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11715
+ ] })
11716
+ }
11717
+ )
11718
+ ] }),
11719
+ /* @__PURE__ */ jsx(
11720
+ Form$2.Field,
11721
+ {
11722
+ control: form.control,
11723
+ name: "province",
11724
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11725
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11726
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11727
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11728
+ ] })
11729
+ }
11730
+ ),
11731
+ /* @__PURE__ */ jsx(
11732
+ Form$2.Field,
11733
+ {
11734
+ control: form.control,
11735
+ name: "phone",
11736
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11737
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
11738
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11739
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11740
+ ] })
11741
+ }
11742
+ )
11743
+ ] }) }),
11744
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11745
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11746
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11747
+ ] }) })
11748
+ ]
11749
+ }
11750
+ ) });
11751
+ };
11752
+ const schema$1 = addressSchema;
11444
11753
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11445
11754
  const Shipping = () => {
11446
11755
  var _a;
@@ -12191,266 +12500,63 @@ const ShippingOptionField = ({
12191
12500
  render: ({ field }) => {
12192
12501
  return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12193
12502
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12194
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Shipping option" }),
12195
- /* @__PURE__ */ jsx(Form$2.Hint, { children: "Choose the shipping option to use." })
12196
- ] }),
12197
- /* @__PURE__ */ jsx(
12198
- ConditionalTooltip,
12199
- {
12200
- content: tooltipContent,
12201
- showTooltip: !locationId || !shippingProfileId,
12202
- children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12203
- Combobox,
12204
- {
12205
- options: shippingOptions.options,
12206
- fetchNextPage: shippingOptions.fetchNextPage,
12207
- isFetchingNextPage: shippingOptions.isFetchingNextPage,
12208
- searchValue: shippingOptions.searchValue,
12209
- onSearchValueChange: shippingOptions.onSearchValueChange,
12210
- placeholder: "Select shipping option",
12211
- ...field,
12212
- disabled: !locationId || !shippingProfileId
12213
- }
12214
- ) }) })
12215
- }
12216
- )
12217
- ] }) });
12218
- }
12219
- }
12220
- );
12221
- };
12222
- const CustomAmountField = ({
12223
- control,
12224
- currencyCode
12225
- }) => {
12226
- return /* @__PURE__ */ jsx(
12227
- Form$2.Field,
12228
- {
12229
- control,
12230
- name: "custom_amount",
12231
- render: ({ field: { onChange, ...field } }) => {
12232
- return /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12233
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12234
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Custom amount" }),
12235
- /* @__PURE__ */ jsx(Form$2.Hint, { children: "Set a custom amount for the shipping option." })
12236
- ] }),
12237
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12238
- CurrencyInput,
12239
- {
12240
- ...field,
12241
- onValueChange: (value) => onChange(value),
12242
- symbol: getNativeSymbol(currencyCode),
12243
- code: currencyCode
12244
- }
12245
- ) })
12246
- ] });
12247
- }
12248
- }
12249
- );
12250
- };
12251
- const ShippingAddress = () => {
12252
- const { id } = useParams();
12253
- const { order, isPending, isError, error } = useOrder(id, {
12254
- fields: "+shipping_address"
12255
- });
12256
- if (isError) {
12257
- throw error;
12258
- }
12259
- const isReady = !isPending && !!order;
12260
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12261
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12262
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
12263
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12264
- ] }),
12265
- isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
12266
- ] });
12267
- };
12268
- const ShippingAddressForm = ({ order }) => {
12269
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12270
- const form = useForm({
12271
- defaultValues: {
12272
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12273
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12274
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12275
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12276
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12277
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12278
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12279
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12280
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12281
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12282
- },
12283
- resolver: zodResolver(schema$2)
12284
- });
12285
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12286
- const { handleSuccess } = useRouteModal();
12287
- const onSubmit = form.handleSubmit(async (data) => {
12288
- await mutateAsync(
12289
- {
12290
- shipping_address: {
12291
- first_name: data.first_name,
12292
- last_name: data.last_name,
12293
- company: data.company,
12294
- address_1: data.address_1,
12295
- address_2: data.address_2,
12296
- city: data.city,
12297
- province: data.province,
12298
- country_code: data.country_code,
12299
- postal_code: data.postal_code,
12300
- phone: data.phone
12301
- }
12302
- },
12303
- {
12304
- onSuccess: () => {
12305
- handleSuccess();
12306
- },
12307
- onError: (error) => {
12308
- toast.error(error.message);
12309
- }
12310
- }
12311
- );
12312
- });
12313
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12314
- KeyboundForm,
12315
- {
12316
- className: "flex flex-1 flex-col overflow-hidden",
12317
- onSubmit,
12318
- children: [
12319
- /* @__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: [
12320
- /* @__PURE__ */ jsx(
12321
- Form$2.Field,
12322
- {
12323
- control: form.control,
12324
- name: "country_code",
12325
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12326
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
12327
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
12328
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12329
- ] })
12330
- }
12331
- ),
12332
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12333
- /* @__PURE__ */ jsx(
12334
- Form$2.Field,
12335
- {
12336
- control: form.control,
12337
- name: "first_name",
12338
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12339
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
12340
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12341
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12342
- ] })
12343
- }
12344
- ),
12345
- /* @__PURE__ */ jsx(
12346
- Form$2.Field,
12347
- {
12348
- control: form.control,
12349
- name: "last_name",
12350
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12351
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
12352
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12353
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12354
- ] })
12355
- }
12356
- )
12503
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Shipping option" }),
12504
+ /* @__PURE__ */ jsx(Form$2.Hint, { children: "Choose the shipping option to use." })
12357
12505
  ] }),
12358
12506
  /* @__PURE__ */ jsx(
12359
- Form$2.Field,
12360
- {
12361
- control: form.control,
12362
- name: "company",
12363
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12364
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
12365
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12366
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12367
- ] })
12368
- }
12369
- ),
12370
- /* @__PURE__ */ jsx(
12371
- Form$2.Field,
12372
- {
12373
- control: form.control,
12374
- name: "address_1",
12375
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12376
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
12377
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12378
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12379
- ] })
12380
- }
12381
- ),
12382
- /* @__PURE__ */ jsx(
12383
- Form$2.Field,
12507
+ ConditionalTooltip,
12384
12508
  {
12385
- control: form.control,
12386
- name: "address_2",
12387
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12388
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12389
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12390
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12391
- ] })
12509
+ content: tooltipContent,
12510
+ showTooltip: !locationId || !shippingProfileId,
12511
+ children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12512
+ Combobox,
12513
+ {
12514
+ options: shippingOptions.options,
12515
+ fetchNextPage: shippingOptions.fetchNextPage,
12516
+ isFetchingNextPage: shippingOptions.isFetchingNextPage,
12517
+ searchValue: shippingOptions.searchValue,
12518
+ onSearchValueChange: shippingOptions.onSearchValueChange,
12519
+ placeholder: "Select shipping option",
12520
+ ...field,
12521
+ disabled: !locationId || !shippingProfileId
12522
+ }
12523
+ ) }) })
12392
12524
  }
12393
- ),
12394
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12395
- /* @__PURE__ */ jsx(
12396
- Form$2.Field,
12397
- {
12398
- control: form.control,
12399
- name: "postal_code",
12400
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12401
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
12402
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12403
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12404
- ] })
12405
- }
12406
- ),
12407
- /* @__PURE__ */ jsx(
12408
- Form$2.Field,
12409
- {
12410
- control: form.control,
12411
- name: "city",
12412
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12413
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
12414
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12415
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12416
- ] })
12417
- }
12418
- )
12525
+ )
12526
+ ] }) });
12527
+ }
12528
+ }
12529
+ );
12530
+ };
12531
+ const CustomAmountField = ({
12532
+ control,
12533
+ currencyCode
12534
+ }) => {
12535
+ return /* @__PURE__ */ jsx(
12536
+ Form$2.Field,
12537
+ {
12538
+ control,
12539
+ name: "custom_amount",
12540
+ render: ({ field: { onChange, ...field } }) => {
12541
+ return /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
12542
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
12543
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Custom amount" }),
12544
+ /* @__PURE__ */ jsx(Form$2.Hint, { children: "Set a custom amount for the shipping option." })
12419
12545
  ] }),
12420
- /* @__PURE__ */ jsx(
12421
- Form$2.Field,
12422
- {
12423
- control: form.control,
12424
- name: "province",
12425
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12426
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12427
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12428
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12429
- ] })
12430
- }
12431
- ),
12432
- /* @__PURE__ */ jsx(
12433
- Form$2.Field,
12546
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12547
+ CurrencyInput,
12434
12548
  {
12435
- control: form.control,
12436
- name: "phone",
12437
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12438
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
12439
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12440
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12441
- ] })
12549
+ ...field,
12550
+ onValueChange: (value) => onChange(value),
12551
+ symbol: getNativeSymbol(currencyCode),
12552
+ code: currencyCode
12442
12553
  }
12443
- )
12444
- ] }) }),
12445
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12446
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12447
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12448
- ] }) })
12449
- ]
12554
+ ) })
12555
+ ] });
12556
+ }
12450
12557
  }
12451
- ) });
12558
+ );
12452
12559
  };
12453
- const schema$2 = addressSchema;
12454
12560
  const TransferOwnership = () => {
12455
12561
  const { id } = useParams();
12456
12562
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12474,7 +12580,7 @@ const TransferOwnershipForm = ({ order }) => {
12474
12580
  defaultValues: {
12475
12581
  customer_id: order.customer_id || ""
12476
12582
  },
12477
- resolver: zodResolver(schema$1)
12583
+ resolver: zodResolver(schema)
12478
12584
  });
12479
12585
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12480
12586
  const { handleSuccess } = useRouteModal();
@@ -12924,114 +13030,8 @@ const Illustration = () => {
12924
13030
  }
12925
13031
  );
12926
13032
  };
12927
- const schema$1 = objectType({
12928
- customer_id: stringType().min(1)
12929
- });
12930
- const SalesChannel = () => {
12931
- const { id } = useParams();
12932
- const { draft_order, isPending, isError, error } = useDraftOrder(
12933
- id,
12934
- {
12935
- fields: "+sales_channel_id"
12936
- },
12937
- {
12938
- enabled: !!id
12939
- }
12940
- );
12941
- if (isError) {
12942
- throw error;
12943
- }
12944
- const ISrEADY = !!draft_order && !isPending;
12945
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12946
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12947
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
12948
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
12949
- ] }),
12950
- ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
12951
- ] });
12952
- };
12953
- const SalesChannelForm = ({ order }) => {
12954
- const form = useForm({
12955
- defaultValues: {
12956
- sales_channel_id: order.sales_channel_id || ""
12957
- },
12958
- resolver: zodResolver(schema)
12959
- });
12960
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12961
- const { handleSuccess } = useRouteModal();
12962
- const onSubmit = form.handleSubmit(async (data) => {
12963
- await mutateAsync(
12964
- {
12965
- sales_channel_id: data.sales_channel_id
12966
- },
12967
- {
12968
- onSuccess: () => {
12969
- toast.success("Sales channel updated");
12970
- handleSuccess();
12971
- },
12972
- onError: (error) => {
12973
- toast.error(error.message);
12974
- }
12975
- }
12976
- );
12977
- });
12978
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12979
- KeyboundForm,
12980
- {
12981
- className: "flex flex-1 flex-col overflow-hidden",
12982
- onSubmit,
12983
- children: [
12984
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
12985
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12986
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12987
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12988
- ] }) })
12989
- ]
12990
- }
12991
- ) });
12992
- };
12993
- const SalesChannelField = ({ control, order }) => {
12994
- const salesChannels = useComboboxData({
12995
- queryFn: async (params) => {
12996
- return await sdk.admin.salesChannel.list(params);
12997
- },
12998
- queryKey: ["sales-channels"],
12999
- getOptions: (data) => {
13000
- return data.sales_channels.map((salesChannel) => ({
13001
- label: salesChannel.name,
13002
- value: salesChannel.id
13003
- }));
13004
- },
13005
- defaultValue: order.sales_channel_id || void 0
13006
- });
13007
- return /* @__PURE__ */ jsx(
13008
- Form$2.Field,
13009
- {
13010
- control,
13011
- name: "sales_channel_id",
13012
- render: ({ field }) => {
13013
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13014
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
13015
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
13016
- Combobox,
13017
- {
13018
- options: salesChannels.options,
13019
- fetchNextPage: salesChannels.fetchNextPage,
13020
- isFetchingNextPage: salesChannels.isFetchingNextPage,
13021
- searchValue: salesChannels.searchValue,
13022
- onSearchValueChange: salesChannels.onSearchValueChange,
13023
- placeholder: "Select sales channel",
13024
- ...field
13025
- }
13026
- ) }),
13027
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13028
- ] });
13029
- }
13030
- }
13031
- );
13032
- };
13033
13033
  const schema = objectType({
13034
- sales_channel_id: stringType().min(1)
13034
+ customer_id: stringType().min(1)
13035
13035
  });
13036
13036
  const widgetModule = { widgets: [] };
13037
13037
  const routeModule = {
@@ -13078,20 +13078,20 @@ const routeModule = {
13078
13078
  path: "/draft-orders/:id/promotions"
13079
13079
  },
13080
13080
  {
13081
- Component: Shipping,
13082
- path: "/draft-orders/:id/shipping"
13081
+ Component: SalesChannel,
13082
+ path: "/draft-orders/:id/sales-channel"
13083
13083
  },
13084
13084
  {
13085
13085
  Component: ShippingAddress,
13086
13086
  path: "/draft-orders/:id/shipping-address"
13087
13087
  },
13088
13088
  {
13089
- Component: TransferOwnership,
13090
- path: "/draft-orders/:id/transfer-ownership"
13089
+ Component: Shipping,
13090
+ path: "/draft-orders/:id/shipping"
13091
13091
  },
13092
13092
  {
13093
- Component: SalesChannel,
13094
- path: "/draft-orders/:id/sales-channel"
13093
+ Component: TransferOwnership,
13094
+ path: "/draft-orders/:id/transfer-ownership"
13095
13095
  }
13096
13096
  ]
13097
13097
  }