@medusajs/draft-order 2.11.0-preview-20251019032246 → 2.11.0-preview-20251019060156
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.
- package/.medusa/server/src/admin/index.js +209 -209
- package/.medusa/server/src/admin/index.mjs +209 -209
- package/package.json +16 -16
|
@@ -12176,209 +12176,6 @@ const CustomAmountField = ({
|
|
|
12176
12176
|
}
|
|
12177
12177
|
);
|
|
12178
12178
|
};
|
|
12179
|
-
const ShippingAddress = () => {
|
|
12180
|
-
const { id } = reactRouterDom.useParams();
|
|
12181
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
12182
|
-
fields: "+shipping_address"
|
|
12183
|
-
});
|
|
12184
|
-
if (isError) {
|
|
12185
|
-
throw error;
|
|
12186
|
-
}
|
|
12187
|
-
const isReady = !isPending && !!order;
|
|
12188
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12189
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12190
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
|
|
12191
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
12192
|
-
] }),
|
|
12193
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
|
|
12194
|
-
] });
|
|
12195
|
-
};
|
|
12196
|
-
const ShippingAddressForm = ({ order }) => {
|
|
12197
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12198
|
-
const form = reactHookForm.useForm({
|
|
12199
|
-
defaultValues: {
|
|
12200
|
-
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12201
|
-
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12202
|
-
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12203
|
-
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12204
|
-
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12205
|
-
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12206
|
-
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12207
|
-
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12208
|
-
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12209
|
-
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12210
|
-
},
|
|
12211
|
-
resolver: zod.zodResolver(schema$2)
|
|
12212
|
-
});
|
|
12213
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12214
|
-
const { handleSuccess } = useRouteModal();
|
|
12215
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12216
|
-
await mutateAsync(
|
|
12217
|
-
{
|
|
12218
|
-
shipping_address: {
|
|
12219
|
-
first_name: data.first_name,
|
|
12220
|
-
last_name: data.last_name,
|
|
12221
|
-
company: data.company,
|
|
12222
|
-
address_1: data.address_1,
|
|
12223
|
-
address_2: data.address_2,
|
|
12224
|
-
city: data.city,
|
|
12225
|
-
province: data.province,
|
|
12226
|
-
country_code: data.country_code,
|
|
12227
|
-
postal_code: data.postal_code,
|
|
12228
|
-
phone: data.phone
|
|
12229
|
-
}
|
|
12230
|
-
},
|
|
12231
|
-
{
|
|
12232
|
-
onSuccess: () => {
|
|
12233
|
-
handleSuccess();
|
|
12234
|
-
},
|
|
12235
|
-
onError: (error) => {
|
|
12236
|
-
ui.toast.error(error.message);
|
|
12237
|
-
}
|
|
12238
|
-
}
|
|
12239
|
-
);
|
|
12240
|
-
});
|
|
12241
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12242
|
-
KeyboundForm,
|
|
12243
|
-
{
|
|
12244
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12245
|
-
onSubmit,
|
|
12246
|
-
children: [
|
|
12247
|
-
/* @__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: [
|
|
12248
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12249
|
-
Form$2.Field,
|
|
12250
|
-
{
|
|
12251
|
-
control: form.control,
|
|
12252
|
-
name: "country_code",
|
|
12253
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12254
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
|
|
12255
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
12256
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12257
|
-
] })
|
|
12258
|
-
}
|
|
12259
|
-
),
|
|
12260
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12261
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12262
|
-
Form$2.Field,
|
|
12263
|
-
{
|
|
12264
|
-
control: form.control,
|
|
12265
|
-
name: "first_name",
|
|
12266
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12267
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
12268
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12269
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12270
|
-
] })
|
|
12271
|
-
}
|
|
12272
|
-
),
|
|
12273
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12274
|
-
Form$2.Field,
|
|
12275
|
-
{
|
|
12276
|
-
control: form.control,
|
|
12277
|
-
name: "last_name",
|
|
12278
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12279
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
12280
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12281
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12282
|
-
] })
|
|
12283
|
-
}
|
|
12284
|
-
)
|
|
12285
|
-
] }),
|
|
12286
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12287
|
-
Form$2.Field,
|
|
12288
|
-
{
|
|
12289
|
-
control: form.control,
|
|
12290
|
-
name: "company",
|
|
12291
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12292
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12293
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12294
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12295
|
-
] })
|
|
12296
|
-
}
|
|
12297
|
-
),
|
|
12298
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12299
|
-
Form$2.Field,
|
|
12300
|
-
{
|
|
12301
|
-
control: form.control,
|
|
12302
|
-
name: "address_1",
|
|
12303
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12304
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
12305
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12306
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12307
|
-
] })
|
|
12308
|
-
}
|
|
12309
|
-
),
|
|
12310
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12311
|
-
Form$2.Field,
|
|
12312
|
-
{
|
|
12313
|
-
control: form.control,
|
|
12314
|
-
name: "address_2",
|
|
12315
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12316
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12317
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12318
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12319
|
-
] })
|
|
12320
|
-
}
|
|
12321
|
-
),
|
|
12322
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12323
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12324
|
-
Form$2.Field,
|
|
12325
|
-
{
|
|
12326
|
-
control: form.control,
|
|
12327
|
-
name: "postal_code",
|
|
12328
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12329
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
12330
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12331
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12332
|
-
] })
|
|
12333
|
-
}
|
|
12334
|
-
),
|
|
12335
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12336
|
-
Form$2.Field,
|
|
12337
|
-
{
|
|
12338
|
-
control: form.control,
|
|
12339
|
-
name: "city",
|
|
12340
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12341
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
12342
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12343
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12344
|
-
] })
|
|
12345
|
-
}
|
|
12346
|
-
)
|
|
12347
|
-
] }),
|
|
12348
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12349
|
-
Form$2.Field,
|
|
12350
|
-
{
|
|
12351
|
-
control: form.control,
|
|
12352
|
-
name: "province",
|
|
12353
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12354
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
12355
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12356
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12357
|
-
] })
|
|
12358
|
-
}
|
|
12359
|
-
),
|
|
12360
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12361
|
-
Form$2.Field,
|
|
12362
|
-
{
|
|
12363
|
-
control: form.control,
|
|
12364
|
-
name: "phone",
|
|
12365
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12366
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
12367
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12368
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12369
|
-
] })
|
|
12370
|
-
}
|
|
12371
|
-
)
|
|
12372
|
-
] }) }),
|
|
12373
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12374
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12375
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12376
|
-
] }) })
|
|
12377
|
-
]
|
|
12378
|
-
}
|
|
12379
|
-
) });
|
|
12380
|
-
};
|
|
12381
|
-
const schema$2 = addressSchema;
|
|
12382
12179
|
const TransferOwnership = () => {
|
|
12383
12180
|
const { id } = reactRouterDom.useParams();
|
|
12384
12181
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -12402,7 +12199,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12402
12199
|
defaultValues: {
|
|
12403
12200
|
customer_id: order.customer_id || ""
|
|
12404
12201
|
},
|
|
12405
|
-
resolver: zod.zodResolver(schema$
|
|
12202
|
+
resolver: zod.zodResolver(schema$2)
|
|
12406
12203
|
});
|
|
12407
12204
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12408
12205
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12852,9 +12649,212 @@ const Illustration = () => {
|
|
|
12852
12649
|
}
|
|
12853
12650
|
);
|
|
12854
12651
|
};
|
|
12855
|
-
const schema$
|
|
12652
|
+
const schema$2 = objectType({
|
|
12856
12653
|
customer_id: stringType().min(1)
|
|
12857
12654
|
});
|
|
12655
|
+
const ShippingAddress = () => {
|
|
12656
|
+
const { id } = reactRouterDom.useParams();
|
|
12657
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
12658
|
+
fields: "+shipping_address"
|
|
12659
|
+
});
|
|
12660
|
+
if (isError) {
|
|
12661
|
+
throw error;
|
|
12662
|
+
}
|
|
12663
|
+
const isReady = !isPending && !!order;
|
|
12664
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12665
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12666
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
|
|
12667
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
12668
|
+
] }),
|
|
12669
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
|
|
12670
|
+
] });
|
|
12671
|
+
};
|
|
12672
|
+
const ShippingAddressForm = ({ order }) => {
|
|
12673
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12674
|
+
const form = reactHookForm.useForm({
|
|
12675
|
+
defaultValues: {
|
|
12676
|
+
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12677
|
+
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12678
|
+
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12679
|
+
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12680
|
+
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12681
|
+
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12682
|
+
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12683
|
+
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12684
|
+
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12685
|
+
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12686
|
+
},
|
|
12687
|
+
resolver: zod.zodResolver(schema$1)
|
|
12688
|
+
});
|
|
12689
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12690
|
+
const { handleSuccess } = useRouteModal();
|
|
12691
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12692
|
+
await mutateAsync(
|
|
12693
|
+
{
|
|
12694
|
+
shipping_address: {
|
|
12695
|
+
first_name: data.first_name,
|
|
12696
|
+
last_name: data.last_name,
|
|
12697
|
+
company: data.company,
|
|
12698
|
+
address_1: data.address_1,
|
|
12699
|
+
address_2: data.address_2,
|
|
12700
|
+
city: data.city,
|
|
12701
|
+
province: data.province,
|
|
12702
|
+
country_code: data.country_code,
|
|
12703
|
+
postal_code: data.postal_code,
|
|
12704
|
+
phone: data.phone
|
|
12705
|
+
}
|
|
12706
|
+
},
|
|
12707
|
+
{
|
|
12708
|
+
onSuccess: () => {
|
|
12709
|
+
handleSuccess();
|
|
12710
|
+
},
|
|
12711
|
+
onError: (error) => {
|
|
12712
|
+
ui.toast.error(error.message);
|
|
12713
|
+
}
|
|
12714
|
+
}
|
|
12715
|
+
);
|
|
12716
|
+
});
|
|
12717
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12718
|
+
KeyboundForm,
|
|
12719
|
+
{
|
|
12720
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12721
|
+
onSubmit,
|
|
12722
|
+
children: [
|
|
12723
|
+
/* @__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: [
|
|
12724
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12725
|
+
Form$2.Field,
|
|
12726
|
+
{
|
|
12727
|
+
control: form.control,
|
|
12728
|
+
name: "country_code",
|
|
12729
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12730
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
|
|
12731
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
12732
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12733
|
+
] })
|
|
12734
|
+
}
|
|
12735
|
+
),
|
|
12736
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12737
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12738
|
+
Form$2.Field,
|
|
12739
|
+
{
|
|
12740
|
+
control: form.control,
|
|
12741
|
+
name: "first_name",
|
|
12742
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12743
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
12744
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12745
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12746
|
+
] })
|
|
12747
|
+
}
|
|
12748
|
+
),
|
|
12749
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12750
|
+
Form$2.Field,
|
|
12751
|
+
{
|
|
12752
|
+
control: form.control,
|
|
12753
|
+
name: "last_name",
|
|
12754
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12755
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
12756
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12757
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12758
|
+
] })
|
|
12759
|
+
}
|
|
12760
|
+
)
|
|
12761
|
+
] }),
|
|
12762
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12763
|
+
Form$2.Field,
|
|
12764
|
+
{
|
|
12765
|
+
control: form.control,
|
|
12766
|
+
name: "company",
|
|
12767
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12768
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12769
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12770
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12771
|
+
] })
|
|
12772
|
+
}
|
|
12773
|
+
),
|
|
12774
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12775
|
+
Form$2.Field,
|
|
12776
|
+
{
|
|
12777
|
+
control: form.control,
|
|
12778
|
+
name: "address_1",
|
|
12779
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12780
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
12781
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12782
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12783
|
+
] })
|
|
12784
|
+
}
|
|
12785
|
+
),
|
|
12786
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12787
|
+
Form$2.Field,
|
|
12788
|
+
{
|
|
12789
|
+
control: form.control,
|
|
12790
|
+
name: "address_2",
|
|
12791
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12792
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12793
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12794
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12795
|
+
] })
|
|
12796
|
+
}
|
|
12797
|
+
),
|
|
12798
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12799
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12800
|
+
Form$2.Field,
|
|
12801
|
+
{
|
|
12802
|
+
control: form.control,
|
|
12803
|
+
name: "postal_code",
|
|
12804
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12805
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
12806
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12807
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12808
|
+
] })
|
|
12809
|
+
}
|
|
12810
|
+
),
|
|
12811
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12812
|
+
Form$2.Field,
|
|
12813
|
+
{
|
|
12814
|
+
control: form.control,
|
|
12815
|
+
name: "city",
|
|
12816
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12817
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
12818
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12819
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12820
|
+
] })
|
|
12821
|
+
}
|
|
12822
|
+
)
|
|
12823
|
+
] }),
|
|
12824
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12825
|
+
Form$2.Field,
|
|
12826
|
+
{
|
|
12827
|
+
control: form.control,
|
|
12828
|
+
name: "province",
|
|
12829
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12830
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
12831
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12832
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12833
|
+
] })
|
|
12834
|
+
}
|
|
12835
|
+
),
|
|
12836
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12837
|
+
Form$2.Field,
|
|
12838
|
+
{
|
|
12839
|
+
control: form.control,
|
|
12840
|
+
name: "phone",
|
|
12841
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12842
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
12843
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
12844
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12845
|
+
] })
|
|
12846
|
+
}
|
|
12847
|
+
)
|
|
12848
|
+
] }) }),
|
|
12849
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12850
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12851
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12852
|
+
] }) })
|
|
12853
|
+
]
|
|
12854
|
+
}
|
|
12855
|
+
) });
|
|
12856
|
+
};
|
|
12857
|
+
const schema$1 = addressSchema;
|
|
12858
12858
|
const BillingAddress = () => {
|
|
12859
12859
|
const { id } = reactRouterDom.useParams();
|
|
12860
12860
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -13093,14 +13093,14 @@ const routeModule = {
|
|
|
13093
13093
|
Component: Shipping,
|
|
13094
13094
|
path: "/draft-orders/:id/shipping"
|
|
13095
13095
|
},
|
|
13096
|
-
{
|
|
13097
|
-
Component: ShippingAddress,
|
|
13098
|
-
path: "/draft-orders/:id/shipping-address"
|
|
13099
|
-
},
|
|
13100
13096
|
{
|
|
13101
13097
|
Component: TransferOwnership,
|
|
13102
13098
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13103
13099
|
},
|
|
13100
|
+
{
|
|
13101
|
+
Component: ShippingAddress,
|
|
13102
|
+
path: "/draft-orders/:id/shipping-address"
|
|
13103
|
+
},
|
|
13104
13104
|
{
|
|
13105
13105
|
Component: BillingAddress,
|
|
13106
13106
|
path: "/draft-orders/:id/billing-address"
|
|
@@ -12170,209 +12170,6 @@ const CustomAmountField = ({
|
|
|
12170
12170
|
}
|
|
12171
12171
|
);
|
|
12172
12172
|
};
|
|
12173
|
-
const ShippingAddress = () => {
|
|
12174
|
-
const { id } = useParams();
|
|
12175
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
12176
|
-
fields: "+shipping_address"
|
|
12177
|
-
});
|
|
12178
|
-
if (isError) {
|
|
12179
|
-
throw error;
|
|
12180
|
-
}
|
|
12181
|
-
const isReady = !isPending && !!order;
|
|
12182
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12183
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12184
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
|
|
12185
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
12186
|
-
] }),
|
|
12187
|
-
isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
|
|
12188
|
-
] });
|
|
12189
|
-
};
|
|
12190
|
-
const ShippingAddressForm = ({ order }) => {
|
|
12191
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12192
|
-
const form = useForm({
|
|
12193
|
-
defaultValues: {
|
|
12194
|
-
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12195
|
-
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12196
|
-
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12197
|
-
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12198
|
-
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12199
|
-
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12200
|
-
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12201
|
-
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12202
|
-
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12203
|
-
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12204
|
-
},
|
|
12205
|
-
resolver: zodResolver(schema$2)
|
|
12206
|
-
});
|
|
12207
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12208
|
-
const { handleSuccess } = useRouteModal();
|
|
12209
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12210
|
-
await mutateAsync(
|
|
12211
|
-
{
|
|
12212
|
-
shipping_address: {
|
|
12213
|
-
first_name: data.first_name,
|
|
12214
|
-
last_name: data.last_name,
|
|
12215
|
-
company: data.company,
|
|
12216
|
-
address_1: data.address_1,
|
|
12217
|
-
address_2: data.address_2,
|
|
12218
|
-
city: data.city,
|
|
12219
|
-
province: data.province,
|
|
12220
|
-
country_code: data.country_code,
|
|
12221
|
-
postal_code: data.postal_code,
|
|
12222
|
-
phone: data.phone
|
|
12223
|
-
}
|
|
12224
|
-
},
|
|
12225
|
-
{
|
|
12226
|
-
onSuccess: () => {
|
|
12227
|
-
handleSuccess();
|
|
12228
|
-
},
|
|
12229
|
-
onError: (error) => {
|
|
12230
|
-
toast.error(error.message);
|
|
12231
|
-
}
|
|
12232
|
-
}
|
|
12233
|
-
);
|
|
12234
|
-
});
|
|
12235
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12236
|
-
KeyboundForm,
|
|
12237
|
-
{
|
|
12238
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12239
|
-
onSubmit,
|
|
12240
|
-
children: [
|
|
12241
|
-
/* @__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: [
|
|
12242
|
-
/* @__PURE__ */ jsx(
|
|
12243
|
-
Form$2.Field,
|
|
12244
|
-
{
|
|
12245
|
-
control: form.control,
|
|
12246
|
-
name: "country_code",
|
|
12247
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12248
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
12249
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
12250
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12251
|
-
] })
|
|
12252
|
-
}
|
|
12253
|
-
),
|
|
12254
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12255
|
-
/* @__PURE__ */ jsx(
|
|
12256
|
-
Form$2.Field,
|
|
12257
|
-
{
|
|
12258
|
-
control: form.control,
|
|
12259
|
-
name: "first_name",
|
|
12260
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12261
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
12262
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12263
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12264
|
-
] })
|
|
12265
|
-
}
|
|
12266
|
-
),
|
|
12267
|
-
/* @__PURE__ */ jsx(
|
|
12268
|
-
Form$2.Field,
|
|
12269
|
-
{
|
|
12270
|
-
control: form.control,
|
|
12271
|
-
name: "last_name",
|
|
12272
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12273
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
12274
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12275
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12276
|
-
] })
|
|
12277
|
-
}
|
|
12278
|
-
)
|
|
12279
|
-
] }),
|
|
12280
|
-
/* @__PURE__ */ jsx(
|
|
12281
|
-
Form$2.Field,
|
|
12282
|
-
{
|
|
12283
|
-
control: form.control,
|
|
12284
|
-
name: "company",
|
|
12285
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12286
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12287
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12288
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12289
|
-
] })
|
|
12290
|
-
}
|
|
12291
|
-
),
|
|
12292
|
-
/* @__PURE__ */ jsx(
|
|
12293
|
-
Form$2.Field,
|
|
12294
|
-
{
|
|
12295
|
-
control: form.control,
|
|
12296
|
-
name: "address_1",
|
|
12297
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12298
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
12299
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12300
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12301
|
-
] })
|
|
12302
|
-
}
|
|
12303
|
-
),
|
|
12304
|
-
/* @__PURE__ */ jsx(
|
|
12305
|
-
Form$2.Field,
|
|
12306
|
-
{
|
|
12307
|
-
control: form.control,
|
|
12308
|
-
name: "address_2",
|
|
12309
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12310
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12311
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12312
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12313
|
-
] })
|
|
12314
|
-
}
|
|
12315
|
-
),
|
|
12316
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12317
|
-
/* @__PURE__ */ jsx(
|
|
12318
|
-
Form$2.Field,
|
|
12319
|
-
{
|
|
12320
|
-
control: form.control,
|
|
12321
|
-
name: "postal_code",
|
|
12322
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12323
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
12324
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12325
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12326
|
-
] })
|
|
12327
|
-
}
|
|
12328
|
-
),
|
|
12329
|
-
/* @__PURE__ */ jsx(
|
|
12330
|
-
Form$2.Field,
|
|
12331
|
-
{
|
|
12332
|
-
control: form.control,
|
|
12333
|
-
name: "city",
|
|
12334
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12335
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
12336
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12337
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12338
|
-
] })
|
|
12339
|
-
}
|
|
12340
|
-
)
|
|
12341
|
-
] }),
|
|
12342
|
-
/* @__PURE__ */ jsx(
|
|
12343
|
-
Form$2.Field,
|
|
12344
|
-
{
|
|
12345
|
-
control: form.control,
|
|
12346
|
-
name: "province",
|
|
12347
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12348
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
12349
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12350
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12351
|
-
] })
|
|
12352
|
-
}
|
|
12353
|
-
),
|
|
12354
|
-
/* @__PURE__ */ jsx(
|
|
12355
|
-
Form$2.Field,
|
|
12356
|
-
{
|
|
12357
|
-
control: form.control,
|
|
12358
|
-
name: "phone",
|
|
12359
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12360
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
12361
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12362
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12363
|
-
] })
|
|
12364
|
-
}
|
|
12365
|
-
)
|
|
12366
|
-
] }) }),
|
|
12367
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12368
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12369
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12370
|
-
] }) })
|
|
12371
|
-
]
|
|
12372
|
-
}
|
|
12373
|
-
) });
|
|
12374
|
-
};
|
|
12375
|
-
const schema$2 = addressSchema;
|
|
12376
12173
|
const TransferOwnership = () => {
|
|
12377
12174
|
const { id } = useParams();
|
|
12378
12175
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -12396,7 +12193,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12396
12193
|
defaultValues: {
|
|
12397
12194
|
customer_id: order.customer_id || ""
|
|
12398
12195
|
},
|
|
12399
|
-
resolver: zodResolver(schema$
|
|
12196
|
+
resolver: zodResolver(schema$2)
|
|
12400
12197
|
});
|
|
12401
12198
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12402
12199
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12846,9 +12643,212 @@ const Illustration = () => {
|
|
|
12846
12643
|
}
|
|
12847
12644
|
);
|
|
12848
12645
|
};
|
|
12849
|
-
const schema$
|
|
12646
|
+
const schema$2 = objectType({
|
|
12850
12647
|
customer_id: stringType().min(1)
|
|
12851
12648
|
});
|
|
12649
|
+
const ShippingAddress = () => {
|
|
12650
|
+
const { id } = useParams();
|
|
12651
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
12652
|
+
fields: "+shipping_address"
|
|
12653
|
+
});
|
|
12654
|
+
if (isError) {
|
|
12655
|
+
throw error;
|
|
12656
|
+
}
|
|
12657
|
+
const isReady = !isPending && !!order;
|
|
12658
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12659
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12660
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
|
|
12661
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
12662
|
+
] }),
|
|
12663
|
+
isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
|
|
12664
|
+
] });
|
|
12665
|
+
};
|
|
12666
|
+
const ShippingAddressForm = ({ order }) => {
|
|
12667
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12668
|
+
const form = useForm({
|
|
12669
|
+
defaultValues: {
|
|
12670
|
+
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12671
|
+
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12672
|
+
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12673
|
+
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12674
|
+
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12675
|
+
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12676
|
+
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12677
|
+
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12678
|
+
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12679
|
+
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12680
|
+
},
|
|
12681
|
+
resolver: zodResolver(schema$1)
|
|
12682
|
+
});
|
|
12683
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12684
|
+
const { handleSuccess } = useRouteModal();
|
|
12685
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12686
|
+
await mutateAsync(
|
|
12687
|
+
{
|
|
12688
|
+
shipping_address: {
|
|
12689
|
+
first_name: data.first_name,
|
|
12690
|
+
last_name: data.last_name,
|
|
12691
|
+
company: data.company,
|
|
12692
|
+
address_1: data.address_1,
|
|
12693
|
+
address_2: data.address_2,
|
|
12694
|
+
city: data.city,
|
|
12695
|
+
province: data.province,
|
|
12696
|
+
country_code: data.country_code,
|
|
12697
|
+
postal_code: data.postal_code,
|
|
12698
|
+
phone: data.phone
|
|
12699
|
+
}
|
|
12700
|
+
},
|
|
12701
|
+
{
|
|
12702
|
+
onSuccess: () => {
|
|
12703
|
+
handleSuccess();
|
|
12704
|
+
},
|
|
12705
|
+
onError: (error) => {
|
|
12706
|
+
toast.error(error.message);
|
|
12707
|
+
}
|
|
12708
|
+
}
|
|
12709
|
+
);
|
|
12710
|
+
});
|
|
12711
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12712
|
+
KeyboundForm,
|
|
12713
|
+
{
|
|
12714
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12715
|
+
onSubmit,
|
|
12716
|
+
children: [
|
|
12717
|
+
/* @__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: [
|
|
12718
|
+
/* @__PURE__ */ jsx(
|
|
12719
|
+
Form$2.Field,
|
|
12720
|
+
{
|
|
12721
|
+
control: form.control,
|
|
12722
|
+
name: "country_code",
|
|
12723
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12724
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
12725
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
12726
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12727
|
+
] })
|
|
12728
|
+
}
|
|
12729
|
+
),
|
|
12730
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12731
|
+
/* @__PURE__ */ jsx(
|
|
12732
|
+
Form$2.Field,
|
|
12733
|
+
{
|
|
12734
|
+
control: form.control,
|
|
12735
|
+
name: "first_name",
|
|
12736
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12737
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
12738
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12739
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12740
|
+
] })
|
|
12741
|
+
}
|
|
12742
|
+
),
|
|
12743
|
+
/* @__PURE__ */ jsx(
|
|
12744
|
+
Form$2.Field,
|
|
12745
|
+
{
|
|
12746
|
+
control: form.control,
|
|
12747
|
+
name: "last_name",
|
|
12748
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12749
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
12750
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12751
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12752
|
+
] })
|
|
12753
|
+
}
|
|
12754
|
+
)
|
|
12755
|
+
] }),
|
|
12756
|
+
/* @__PURE__ */ jsx(
|
|
12757
|
+
Form$2.Field,
|
|
12758
|
+
{
|
|
12759
|
+
control: form.control,
|
|
12760
|
+
name: "company",
|
|
12761
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12762
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12763
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12764
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12765
|
+
] })
|
|
12766
|
+
}
|
|
12767
|
+
),
|
|
12768
|
+
/* @__PURE__ */ jsx(
|
|
12769
|
+
Form$2.Field,
|
|
12770
|
+
{
|
|
12771
|
+
control: form.control,
|
|
12772
|
+
name: "address_1",
|
|
12773
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12774
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
12775
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12776
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12777
|
+
] })
|
|
12778
|
+
}
|
|
12779
|
+
),
|
|
12780
|
+
/* @__PURE__ */ jsx(
|
|
12781
|
+
Form$2.Field,
|
|
12782
|
+
{
|
|
12783
|
+
control: form.control,
|
|
12784
|
+
name: "address_2",
|
|
12785
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12786
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12787
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12788
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12789
|
+
] })
|
|
12790
|
+
}
|
|
12791
|
+
),
|
|
12792
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12793
|
+
/* @__PURE__ */ jsx(
|
|
12794
|
+
Form$2.Field,
|
|
12795
|
+
{
|
|
12796
|
+
control: form.control,
|
|
12797
|
+
name: "postal_code",
|
|
12798
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12799
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
12800
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12801
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12802
|
+
] })
|
|
12803
|
+
}
|
|
12804
|
+
),
|
|
12805
|
+
/* @__PURE__ */ jsx(
|
|
12806
|
+
Form$2.Field,
|
|
12807
|
+
{
|
|
12808
|
+
control: form.control,
|
|
12809
|
+
name: "city",
|
|
12810
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12811
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
12812
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12813
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12814
|
+
] })
|
|
12815
|
+
}
|
|
12816
|
+
)
|
|
12817
|
+
] }),
|
|
12818
|
+
/* @__PURE__ */ jsx(
|
|
12819
|
+
Form$2.Field,
|
|
12820
|
+
{
|
|
12821
|
+
control: form.control,
|
|
12822
|
+
name: "province",
|
|
12823
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12824
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
12825
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12826
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12827
|
+
] })
|
|
12828
|
+
}
|
|
12829
|
+
),
|
|
12830
|
+
/* @__PURE__ */ jsx(
|
|
12831
|
+
Form$2.Field,
|
|
12832
|
+
{
|
|
12833
|
+
control: form.control,
|
|
12834
|
+
name: "phone",
|
|
12835
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12836
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
12837
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12838
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12839
|
+
] })
|
|
12840
|
+
}
|
|
12841
|
+
)
|
|
12842
|
+
] }) }),
|
|
12843
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12844
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12845
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12846
|
+
] }) })
|
|
12847
|
+
]
|
|
12848
|
+
}
|
|
12849
|
+
) });
|
|
12850
|
+
};
|
|
12851
|
+
const schema$1 = addressSchema;
|
|
12852
12852
|
const BillingAddress = () => {
|
|
12853
12853
|
const { id } = useParams();
|
|
12854
12854
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -13087,14 +13087,14 @@ const routeModule = {
|
|
|
13087
13087
|
Component: Shipping,
|
|
13088
13088
|
path: "/draft-orders/:id/shipping"
|
|
13089
13089
|
},
|
|
13090
|
-
{
|
|
13091
|
-
Component: ShippingAddress,
|
|
13092
|
-
path: "/draft-orders/:id/shipping-address"
|
|
13093
|
-
},
|
|
13094
13090
|
{
|
|
13095
13091
|
Component: TransferOwnership,
|
|
13096
13092
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13097
13093
|
},
|
|
13094
|
+
{
|
|
13095
|
+
Component: ShippingAddress,
|
|
13096
|
+
path: "/draft-orders/:id/shipping-address"
|
|
13097
|
+
},
|
|
13098
13098
|
{
|
|
13099
13099
|
Component: BillingAddress,
|
|
13100
13100
|
path: "/draft-orders/:id/billing-address"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/draft-order",
|
|
3
|
-
"version": "2.11.0-preview-
|
|
3
|
+
"version": "2.11.0-preview-20251019060156",
|
|
4
4
|
"description": "A starter for Medusa plugins.",
|
|
5
5
|
"author": "Medusa (https://medusajs.com)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@ariakit/react": "^0.4.15",
|
|
38
38
|
"@hookform/resolvers": "3.4.2",
|
|
39
|
-
"@medusajs/js-sdk": "2.11.0-preview-
|
|
39
|
+
"@medusajs/js-sdk": "2.11.0-preview-20251019060156",
|
|
40
40
|
"@tanstack/react-query": "5.64.2",
|
|
41
41
|
"@uiw/react-json-view": "^2.0.0-alpha.17",
|
|
42
42
|
"date-fns": "^3.6.0",
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
"react-hook-form": "7.49.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@medusajs/admin-sdk": "2.11.0-preview-
|
|
49
|
-
"@medusajs/cli": "2.11.0-preview-
|
|
50
|
-
"@medusajs/framework": "2.11.0-preview-
|
|
51
|
-
"@medusajs/icons": "2.11.0-preview-
|
|
52
|
-
"@medusajs/test-utils": "2.11.0-preview-
|
|
53
|
-
"@medusajs/types": "2.11.0-preview-
|
|
54
|
-
"@medusajs/ui": "4.0.24-preview-
|
|
55
|
-
"@medusajs/ui-preset": "2.11.0-preview-
|
|
48
|
+
"@medusajs/admin-sdk": "2.11.0-preview-20251019060156",
|
|
49
|
+
"@medusajs/cli": "2.11.0-preview-20251019060156",
|
|
50
|
+
"@medusajs/framework": "2.11.0-preview-20251019060156",
|
|
51
|
+
"@medusajs/icons": "2.11.0-preview-20251019060156",
|
|
52
|
+
"@medusajs/test-utils": "2.11.0-preview-20251019060156",
|
|
53
|
+
"@medusajs/types": "2.11.0-preview-20251019060156",
|
|
54
|
+
"@medusajs/ui": "4.0.24-preview-20251019060156",
|
|
55
|
+
"@medusajs/ui-preset": "2.11.0-preview-20251019060156",
|
|
56
56
|
"@swc/core": "1.5.7",
|
|
57
57
|
"@types/lodash": "^4.17.15",
|
|
58
58
|
"@types/node": "^20.0.0",
|
|
@@ -69,12 +69,12 @@
|
|
|
69
69
|
"yalc": "^1.0.0-pre.53"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
|
-
"@medusajs/admin-sdk": "2.11.0-preview-
|
|
73
|
-
"@medusajs/cli": "2.11.0-preview-
|
|
74
|
-
"@medusajs/framework": "2.11.0-preview-
|
|
75
|
-
"@medusajs/icons": "2.11.0-preview-
|
|
76
|
-
"@medusajs/test-utils": "2.11.0-preview-
|
|
77
|
-
"@medusajs/ui": "4.0.24-preview-
|
|
72
|
+
"@medusajs/admin-sdk": "2.11.0-preview-20251019060156",
|
|
73
|
+
"@medusajs/cli": "2.11.0-preview-20251019060156",
|
|
74
|
+
"@medusajs/framework": "2.11.0-preview-20251019060156",
|
|
75
|
+
"@medusajs/icons": "2.11.0-preview-20251019060156",
|
|
76
|
+
"@medusajs/test-utils": "2.11.0-preview-20251019060156",
|
|
77
|
+
"@medusajs/ui": "4.0.24-preview-20251019060156",
|
|
78
78
|
"lodash": "^4.17.21",
|
|
79
79
|
"react-router-dom": "6.20.1"
|
|
80
80
|
},
|