@medusajs/draft-order 2.22.6 → 2.22.7-snapshot-20261111153147

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.
@@ -6098,198 +6098,6 @@ const ID = () => {
6098
6098
  }
6099
6099
  );
6100
6100
  };
6101
- const BillingAddress = () => {
6102
- const { id } = reactRouterDom.useParams();
6103
- const { order, isPending, isError, error } = useOrder(id, {
6104
- fields: "+billing_address"
6105
- });
6106
- if (isError) {
6107
- throw error;
6108
- }
6109
- const isReady = !isPending && !!order;
6110
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
6111
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
6112
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
6113
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
6114
- ] }),
6115
- isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
6116
- ] });
6117
- };
6118
- const BillingAddressForm = ({ order }) => {
6119
- const form = reactHookForm.useForm({
6120
- defaultValues: {
6121
- first_name: order.billing_address?.first_name ?? "",
6122
- last_name: order.billing_address?.last_name ?? "",
6123
- company: order.billing_address?.company ?? "",
6124
- address_1: order.billing_address?.address_1 ?? "",
6125
- address_2: order.billing_address?.address_2 ?? "",
6126
- city: order.billing_address?.city ?? "",
6127
- province: order.billing_address?.province ?? "",
6128
- country_code: order.billing_address?.country_code ?? "",
6129
- postal_code: order.billing_address?.postal_code ?? "",
6130
- phone: order.billing_address?.phone ?? ""
6131
- },
6132
- resolver: zod$1.zodResolver(schema$5)
6133
- });
6134
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
6135
- const { handleSuccess } = useRouteModal();
6136
- const onSubmit = form.handleSubmit(async (data) => {
6137
- await mutateAsync(
6138
- { billing_address: data },
6139
- {
6140
- onSuccess: () => {
6141
- handleSuccess();
6142
- },
6143
- onError: (error) => {
6144
- ui.toast.error(error.message);
6145
- }
6146
- }
6147
- );
6148
- });
6149
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
6150
- KeyboundForm,
6151
- {
6152
- className: "flex flex-1 flex-col overflow-hidden",
6153
- onSubmit,
6154
- children: [
6155
- /* @__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: [
6156
- /* @__PURE__ */ jsxRuntime.jsx(
6157
- Form$2.Field,
6158
- {
6159
- control: form.control,
6160
- name: "country_code",
6161
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
6162
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
6163
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
6164
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
6165
- ] })
6166
- }
6167
- ),
6168
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
6169
- /* @__PURE__ */ jsxRuntime.jsx(
6170
- Form$2.Field,
6171
- {
6172
- control: form.control,
6173
- name: "first_name",
6174
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
6175
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
6176
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
6177
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
6178
- ] })
6179
- }
6180
- ),
6181
- /* @__PURE__ */ jsxRuntime.jsx(
6182
- Form$2.Field,
6183
- {
6184
- control: form.control,
6185
- name: "last_name",
6186
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
6187
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
6188
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
6189
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
6190
- ] })
6191
- }
6192
- )
6193
- ] }),
6194
- /* @__PURE__ */ jsxRuntime.jsx(
6195
- Form$2.Field,
6196
- {
6197
- control: form.control,
6198
- name: "company",
6199
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
6200
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
6201
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
6202
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
6203
- ] })
6204
- }
6205
- ),
6206
- /* @__PURE__ */ jsxRuntime.jsx(
6207
- Form$2.Field,
6208
- {
6209
- control: form.control,
6210
- name: "address_1",
6211
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
6212
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
6213
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
6214
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
6215
- ] })
6216
- }
6217
- ),
6218
- /* @__PURE__ */ jsxRuntime.jsx(
6219
- Form$2.Field,
6220
- {
6221
- control: form.control,
6222
- name: "address_2",
6223
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
6224
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
6225
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
6226
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
6227
- ] })
6228
- }
6229
- ),
6230
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
6231
- /* @__PURE__ */ jsxRuntime.jsx(
6232
- Form$2.Field,
6233
- {
6234
- control: form.control,
6235
- name: "postal_code",
6236
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
6237
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
6238
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
6239
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
6240
- ] })
6241
- }
6242
- ),
6243
- /* @__PURE__ */ jsxRuntime.jsx(
6244
- Form$2.Field,
6245
- {
6246
- control: form.control,
6247
- name: "city",
6248
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
6249
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
6250
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
6251
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
6252
- ] })
6253
- }
6254
- )
6255
- ] }),
6256
- /* @__PURE__ */ jsxRuntime.jsx(
6257
- Form$2.Field,
6258
- {
6259
- control: form.control,
6260
- name: "province",
6261
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
6262
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
6263
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
6264
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
6265
- ] })
6266
- }
6267
- ),
6268
- /* @__PURE__ */ jsxRuntime.jsx(
6269
- Form$2.Field,
6270
- {
6271
- control: form.control,
6272
- name: "phone",
6273
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
6274
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
6275
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
6276
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
6277
- ] })
6278
- }
6279
- )
6280
- ] }) }),
6281
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
6282
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
6283
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
6284
- ] }) })
6285
- ]
6286
- }
6287
- ) });
6288
- };
6289
- const schema$5 = addressSchema;
6290
- const handle$9 = {
6291
- permissions: EDIT_DRAFT_ORDER_PERMISSIONS
6292
- };
6293
6101
  const CustomItems = () => {
6294
6102
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
6295
6103
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
@@ -6298,7 +6106,7 @@ const CustomItems = () => {
6298
6106
  };
6299
6107
  const CustomItemsForm = () => {
6300
6108
  const form = reactHookForm.useForm({
6301
- resolver: zod$1.zodResolver(schema$4)
6109
+ resolver: zod$1.zodResolver(schema$5)
6302
6110
  });
6303
6111
  return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
6304
6112
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
@@ -6308,10 +6116,10 @@ const CustomItemsForm = () => {
6308
6116
  ] }) })
6309
6117
  ] }) });
6310
6118
  };
6311
- const schema$4 = zod.z.object({
6119
+ const schema$5 = zod.z.object({
6312
6120
  email: zod.z.string().email()
6313
6121
  });
6314
- const handle$8 = {
6122
+ const handle$9 = {
6315
6123
  permissions: EDIT_DRAFT_ORDER_PERMISSIONS
6316
6124
  };
6317
6125
  const Email = () => {
@@ -6336,7 +6144,7 @@ const EmailForm = ({ order }) => {
6336
6144
  defaultValues: {
6337
6145
  email: order.email ?? ""
6338
6146
  },
6339
- resolver: zod$1.zodResolver(schema$3)
6147
+ resolver: zod$1.zodResolver(schema$4)
6340
6148
  });
6341
6149
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
6342
6150
  const { handleSuccess } = useRouteModal();
@@ -6379,10 +6187,10 @@ const EmailForm = ({ order }) => {
6379
6187
  }
6380
6188
  ) });
6381
6189
  };
6382
- const schema$3 = zod.z.object({
6190
+ const schema$4 = zod.z.object({
6383
6191
  email: zod.z.string().email()
6384
6192
  });
6385
- const handle$7 = {
6193
+ const handle$8 = {
6386
6194
  permissions: EDIT_DRAFT_ORDER_PERMISSIONS
6387
6195
  };
6388
6196
  const NumberInput = React.forwardRef(
@@ -7406,7 +7214,7 @@ const customItemSchema = zod.z.object({
7406
7214
  quantity: zod.z.number(),
7407
7215
  unit_price: zod.z.union([zod.z.number(), zod.z.string()])
7408
7216
  });
7409
- const handle$6 = {
7217
+ const handle$7 = {
7410
7218
  permissions: EDIT_DRAFT_ORDER_PERMISSIONS
7411
7219
  };
7412
7220
  const InlineTip = React.forwardRef(
@@ -7759,7 +7567,7 @@ function getHasUneditableRows(metadata) {
7759
7567
  (value) => !EDITABLE_TYPES.includes(typeof value)
7760
7568
  );
7761
7569
  }
7762
- const handle$5 = {
7570
+ const handle$6 = {
7763
7571
  permissions: EDIT_DRAFT_ORDER_PERMISSIONS
7764
7572
  };
7765
7573
  const PROMOTION_QUERY_KEY = "promotions";
@@ -8037,7 +7845,7 @@ function getPromotionIds(items, shippingMethods) {
8037
7845
  }
8038
7846
  return Array.from(promotionIds);
8039
7847
  }
8040
- const handle$4 = {
7848
+ const handle$5 = {
8041
7849
  permissions: EDIT_DRAFT_ORDER_PROMOTIONS_PERMISSIONS
8042
7850
  };
8043
7851
  const SalesChannel = () => {
@@ -8068,7 +7876,7 @@ const SalesChannelForm = ({ order }) => {
8068
7876
  defaultValues: {
8069
7877
  sales_channel_id: order.sales_channel_id || ""
8070
7878
  },
8071
- resolver: zod$1.zodResolver(schema$2)
7879
+ resolver: zod$1.zodResolver(schema$3)
8072
7880
  });
8073
7881
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
8074
7882
  const { handleSuccess } = useRouteModal();
@@ -8143,10 +7951,10 @@ const SalesChannelField = ({ control, order }) => {
8143
7951
  }
8144
7952
  );
8145
7953
  };
8146
- const schema$2 = zod.z.object({
7954
+ const schema$3 = zod.z.object({
8147
7955
  sales_channel_id: zod.z.string().min(1)
8148
7956
  });
8149
- const handle$3 = {
7957
+ const handle$4 = {
8150
7958
  permissions: EDIT_DRAFT_ORDER_SALES_CHANNEL_PERMISSIONS
8151
7959
  };
8152
7960
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
@@ -8943,7 +8751,7 @@ const CustomAmountField = ({
8943
8751
  }
8944
8752
  );
8945
8753
  };
8946
- const handle$2 = {
8754
+ const handle$3 = {
8947
8755
  permissions: EDIT_DRAFT_ORDER_SHIPPING_PERMISSIONS
8948
8756
  };
8949
8757
  const ShippingAddress = () => {
@@ -8977,7 +8785,7 @@ const ShippingAddressForm = ({ order }) => {
8977
8785
  postal_code: order.shipping_address?.postal_code ?? "",
8978
8786
  phone: order.shipping_address?.phone ?? ""
8979
8787
  },
8980
- resolver: zod$1.zodResolver(schema$1)
8788
+ resolver: zod$1.zodResolver(schema$2)
8981
8789
  });
8982
8790
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
8983
8791
  const { handleSuccess } = useRouteModal();
@@ -9147,8 +8955,8 @@ const ShippingAddressForm = ({ order }) => {
9147
8955
  }
9148
8956
  ) });
9149
8957
  };
9150
- const schema$1 = addressSchema;
9151
- const handle$1 = {
8958
+ const schema$2 = addressSchema;
8959
+ const handle$2 = {
9152
8960
  permissions: EDIT_DRAFT_ORDER_PERMISSIONS
9153
8961
  };
9154
8962
  const TransferOwnership = () => {
@@ -9173,7 +8981,7 @@ const TransferOwnershipForm = ({ order }) => {
9173
8981
  defaultValues: {
9174
8982
  customer_id: order.customer_id || ""
9175
8983
  },
9176
- resolver: zod$1.zodResolver(schema)
8984
+ resolver: zod$1.zodResolver(schema$1)
9177
8985
  });
9178
8986
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9179
8987
  const { handleSuccess } = useRouteModal();
@@ -9625,12 +9433,204 @@ const Illustration = () => {
9625
9433
  }
9626
9434
  );
9627
9435
  };
9628
- const schema = zod.z.object({
9436
+ const schema$1 = zod.z.object({
9629
9437
  customer_id: zod.z.string().min(1)
9630
9438
  });
9631
- const handle = {
9439
+ const handle$1 = {
9632
9440
  permissions: TRANSFER_DRAFT_ORDER_PERMISSIONS
9633
9441
  };
9442
+ const BillingAddress = () => {
9443
+ const { id } = reactRouterDom.useParams();
9444
+ const { order, isPending, isError, error } = useOrder(id, {
9445
+ fields: "+billing_address"
9446
+ });
9447
+ if (isError) {
9448
+ throw error;
9449
+ }
9450
+ const isReady = !isPending && !!order;
9451
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9452
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9453
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
9454
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9455
+ ] }),
9456
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
9457
+ ] });
9458
+ };
9459
+ const BillingAddressForm = ({ order }) => {
9460
+ const form = reactHookForm.useForm({
9461
+ defaultValues: {
9462
+ first_name: order.billing_address?.first_name ?? "",
9463
+ last_name: order.billing_address?.last_name ?? "",
9464
+ company: order.billing_address?.company ?? "",
9465
+ address_1: order.billing_address?.address_1 ?? "",
9466
+ address_2: order.billing_address?.address_2 ?? "",
9467
+ city: order.billing_address?.city ?? "",
9468
+ province: order.billing_address?.province ?? "",
9469
+ country_code: order.billing_address?.country_code ?? "",
9470
+ postal_code: order.billing_address?.postal_code ?? "",
9471
+ phone: order.billing_address?.phone ?? ""
9472
+ },
9473
+ resolver: zod$1.zodResolver(schema)
9474
+ });
9475
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9476
+ const { handleSuccess } = useRouteModal();
9477
+ const onSubmit = form.handleSubmit(async (data) => {
9478
+ await mutateAsync(
9479
+ { billing_address: data },
9480
+ {
9481
+ onSuccess: () => {
9482
+ handleSuccess();
9483
+ },
9484
+ onError: (error) => {
9485
+ ui.toast.error(error.message);
9486
+ }
9487
+ }
9488
+ );
9489
+ });
9490
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
9491
+ KeyboundForm,
9492
+ {
9493
+ className: "flex flex-1 flex-col overflow-hidden",
9494
+ onSubmit,
9495
+ children: [
9496
+ /* @__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: [
9497
+ /* @__PURE__ */ jsxRuntime.jsx(
9498
+ Form$2.Field,
9499
+ {
9500
+ control: form.control,
9501
+ name: "country_code",
9502
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9503
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
9504
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
9505
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9506
+ ] })
9507
+ }
9508
+ ),
9509
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9510
+ /* @__PURE__ */ jsxRuntime.jsx(
9511
+ Form$2.Field,
9512
+ {
9513
+ control: form.control,
9514
+ name: "first_name",
9515
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9516
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
9517
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9518
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9519
+ ] })
9520
+ }
9521
+ ),
9522
+ /* @__PURE__ */ jsxRuntime.jsx(
9523
+ Form$2.Field,
9524
+ {
9525
+ control: form.control,
9526
+ name: "last_name",
9527
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9528
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
9529
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9530
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9531
+ ] })
9532
+ }
9533
+ )
9534
+ ] }),
9535
+ /* @__PURE__ */ jsxRuntime.jsx(
9536
+ Form$2.Field,
9537
+ {
9538
+ control: form.control,
9539
+ name: "company",
9540
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9541
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
9542
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9543
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9544
+ ] })
9545
+ }
9546
+ ),
9547
+ /* @__PURE__ */ jsxRuntime.jsx(
9548
+ Form$2.Field,
9549
+ {
9550
+ control: form.control,
9551
+ name: "address_1",
9552
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9553
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
9554
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9555
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9556
+ ] })
9557
+ }
9558
+ ),
9559
+ /* @__PURE__ */ jsxRuntime.jsx(
9560
+ Form$2.Field,
9561
+ {
9562
+ control: form.control,
9563
+ name: "address_2",
9564
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9565
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9566
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9567
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9568
+ ] })
9569
+ }
9570
+ ),
9571
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9572
+ /* @__PURE__ */ jsxRuntime.jsx(
9573
+ Form$2.Field,
9574
+ {
9575
+ control: form.control,
9576
+ name: "postal_code",
9577
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9578
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
9579
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9580
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9581
+ ] })
9582
+ }
9583
+ ),
9584
+ /* @__PURE__ */ jsxRuntime.jsx(
9585
+ Form$2.Field,
9586
+ {
9587
+ control: form.control,
9588
+ name: "city",
9589
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9590
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
9591
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9592
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9593
+ ] })
9594
+ }
9595
+ )
9596
+ ] }),
9597
+ /* @__PURE__ */ jsxRuntime.jsx(
9598
+ Form$2.Field,
9599
+ {
9600
+ control: form.control,
9601
+ name: "province",
9602
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9603
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9604
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9605
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9606
+ ] })
9607
+ }
9608
+ ),
9609
+ /* @__PURE__ */ jsxRuntime.jsx(
9610
+ Form$2.Field,
9611
+ {
9612
+ control: form.control,
9613
+ name: "phone",
9614
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9615
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
9616
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9617
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9618
+ ] })
9619
+ }
9620
+ )
9621
+ ] }) }),
9622
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9623
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9624
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9625
+ ] }) })
9626
+ ]
9627
+ }
9628
+ ) });
9629
+ };
9630
+ const schema = addressSchema;
9631
+ const handle = {
9632
+ permissions: EDIT_DRAFT_ORDER_PERMISSIONS
9633
+ };
9634
9634
  const widgetModule = { widgets: [] };
9635
9635
  const routeModule = {
9636
9636
  routes: [
@@ -9652,54 +9652,54 @@ const routeModule = {
9652
9652
  handle: handle$a,
9653
9653
  loader,
9654
9654
  children: [
9655
- {
9656
- Component: BillingAddress,
9657
- path: "/draft-orders/:id/billing-address",
9658
- handle: handle$9
9659
- },
9660
9655
  {
9661
9656
  Component: CustomItems,
9662
9657
  path: "/draft-orders/:id/custom-items",
9663
- handle: handle$8
9658
+ handle: handle$9
9664
9659
  },
9665
9660
  {
9666
9661
  Component: Email,
9667
9662
  path: "/draft-orders/:id/email",
9668
- handle: handle$7
9663
+ handle: handle$8
9669
9664
  },
9670
9665
  {
9671
9666
  Component: Items,
9672
9667
  path: "/draft-orders/:id/items",
9673
- handle: handle$6
9668
+ handle: handle$7
9674
9669
  },
9675
9670
  {
9676
9671
  Component: Metadata,
9677
9672
  path: "/draft-orders/:id/metadata",
9678
- handle: handle$5
9673
+ handle: handle$6
9679
9674
  },
9680
9675
  {
9681
9676
  Component: Promotions,
9682
9677
  path: "/draft-orders/:id/promotions",
9683
- handle: handle$4
9678
+ handle: handle$5
9684
9679
  },
9685
9680
  {
9686
9681
  Component: SalesChannel,
9687
9682
  path: "/draft-orders/:id/sales-channel",
9688
- handle: handle$3
9683
+ handle: handle$4
9689
9684
  },
9690
9685
  {
9691
9686
  Component: Shipping,
9692
9687
  path: "/draft-orders/:id/shipping",
9693
- handle: handle$2
9688
+ handle: handle$3
9694
9689
  },
9695
9690
  {
9696
9691
  Component: ShippingAddress,
9697
9692
  path: "/draft-orders/:id/shipping-address",
9698
- handle: handle$1
9693
+ handle: handle$2
9699
9694
  },
9700
9695
  {
9701
9696
  Component: TransferOwnership,
9702
9697
  path: "/draft-orders/:id/transfer-ownership",
9698
+ handle: handle$1
9699
+ },
9700
+ {
9701
+ Component: BillingAddress,
9702
+ path: "/draft-orders/:id/billing-address",
9703
9703
  handle
9704
9704
  }
9705
9705
  ]
@@ -6092,198 +6092,6 @@ const ID = () => {
6092
6092
  }
6093
6093
  );
6094
6094
  };
6095
- const BillingAddress = () => {
6096
- const { id } = useParams();
6097
- const { order, isPending, isError, error } = useOrder(id, {
6098
- fields: "+billing_address"
6099
- });
6100
- if (isError) {
6101
- throw error;
6102
- }
6103
- const isReady = !isPending && !!order;
6104
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
6105
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
6106
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
6107
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
6108
- ] }),
6109
- isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
6110
- ] });
6111
- };
6112
- const BillingAddressForm = ({ order }) => {
6113
- const form = useForm({
6114
- defaultValues: {
6115
- first_name: order.billing_address?.first_name ?? "",
6116
- last_name: order.billing_address?.last_name ?? "",
6117
- company: order.billing_address?.company ?? "",
6118
- address_1: order.billing_address?.address_1 ?? "",
6119
- address_2: order.billing_address?.address_2 ?? "",
6120
- city: order.billing_address?.city ?? "",
6121
- province: order.billing_address?.province ?? "",
6122
- country_code: order.billing_address?.country_code ?? "",
6123
- postal_code: order.billing_address?.postal_code ?? "",
6124
- phone: order.billing_address?.phone ?? ""
6125
- },
6126
- resolver: zodResolver(schema$5)
6127
- });
6128
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
6129
- const { handleSuccess } = useRouteModal();
6130
- const onSubmit = form.handleSubmit(async (data) => {
6131
- await mutateAsync(
6132
- { billing_address: data },
6133
- {
6134
- onSuccess: () => {
6135
- handleSuccess();
6136
- },
6137
- onError: (error) => {
6138
- toast.error(error.message);
6139
- }
6140
- }
6141
- );
6142
- });
6143
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
6144
- KeyboundForm,
6145
- {
6146
- className: "flex flex-1 flex-col overflow-hidden",
6147
- onSubmit,
6148
- children: [
6149
- /* @__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: [
6150
- /* @__PURE__ */ jsx(
6151
- Form$2.Field,
6152
- {
6153
- control: form.control,
6154
- name: "country_code",
6155
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
6156
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
6157
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
6158
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
6159
- ] })
6160
- }
6161
- ),
6162
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
6163
- /* @__PURE__ */ jsx(
6164
- Form$2.Field,
6165
- {
6166
- control: form.control,
6167
- name: "first_name",
6168
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
6169
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
6170
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
6171
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
6172
- ] })
6173
- }
6174
- ),
6175
- /* @__PURE__ */ jsx(
6176
- Form$2.Field,
6177
- {
6178
- control: form.control,
6179
- name: "last_name",
6180
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
6181
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
6182
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
6183
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
6184
- ] })
6185
- }
6186
- )
6187
- ] }),
6188
- /* @__PURE__ */ jsx(
6189
- Form$2.Field,
6190
- {
6191
- control: form.control,
6192
- name: "company",
6193
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
6194
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
6195
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
6196
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
6197
- ] })
6198
- }
6199
- ),
6200
- /* @__PURE__ */ jsx(
6201
- Form$2.Field,
6202
- {
6203
- control: form.control,
6204
- name: "address_1",
6205
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
6206
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
6207
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
6208
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
6209
- ] })
6210
- }
6211
- ),
6212
- /* @__PURE__ */ jsx(
6213
- Form$2.Field,
6214
- {
6215
- control: form.control,
6216
- name: "address_2",
6217
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
6218
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
6219
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
6220
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
6221
- ] })
6222
- }
6223
- ),
6224
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
6225
- /* @__PURE__ */ jsx(
6226
- Form$2.Field,
6227
- {
6228
- control: form.control,
6229
- name: "postal_code",
6230
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
6231
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
6232
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
6233
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
6234
- ] })
6235
- }
6236
- ),
6237
- /* @__PURE__ */ jsx(
6238
- Form$2.Field,
6239
- {
6240
- control: form.control,
6241
- name: "city",
6242
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
6243
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
6244
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
6245
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
6246
- ] })
6247
- }
6248
- )
6249
- ] }),
6250
- /* @__PURE__ */ jsx(
6251
- Form$2.Field,
6252
- {
6253
- control: form.control,
6254
- name: "province",
6255
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
6256
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
6257
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
6258
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
6259
- ] })
6260
- }
6261
- ),
6262
- /* @__PURE__ */ jsx(
6263
- Form$2.Field,
6264
- {
6265
- control: form.control,
6266
- name: "phone",
6267
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
6268
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
6269
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
6270
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
6271
- ] })
6272
- }
6273
- )
6274
- ] }) }),
6275
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
6276
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
6277
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
6278
- ] }) })
6279
- ]
6280
- }
6281
- ) });
6282
- };
6283
- const schema$5 = addressSchema;
6284
- const handle$9 = {
6285
- permissions: EDIT_DRAFT_ORDER_PERMISSIONS
6286
- };
6287
6095
  const CustomItems = () => {
6288
6096
  return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
6289
6097
  /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
@@ -6292,7 +6100,7 @@ const CustomItems = () => {
6292
6100
  };
6293
6101
  const CustomItemsForm = () => {
6294
6102
  const form = useForm({
6295
- resolver: zodResolver(schema$4)
6103
+ resolver: zodResolver(schema$5)
6296
6104
  });
6297
6105
  return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
6298
6106
  /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
@@ -6302,10 +6110,10 @@ const CustomItemsForm = () => {
6302
6110
  ] }) })
6303
6111
  ] }) });
6304
6112
  };
6305
- const schema$4 = z.object({
6113
+ const schema$5 = z.object({
6306
6114
  email: z.string().email()
6307
6115
  });
6308
- const handle$8 = {
6116
+ const handle$9 = {
6309
6117
  permissions: EDIT_DRAFT_ORDER_PERMISSIONS
6310
6118
  };
6311
6119
  const Email = () => {
@@ -6330,7 +6138,7 @@ const EmailForm = ({ order }) => {
6330
6138
  defaultValues: {
6331
6139
  email: order.email ?? ""
6332
6140
  },
6333
- resolver: zodResolver(schema$3)
6141
+ resolver: zodResolver(schema$4)
6334
6142
  });
6335
6143
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
6336
6144
  const { handleSuccess } = useRouteModal();
@@ -6373,10 +6181,10 @@ const EmailForm = ({ order }) => {
6373
6181
  }
6374
6182
  ) });
6375
6183
  };
6376
- const schema$3 = z.object({
6184
+ const schema$4 = z.object({
6377
6185
  email: z.string().email()
6378
6186
  });
6379
- const handle$7 = {
6187
+ const handle$8 = {
6380
6188
  permissions: EDIT_DRAFT_ORDER_PERMISSIONS
6381
6189
  };
6382
6190
  const NumberInput = forwardRef(
@@ -7400,7 +7208,7 @@ const customItemSchema = z.object({
7400
7208
  quantity: z.number(),
7401
7209
  unit_price: z.union([z.number(), z.string()])
7402
7210
  });
7403
- const handle$6 = {
7211
+ const handle$7 = {
7404
7212
  permissions: EDIT_DRAFT_ORDER_PERMISSIONS
7405
7213
  };
7406
7214
  const InlineTip = forwardRef(
@@ -7753,7 +7561,7 @@ function getHasUneditableRows(metadata) {
7753
7561
  (value) => !EDITABLE_TYPES.includes(typeof value)
7754
7562
  );
7755
7563
  }
7756
- const handle$5 = {
7564
+ const handle$6 = {
7757
7565
  permissions: EDIT_DRAFT_ORDER_PERMISSIONS
7758
7566
  };
7759
7567
  const PROMOTION_QUERY_KEY = "promotions";
@@ -8031,7 +7839,7 @@ function getPromotionIds(items, shippingMethods) {
8031
7839
  }
8032
7840
  return Array.from(promotionIds);
8033
7841
  }
8034
- const handle$4 = {
7842
+ const handle$5 = {
8035
7843
  permissions: EDIT_DRAFT_ORDER_PROMOTIONS_PERMISSIONS
8036
7844
  };
8037
7845
  const SalesChannel = () => {
@@ -8062,7 +7870,7 @@ const SalesChannelForm = ({ order }) => {
8062
7870
  defaultValues: {
8063
7871
  sales_channel_id: order.sales_channel_id || ""
8064
7872
  },
8065
- resolver: zodResolver(schema$2)
7873
+ resolver: zodResolver(schema$3)
8066
7874
  });
8067
7875
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
8068
7876
  const { handleSuccess } = useRouteModal();
@@ -8137,10 +7945,10 @@ const SalesChannelField = ({ control, order }) => {
8137
7945
  }
8138
7946
  );
8139
7947
  };
8140
- const schema$2 = z.object({
7948
+ const schema$3 = z.object({
8141
7949
  sales_channel_id: z.string().min(1)
8142
7950
  });
8143
- const handle$3 = {
7951
+ const handle$4 = {
8144
7952
  permissions: EDIT_DRAFT_ORDER_SALES_CHANNEL_PERMISSIONS
8145
7953
  };
8146
7954
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
@@ -8937,7 +8745,7 @@ const CustomAmountField = ({
8937
8745
  }
8938
8746
  );
8939
8747
  };
8940
- const handle$2 = {
8748
+ const handle$3 = {
8941
8749
  permissions: EDIT_DRAFT_ORDER_SHIPPING_PERMISSIONS
8942
8750
  };
8943
8751
  const ShippingAddress = () => {
@@ -8971,7 +8779,7 @@ const ShippingAddressForm = ({ order }) => {
8971
8779
  postal_code: order.shipping_address?.postal_code ?? "",
8972
8780
  phone: order.shipping_address?.phone ?? ""
8973
8781
  },
8974
- resolver: zodResolver(schema$1)
8782
+ resolver: zodResolver(schema$2)
8975
8783
  });
8976
8784
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
8977
8785
  const { handleSuccess } = useRouteModal();
@@ -9141,8 +8949,8 @@ const ShippingAddressForm = ({ order }) => {
9141
8949
  }
9142
8950
  ) });
9143
8951
  };
9144
- const schema$1 = addressSchema;
9145
- const handle$1 = {
8952
+ const schema$2 = addressSchema;
8953
+ const handle$2 = {
9146
8954
  permissions: EDIT_DRAFT_ORDER_PERMISSIONS
9147
8955
  };
9148
8956
  const TransferOwnership = () => {
@@ -9167,7 +8975,7 @@ const TransferOwnershipForm = ({ order }) => {
9167
8975
  defaultValues: {
9168
8976
  customer_id: order.customer_id || ""
9169
8977
  },
9170
- resolver: zodResolver(schema)
8978
+ resolver: zodResolver(schema$1)
9171
8979
  });
9172
8980
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9173
8981
  const { handleSuccess } = useRouteModal();
@@ -9619,12 +9427,204 @@ const Illustration = () => {
9619
9427
  }
9620
9428
  );
9621
9429
  };
9622
- const schema = z.object({
9430
+ const schema$1 = z.object({
9623
9431
  customer_id: z.string().min(1)
9624
9432
  });
9625
- const handle = {
9433
+ const handle$1 = {
9626
9434
  permissions: TRANSFER_DRAFT_ORDER_PERMISSIONS
9627
9435
  };
9436
+ const BillingAddress = () => {
9437
+ const { id } = useParams();
9438
+ const { order, isPending, isError, error } = useOrder(id, {
9439
+ fields: "+billing_address"
9440
+ });
9441
+ if (isError) {
9442
+ throw error;
9443
+ }
9444
+ const isReady = !isPending && !!order;
9445
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9446
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
9447
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
9448
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9449
+ ] }),
9450
+ isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
9451
+ ] });
9452
+ };
9453
+ const BillingAddressForm = ({ order }) => {
9454
+ const form = useForm({
9455
+ defaultValues: {
9456
+ first_name: order.billing_address?.first_name ?? "",
9457
+ last_name: order.billing_address?.last_name ?? "",
9458
+ company: order.billing_address?.company ?? "",
9459
+ address_1: order.billing_address?.address_1 ?? "",
9460
+ address_2: order.billing_address?.address_2 ?? "",
9461
+ city: order.billing_address?.city ?? "",
9462
+ province: order.billing_address?.province ?? "",
9463
+ country_code: order.billing_address?.country_code ?? "",
9464
+ postal_code: order.billing_address?.postal_code ?? "",
9465
+ phone: order.billing_address?.phone ?? ""
9466
+ },
9467
+ resolver: zodResolver(schema)
9468
+ });
9469
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9470
+ const { handleSuccess } = useRouteModal();
9471
+ const onSubmit = form.handleSubmit(async (data) => {
9472
+ await mutateAsync(
9473
+ { billing_address: data },
9474
+ {
9475
+ onSuccess: () => {
9476
+ handleSuccess();
9477
+ },
9478
+ onError: (error) => {
9479
+ toast.error(error.message);
9480
+ }
9481
+ }
9482
+ );
9483
+ });
9484
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
9485
+ KeyboundForm,
9486
+ {
9487
+ className: "flex flex-1 flex-col overflow-hidden",
9488
+ onSubmit,
9489
+ children: [
9490
+ /* @__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: [
9491
+ /* @__PURE__ */ jsx(
9492
+ Form$2.Field,
9493
+ {
9494
+ control: form.control,
9495
+ name: "country_code",
9496
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9497
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
9498
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
9499
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9500
+ ] })
9501
+ }
9502
+ ),
9503
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9504
+ /* @__PURE__ */ jsx(
9505
+ Form$2.Field,
9506
+ {
9507
+ control: form.control,
9508
+ name: "first_name",
9509
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9510
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
9511
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9512
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9513
+ ] })
9514
+ }
9515
+ ),
9516
+ /* @__PURE__ */ jsx(
9517
+ Form$2.Field,
9518
+ {
9519
+ control: form.control,
9520
+ name: "last_name",
9521
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9522
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
9523
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9524
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9525
+ ] })
9526
+ }
9527
+ )
9528
+ ] }),
9529
+ /* @__PURE__ */ jsx(
9530
+ Form$2.Field,
9531
+ {
9532
+ control: form.control,
9533
+ name: "company",
9534
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9535
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
9536
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9537
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9538
+ ] })
9539
+ }
9540
+ ),
9541
+ /* @__PURE__ */ jsx(
9542
+ Form$2.Field,
9543
+ {
9544
+ control: form.control,
9545
+ name: "address_1",
9546
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9547
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
9548
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9549
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9550
+ ] })
9551
+ }
9552
+ ),
9553
+ /* @__PURE__ */ jsx(
9554
+ Form$2.Field,
9555
+ {
9556
+ control: form.control,
9557
+ name: "address_2",
9558
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9559
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9560
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9561
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9562
+ ] })
9563
+ }
9564
+ ),
9565
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9566
+ /* @__PURE__ */ jsx(
9567
+ Form$2.Field,
9568
+ {
9569
+ control: form.control,
9570
+ name: "postal_code",
9571
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9572
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
9573
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9574
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9575
+ ] })
9576
+ }
9577
+ ),
9578
+ /* @__PURE__ */ jsx(
9579
+ Form$2.Field,
9580
+ {
9581
+ control: form.control,
9582
+ name: "city",
9583
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9584
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
9585
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9586
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9587
+ ] })
9588
+ }
9589
+ )
9590
+ ] }),
9591
+ /* @__PURE__ */ jsx(
9592
+ Form$2.Field,
9593
+ {
9594
+ control: form.control,
9595
+ name: "province",
9596
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9597
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9598
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9599
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9600
+ ] })
9601
+ }
9602
+ ),
9603
+ /* @__PURE__ */ jsx(
9604
+ Form$2.Field,
9605
+ {
9606
+ control: form.control,
9607
+ name: "phone",
9608
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9609
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
9610
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9611
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9612
+ ] })
9613
+ }
9614
+ )
9615
+ ] }) }),
9616
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9617
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9618
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9619
+ ] }) })
9620
+ ]
9621
+ }
9622
+ ) });
9623
+ };
9624
+ const schema = addressSchema;
9625
+ const handle = {
9626
+ permissions: EDIT_DRAFT_ORDER_PERMISSIONS
9627
+ };
9628
9628
  const widgetModule = { widgets: [] };
9629
9629
  const routeModule = {
9630
9630
  routes: [
@@ -9646,54 +9646,54 @@ const routeModule = {
9646
9646
  handle: handle$a,
9647
9647
  loader,
9648
9648
  children: [
9649
- {
9650
- Component: BillingAddress,
9651
- path: "/draft-orders/:id/billing-address",
9652
- handle: handle$9
9653
- },
9654
9649
  {
9655
9650
  Component: CustomItems,
9656
9651
  path: "/draft-orders/:id/custom-items",
9657
- handle: handle$8
9652
+ handle: handle$9
9658
9653
  },
9659
9654
  {
9660
9655
  Component: Email,
9661
9656
  path: "/draft-orders/:id/email",
9662
- handle: handle$7
9657
+ handle: handle$8
9663
9658
  },
9664
9659
  {
9665
9660
  Component: Items,
9666
9661
  path: "/draft-orders/:id/items",
9667
- handle: handle$6
9662
+ handle: handle$7
9668
9663
  },
9669
9664
  {
9670
9665
  Component: Metadata,
9671
9666
  path: "/draft-orders/:id/metadata",
9672
- handle: handle$5
9667
+ handle: handle$6
9673
9668
  },
9674
9669
  {
9675
9670
  Component: Promotions,
9676
9671
  path: "/draft-orders/:id/promotions",
9677
- handle: handle$4
9672
+ handle: handle$5
9678
9673
  },
9679
9674
  {
9680
9675
  Component: SalesChannel,
9681
9676
  path: "/draft-orders/:id/sales-channel",
9682
- handle: handle$3
9677
+ handle: handle$4
9683
9678
  },
9684
9679
  {
9685
9680
  Component: Shipping,
9686
9681
  path: "/draft-orders/:id/shipping",
9687
- handle: handle$2
9682
+ handle: handle$3
9688
9683
  },
9689
9684
  {
9690
9685
  Component: ShippingAddress,
9691
9686
  path: "/draft-orders/:id/shipping-address",
9692
- handle: handle$1
9687
+ handle: handle$2
9693
9688
  },
9694
9689
  {
9695
9690
  Component: TransferOwnership,
9696
9691
  path: "/draft-orders/:id/transfer-ownership",
9692
+ handle: handle$1
9693
+ },
9694
+ {
9695
+ Component: BillingAddress,
9696
+ path: "/draft-orders/:id/billing-address",
9697
9697
  handle
9698
9698
  }
9699
9699
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/draft-order",
3
- "version": "2.22.6",
3
+ "version": "2.22.7-snapshot-20261111153147",
4
4
  "description": "A draft order plugin for Medusa.",
5
5
  "author": "Medusa (https://medusajs.com)",
6
6
  "license": "MIT",
@@ -50,7 +50,7 @@
50
50
  "@ariakit/react": "^0.4.15",
51
51
  "@babel/runtime": "^8.0.10",
52
52
  "@hookform/resolvers": "6.0.0",
53
- "@medusajs/js-sdk": "2.22.6",
53
+ "@medusajs/js-sdk": "2.22.7-snapshot-20261111153147",
54
54
  "@tanstack/react-query": "5.64.2",
55
55
  "@uiw/react-json-view": "^2.0.0-alpha.17",
56
56
  "date-fns": "^4.4.0",
@@ -62,25 +62,25 @@
62
62
  "zod": "4.6.6"
63
63
  },
64
64
  "devDependencies": {
65
- "@medusajs/admin-sdk": "2.22.6",
66
- "@medusajs/cli": "2.22.6",
67
- "@medusajs/dashboard": "2.22.6",
68
- "@medusajs/framework": "2.22.6",
69
- "@medusajs/icons": "2.22.6",
70
- "@medusajs/test-utils": "2.22.6",
71
- "@medusajs/types": "2.22.6",
72
- "@medusajs/ui": "4.2.13",
73
- "@medusajs/ui-preset": "2.22.6",
65
+ "@medusajs/admin-sdk": "2.22.7-snapshot-20261111153147",
66
+ "@medusajs/cli": "2.22.7-snapshot-20261111153147",
67
+ "@medusajs/dashboard": "2.22.7-snapshot-20261111153147",
68
+ "@medusajs/framework": "2.22.7-snapshot-20261111153147",
69
+ "@medusajs/icons": "2.22.7-snapshot-20261111153147",
70
+ "@medusajs/test-utils": "2.22.7-snapshot-20261111153147",
71
+ "@medusajs/types": "2.22.7-snapshot-20261111153147",
72
+ "@medusajs/ui": "4.2.14-snapshot-20261111153147",
73
+ "@medusajs/ui-preset": "2.22.7-snapshot-20261111153147",
74
74
  "cross-env": "^10.1.0"
75
75
  },
76
76
  "peerDependencies": {
77
- "@medusajs/admin-sdk": "2.22.6",
78
- "@medusajs/cli": "2.22.6",
79
- "@medusajs/dashboard": "2.22.6",
80
- "@medusajs/framework": "2.22.6",
81
- "@medusajs/icons": "2.22.6",
82
- "@medusajs/test-utils": "2.22.6",
83
- "@medusajs/ui": "4.2.13",
77
+ "@medusajs/admin-sdk": "2.22.7-snapshot-20261111153147",
78
+ "@medusajs/cli": "2.22.7-snapshot-20261111153147",
79
+ "@medusajs/dashboard": "2.22.7-snapshot-20261111153147",
80
+ "@medusajs/framework": "2.22.7-snapshot-20261111153147",
81
+ "@medusajs/icons": "2.22.7-snapshot-20261111153147",
82
+ "@medusajs/test-utils": "2.22.7-snapshot-20261111153147",
83
+ "@medusajs/ui": "4.2.14-snapshot-20261111153147",
84
84
  "react": "^18.3.1",
85
85
  "react-dom": "^18.3.1",
86
86
  "react-router-dom": "^6.30.4 || ^7.0.0"