@medusajs/draft-order 3.0.0-snapshot-20251212142124 → 3.0.0-snapshot-20251214110905
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 +302 -302
- package/.medusa/server/src/admin/index.mjs +302 -302
- package/package.json +16 -16
|
@@ -11445,6 +11445,112 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11445
11445
|
}
|
|
11446
11446
|
return Array.from(promotionIds);
|
|
11447
11447
|
}
|
|
11448
|
+
const SalesChannel = () => {
|
|
11449
|
+
const { id } = useParams();
|
|
11450
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11451
|
+
id,
|
|
11452
|
+
{
|
|
11453
|
+
fields: "+sales_channel_id"
|
|
11454
|
+
},
|
|
11455
|
+
{
|
|
11456
|
+
enabled: !!id
|
|
11457
|
+
}
|
|
11458
|
+
);
|
|
11459
|
+
if (isError) {
|
|
11460
|
+
throw error;
|
|
11461
|
+
}
|
|
11462
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
11463
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11464
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11465
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
11466
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
11467
|
+
] }),
|
|
11468
|
+
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
11469
|
+
] });
|
|
11470
|
+
};
|
|
11471
|
+
const SalesChannelForm = ({ order }) => {
|
|
11472
|
+
const form = useForm({
|
|
11473
|
+
defaultValues: {
|
|
11474
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
11475
|
+
},
|
|
11476
|
+
resolver: zodResolver(schema$2)
|
|
11477
|
+
});
|
|
11478
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11479
|
+
const { handleSuccess } = useRouteModal();
|
|
11480
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11481
|
+
await mutateAsync(
|
|
11482
|
+
{
|
|
11483
|
+
sales_channel_id: data.sales_channel_id
|
|
11484
|
+
},
|
|
11485
|
+
{
|
|
11486
|
+
onSuccess: () => {
|
|
11487
|
+
toast.success("Sales channel updated");
|
|
11488
|
+
handleSuccess();
|
|
11489
|
+
},
|
|
11490
|
+
onError: (error) => {
|
|
11491
|
+
toast.error(error.message);
|
|
11492
|
+
}
|
|
11493
|
+
}
|
|
11494
|
+
);
|
|
11495
|
+
});
|
|
11496
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11497
|
+
KeyboundForm,
|
|
11498
|
+
{
|
|
11499
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11500
|
+
onSubmit,
|
|
11501
|
+
children: [
|
|
11502
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11503
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11504
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11505
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11506
|
+
] }) })
|
|
11507
|
+
]
|
|
11508
|
+
}
|
|
11509
|
+
) });
|
|
11510
|
+
};
|
|
11511
|
+
const SalesChannelField = ({ control, order }) => {
|
|
11512
|
+
const salesChannels = useComboboxData({
|
|
11513
|
+
queryFn: async (params) => {
|
|
11514
|
+
return await sdk.admin.salesChannel.list(params);
|
|
11515
|
+
},
|
|
11516
|
+
queryKey: ["sales-channels"],
|
|
11517
|
+
getOptions: (data) => {
|
|
11518
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
11519
|
+
label: salesChannel.name,
|
|
11520
|
+
value: salesChannel.id
|
|
11521
|
+
}));
|
|
11522
|
+
},
|
|
11523
|
+
defaultValue: order.sales_channel_id || void 0
|
|
11524
|
+
});
|
|
11525
|
+
return /* @__PURE__ */ jsx(
|
|
11526
|
+
Form$2.Field,
|
|
11527
|
+
{
|
|
11528
|
+
control,
|
|
11529
|
+
name: "sales_channel_id",
|
|
11530
|
+
render: ({ field }) => {
|
|
11531
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11532
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11533
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
11534
|
+
Combobox,
|
|
11535
|
+
{
|
|
11536
|
+
options: salesChannels.options,
|
|
11537
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
11538
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11539
|
+
searchValue: salesChannels.searchValue,
|
|
11540
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11541
|
+
placeholder: "Select sales channel",
|
|
11542
|
+
...field
|
|
11543
|
+
}
|
|
11544
|
+
) }),
|
|
11545
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11546
|
+
] });
|
|
11547
|
+
}
|
|
11548
|
+
}
|
|
11549
|
+
);
|
|
11550
|
+
};
|
|
11551
|
+
const schema$2 = objectType({
|
|
11552
|
+
sales_channel_id: stringType().min(1)
|
|
11553
|
+
});
|
|
11448
11554
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11449
11555
|
const Shipping = () => {
|
|
11450
11556
|
var _a;
|
|
@@ -12252,60 +12358,44 @@ const CustomAmountField = ({
|
|
|
12252
12358
|
}
|
|
12253
12359
|
);
|
|
12254
12360
|
};
|
|
12255
|
-
const
|
|
12361
|
+
const TransferOwnership = () => {
|
|
12256
12362
|
const { id } = useParams();
|
|
12257
|
-
const {
|
|
12258
|
-
fields: "
|
|
12363
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
12364
|
+
fields: "id,customer_id,customer.*"
|
|
12259
12365
|
});
|
|
12260
12366
|
if (isError) {
|
|
12261
12367
|
throw error;
|
|
12262
12368
|
}
|
|
12263
|
-
const isReady = !isPending && !!
|
|
12369
|
+
const isReady = !isPending && !!draft_order;
|
|
12264
12370
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12265
12371
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12266
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "
|
|
12267
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "
|
|
12372
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Ownership" }) }),
|
|
12373
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Transfer the ownership of this draft order to a new customer" }) })
|
|
12268
12374
|
] }),
|
|
12269
|
-
isReady && /* @__PURE__ */ jsx(
|
|
12375
|
+
isReady && /* @__PURE__ */ jsx(TransferOwnershipForm, { order: draft_order })
|
|
12270
12376
|
] });
|
|
12271
12377
|
};
|
|
12272
|
-
const
|
|
12273
|
-
var _a, _b
|
|
12378
|
+
const TransferOwnershipForm = ({ order }) => {
|
|
12379
|
+
var _a, _b;
|
|
12274
12380
|
const form = useForm({
|
|
12275
12381
|
defaultValues: {
|
|
12276
|
-
|
|
12277
|
-
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12278
|
-
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12279
|
-
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12280
|
-
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12281
|
-
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12282
|
-
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12283
|
-
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12284
|
-
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12285
|
-
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12382
|
+
customer_id: order.customer_id || ""
|
|
12286
12383
|
},
|
|
12287
|
-
resolver: zodResolver(schema$
|
|
12384
|
+
resolver: zodResolver(schema$1)
|
|
12288
12385
|
});
|
|
12289
12386
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12290
12387
|
const { handleSuccess } = useRouteModal();
|
|
12388
|
+
const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
|
|
12389
|
+
const currentCustomer = order.customer ? {
|
|
12390
|
+
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
12391
|
+
value: order.customer.id
|
|
12392
|
+
} : null;
|
|
12291
12393
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
12292
12394
|
await mutateAsync(
|
|
12293
|
-
{
|
|
12294
|
-
shipping_address: {
|
|
12295
|
-
first_name: data.first_name,
|
|
12296
|
-
last_name: data.last_name,
|
|
12297
|
-
company: data.company,
|
|
12298
|
-
address_1: data.address_1,
|
|
12299
|
-
address_2: data.address_2,
|
|
12300
|
-
city: data.city,
|
|
12301
|
-
province: data.province,
|
|
12302
|
-
country_code: data.country_code,
|
|
12303
|
-
postal_code: data.postal_code,
|
|
12304
|
-
phone: data.phone
|
|
12305
|
-
}
|
|
12306
|
-
},
|
|
12395
|
+
{ customer_id: data.customer_id },
|
|
12307
12396
|
{
|
|
12308
12397
|
onSuccess: () => {
|
|
12398
|
+
toast.success("Customer updated");
|
|
12309
12399
|
handleSuccess();
|
|
12310
12400
|
},
|
|
12311
12401
|
onError: (error) => {
|
|
@@ -12320,210 +12410,23 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12320
12410
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
12321
12411
|
onSubmit,
|
|
12322
12412
|
children: [
|
|
12323
|
-
/* @__PURE__ */
|
|
12324
|
-
/* @__PURE__ */ jsx(
|
|
12325
|
-
|
|
12326
|
-
{
|
|
12327
|
-
|
|
12328
|
-
|
|
12329
|
-
|
|
12330
|
-
|
|
12331
|
-
|
|
12332
|
-
|
|
12333
|
-
|
|
12334
|
-
}
|
|
12335
|
-
),
|
|
12336
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12337
|
-
/* @__PURE__ */ jsx(
|
|
12338
|
-
Form$2.Field,
|
|
12339
|
-
{
|
|
12340
|
-
control: form.control,
|
|
12341
|
-
name: "first_name",
|
|
12342
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12343
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
12344
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12345
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12346
|
-
] })
|
|
12347
|
-
}
|
|
12348
|
-
),
|
|
12349
|
-
/* @__PURE__ */ jsx(
|
|
12350
|
-
Form$2.Field,
|
|
12351
|
-
{
|
|
12352
|
-
control: form.control,
|
|
12353
|
-
name: "last_name",
|
|
12354
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12355
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
12356
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12357
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12358
|
-
] })
|
|
12359
|
-
}
|
|
12360
|
-
)
|
|
12413
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
12414
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsx(Illustration, {}) }),
|
|
12415
|
+
currentCustomer && /* @__PURE__ */ jsxs("div", { className: "flex flex-col space-y-3", children: [
|
|
12416
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
12417
|
+
/* @__PURE__ */ jsx(Label$1, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
|
|
12418
|
+
/* @__PURE__ */ jsx(Hint$1, { children: "The customer that is currently associated with this draft order." })
|
|
12419
|
+
] }),
|
|
12420
|
+
/* @__PURE__ */ jsxs(Select, { disabled: true, value: currentCustomer.value, children: [
|
|
12421
|
+
/* @__PURE__ */ jsx(Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsx(Select.Value, {}) }),
|
|
12422
|
+
/* @__PURE__ */ jsx(Select.Content, { children: /* @__PURE__ */ jsx(Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
|
|
12423
|
+
] })
|
|
12361
12424
|
] }),
|
|
12362
12425
|
/* @__PURE__ */ jsx(
|
|
12363
|
-
|
|
12364
|
-
{
|
|
12365
|
-
control: form.control,
|
|
12366
|
-
name: "company",
|
|
12367
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12368
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12369
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12370
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12371
|
-
] })
|
|
12372
|
-
}
|
|
12373
|
-
),
|
|
12374
|
-
/* @__PURE__ */ jsx(
|
|
12375
|
-
Form$2.Field,
|
|
12376
|
-
{
|
|
12377
|
-
control: form.control,
|
|
12378
|
-
name: "address_1",
|
|
12379
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12380
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
12381
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12382
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12383
|
-
] })
|
|
12384
|
-
}
|
|
12385
|
-
),
|
|
12386
|
-
/* @__PURE__ */ jsx(
|
|
12387
|
-
Form$2.Field,
|
|
12426
|
+
CustomerField,
|
|
12388
12427
|
{
|
|
12389
12428
|
control: form.control,
|
|
12390
|
-
|
|
12391
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12392
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12393
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12394
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12395
|
-
] })
|
|
12396
|
-
}
|
|
12397
|
-
),
|
|
12398
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12399
|
-
/* @__PURE__ */ jsx(
|
|
12400
|
-
Form$2.Field,
|
|
12401
|
-
{
|
|
12402
|
-
control: form.control,
|
|
12403
|
-
name: "postal_code",
|
|
12404
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12405
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
12406
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12407
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12408
|
-
] })
|
|
12409
|
-
}
|
|
12410
|
-
),
|
|
12411
|
-
/* @__PURE__ */ jsx(
|
|
12412
|
-
Form$2.Field,
|
|
12413
|
-
{
|
|
12414
|
-
control: form.control,
|
|
12415
|
-
name: "city",
|
|
12416
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12417
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
12418
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12419
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12420
|
-
] })
|
|
12421
|
-
}
|
|
12422
|
-
)
|
|
12423
|
-
] }),
|
|
12424
|
-
/* @__PURE__ */ jsx(
|
|
12425
|
-
Form$2.Field,
|
|
12426
|
-
{
|
|
12427
|
-
control: form.control,
|
|
12428
|
-
name: "province",
|
|
12429
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12430
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
12431
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12432
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12433
|
-
] })
|
|
12434
|
-
}
|
|
12435
|
-
),
|
|
12436
|
-
/* @__PURE__ */ jsx(
|
|
12437
|
-
Form$2.Field,
|
|
12438
|
-
{
|
|
12439
|
-
control: form.control,
|
|
12440
|
-
name: "phone",
|
|
12441
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12442
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
12443
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12444
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12445
|
-
] })
|
|
12446
|
-
}
|
|
12447
|
-
)
|
|
12448
|
-
] }) }),
|
|
12449
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12450
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12451
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12452
|
-
] }) })
|
|
12453
|
-
]
|
|
12454
|
-
}
|
|
12455
|
-
) });
|
|
12456
|
-
};
|
|
12457
|
-
const schema$2 = addressSchema;
|
|
12458
|
-
const TransferOwnership = () => {
|
|
12459
|
-
const { id } = useParams();
|
|
12460
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
12461
|
-
fields: "id,customer_id,customer.*"
|
|
12462
|
-
});
|
|
12463
|
-
if (isError) {
|
|
12464
|
-
throw error;
|
|
12465
|
-
}
|
|
12466
|
-
const isReady = !isPending && !!draft_order;
|
|
12467
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12468
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12469
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Ownership" }) }),
|
|
12470
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Transfer the ownership of this draft order to a new customer" }) })
|
|
12471
|
-
] }),
|
|
12472
|
-
isReady && /* @__PURE__ */ jsx(TransferOwnershipForm, { order: draft_order })
|
|
12473
|
-
] });
|
|
12474
|
-
};
|
|
12475
|
-
const TransferOwnershipForm = ({ order }) => {
|
|
12476
|
-
var _a, _b;
|
|
12477
|
-
const form = useForm({
|
|
12478
|
-
defaultValues: {
|
|
12479
|
-
customer_id: order.customer_id || ""
|
|
12480
|
-
},
|
|
12481
|
-
resolver: zodResolver(schema$1)
|
|
12482
|
-
});
|
|
12483
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12484
|
-
const { handleSuccess } = useRouteModal();
|
|
12485
|
-
const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
|
|
12486
|
-
const currentCustomer = order.customer ? {
|
|
12487
|
-
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
12488
|
-
value: order.customer.id
|
|
12489
|
-
} : null;
|
|
12490
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12491
|
-
await mutateAsync(
|
|
12492
|
-
{ customer_id: data.customer_id },
|
|
12493
|
-
{
|
|
12494
|
-
onSuccess: () => {
|
|
12495
|
-
toast.success("Customer updated");
|
|
12496
|
-
handleSuccess();
|
|
12497
|
-
},
|
|
12498
|
-
onError: (error) => {
|
|
12499
|
-
toast.error(error.message);
|
|
12500
|
-
}
|
|
12501
|
-
}
|
|
12502
|
-
);
|
|
12503
|
-
});
|
|
12504
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12505
|
-
KeyboundForm,
|
|
12506
|
-
{
|
|
12507
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12508
|
-
onSubmit,
|
|
12509
|
-
children: [
|
|
12510
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
12511
|
-
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsx(Illustration, {}) }),
|
|
12512
|
-
currentCustomer && /* @__PURE__ */ jsxs("div", { className: "flex flex-col space-y-3", children: [
|
|
12513
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
12514
|
-
/* @__PURE__ */ jsx(Label$1, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
|
|
12515
|
-
/* @__PURE__ */ jsx(Hint$1, { children: "The customer that is currently associated with this draft order." })
|
|
12516
|
-
] }),
|
|
12517
|
-
/* @__PURE__ */ jsxs(Select, { disabled: true, value: currentCustomer.value, children: [
|
|
12518
|
-
/* @__PURE__ */ jsx(Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsx(Select.Value, {}) }),
|
|
12519
|
-
/* @__PURE__ */ jsx(Select.Content, { children: /* @__PURE__ */ jsx(Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
|
|
12520
|
-
] })
|
|
12521
|
-
] }),
|
|
12522
|
-
/* @__PURE__ */ jsx(
|
|
12523
|
-
CustomerField,
|
|
12524
|
-
{
|
|
12525
|
-
control: form.control,
|
|
12526
|
-
currentCustomerId: order.customer_id
|
|
12429
|
+
currentCustomerId: order.customer_id
|
|
12527
12430
|
}
|
|
12528
12431
|
)
|
|
12529
12432
|
] }),
|
|
@@ -12931,33 +12834,37 @@ const Illustration = () => {
|
|
|
12931
12834
|
const schema$1 = objectType({
|
|
12932
12835
|
customer_id: stringType().min(1)
|
|
12933
12836
|
});
|
|
12934
|
-
const
|
|
12837
|
+
const ShippingAddress = () => {
|
|
12935
12838
|
const { id } = useParams();
|
|
12936
|
-
const {
|
|
12937
|
-
|
|
12938
|
-
|
|
12939
|
-
fields: "+sales_channel_id"
|
|
12940
|
-
},
|
|
12941
|
-
{
|
|
12942
|
-
enabled: !!id
|
|
12943
|
-
}
|
|
12944
|
-
);
|
|
12839
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
12840
|
+
fields: "+shipping_address"
|
|
12841
|
+
});
|
|
12945
12842
|
if (isError) {
|
|
12946
12843
|
throw error;
|
|
12947
12844
|
}
|
|
12948
|
-
const
|
|
12845
|
+
const isReady = !isPending && !!order;
|
|
12949
12846
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12950
12847
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12951
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit
|
|
12952
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "
|
|
12848
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
|
|
12849
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
12953
12850
|
] }),
|
|
12954
|
-
|
|
12851
|
+
isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
|
|
12955
12852
|
] });
|
|
12956
12853
|
};
|
|
12957
|
-
const
|
|
12854
|
+
const ShippingAddressForm = ({ order }) => {
|
|
12855
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12958
12856
|
const form = useForm({
|
|
12959
12857
|
defaultValues: {
|
|
12960
|
-
|
|
12858
|
+
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12859
|
+
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12860
|
+
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12861
|
+
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12862
|
+
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12863
|
+
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12864
|
+
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12865
|
+
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12866
|
+
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12867
|
+
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12961
12868
|
},
|
|
12962
12869
|
resolver: zodResolver(schema)
|
|
12963
12870
|
});
|
|
@@ -12966,11 +12873,21 @@ const SalesChannelForm = ({ order }) => {
|
|
|
12966
12873
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
12967
12874
|
await mutateAsync(
|
|
12968
12875
|
{
|
|
12969
|
-
|
|
12876
|
+
shipping_address: {
|
|
12877
|
+
first_name: data.first_name,
|
|
12878
|
+
last_name: data.last_name,
|
|
12879
|
+
company: data.company,
|
|
12880
|
+
address_1: data.address_1,
|
|
12881
|
+
address_2: data.address_2,
|
|
12882
|
+
city: data.city,
|
|
12883
|
+
province: data.province,
|
|
12884
|
+
country_code: data.country_code,
|
|
12885
|
+
postal_code: data.postal_code,
|
|
12886
|
+
phone: data.phone
|
|
12887
|
+
}
|
|
12970
12888
|
},
|
|
12971
12889
|
{
|
|
12972
12890
|
onSuccess: () => {
|
|
12973
|
-
toast.success("Sales channel updated");
|
|
12974
12891
|
handleSuccess();
|
|
12975
12892
|
},
|
|
12976
12893
|
onError: (error) => {
|
|
@@ -12985,7 +12902,132 @@ const SalesChannelForm = ({ order }) => {
|
|
|
12985
12902
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
12986
12903
|
onSubmit,
|
|
12987
12904
|
children: [
|
|
12988
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */
|
|
12905
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
|
|
12906
|
+
/* @__PURE__ */ jsx(
|
|
12907
|
+
Form$2.Field,
|
|
12908
|
+
{
|
|
12909
|
+
control: form.control,
|
|
12910
|
+
name: "country_code",
|
|
12911
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12912
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
12913
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
12914
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12915
|
+
] })
|
|
12916
|
+
}
|
|
12917
|
+
),
|
|
12918
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12919
|
+
/* @__PURE__ */ jsx(
|
|
12920
|
+
Form$2.Field,
|
|
12921
|
+
{
|
|
12922
|
+
control: form.control,
|
|
12923
|
+
name: "first_name",
|
|
12924
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12925
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
12926
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12927
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12928
|
+
] })
|
|
12929
|
+
}
|
|
12930
|
+
),
|
|
12931
|
+
/* @__PURE__ */ jsx(
|
|
12932
|
+
Form$2.Field,
|
|
12933
|
+
{
|
|
12934
|
+
control: form.control,
|
|
12935
|
+
name: "last_name",
|
|
12936
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12937
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
12938
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12939
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12940
|
+
] })
|
|
12941
|
+
}
|
|
12942
|
+
)
|
|
12943
|
+
] }),
|
|
12944
|
+
/* @__PURE__ */ jsx(
|
|
12945
|
+
Form$2.Field,
|
|
12946
|
+
{
|
|
12947
|
+
control: form.control,
|
|
12948
|
+
name: "company",
|
|
12949
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12950
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12951
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12952
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12953
|
+
] })
|
|
12954
|
+
}
|
|
12955
|
+
),
|
|
12956
|
+
/* @__PURE__ */ jsx(
|
|
12957
|
+
Form$2.Field,
|
|
12958
|
+
{
|
|
12959
|
+
control: form.control,
|
|
12960
|
+
name: "address_1",
|
|
12961
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12962
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
12963
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12964
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12965
|
+
] })
|
|
12966
|
+
}
|
|
12967
|
+
),
|
|
12968
|
+
/* @__PURE__ */ jsx(
|
|
12969
|
+
Form$2.Field,
|
|
12970
|
+
{
|
|
12971
|
+
control: form.control,
|
|
12972
|
+
name: "address_2",
|
|
12973
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12974
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12975
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12976
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12977
|
+
] })
|
|
12978
|
+
}
|
|
12979
|
+
),
|
|
12980
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12981
|
+
/* @__PURE__ */ jsx(
|
|
12982
|
+
Form$2.Field,
|
|
12983
|
+
{
|
|
12984
|
+
control: form.control,
|
|
12985
|
+
name: "postal_code",
|
|
12986
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12987
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
12988
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12989
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12990
|
+
] })
|
|
12991
|
+
}
|
|
12992
|
+
),
|
|
12993
|
+
/* @__PURE__ */ jsx(
|
|
12994
|
+
Form$2.Field,
|
|
12995
|
+
{
|
|
12996
|
+
control: form.control,
|
|
12997
|
+
name: "city",
|
|
12998
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12999
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
13000
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13001
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13002
|
+
] })
|
|
13003
|
+
}
|
|
13004
|
+
)
|
|
13005
|
+
] }),
|
|
13006
|
+
/* @__PURE__ */ jsx(
|
|
13007
|
+
Form$2.Field,
|
|
13008
|
+
{
|
|
13009
|
+
control: form.control,
|
|
13010
|
+
name: "province",
|
|
13011
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13012
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
13013
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13014
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13015
|
+
] })
|
|
13016
|
+
}
|
|
13017
|
+
),
|
|
13018
|
+
/* @__PURE__ */ jsx(
|
|
13019
|
+
Form$2.Field,
|
|
13020
|
+
{
|
|
13021
|
+
control: form.control,
|
|
13022
|
+
name: "phone",
|
|
13023
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13024
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
13025
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13026
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13027
|
+
] })
|
|
13028
|
+
}
|
|
13029
|
+
)
|
|
13030
|
+
] }) }),
|
|
12989
13031
|
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12990
13032
|
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12991
13033
|
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
@@ -12994,49 +13036,7 @@ const SalesChannelForm = ({ order }) => {
|
|
|
12994
13036
|
}
|
|
12995
13037
|
) });
|
|
12996
13038
|
};
|
|
12997
|
-
const
|
|
12998
|
-
const salesChannels = useComboboxData({
|
|
12999
|
-
queryFn: async (params) => {
|
|
13000
|
-
return await sdk.admin.salesChannel.list(params);
|
|
13001
|
-
},
|
|
13002
|
-
queryKey: ["sales-channels"],
|
|
13003
|
-
getOptions: (data) => {
|
|
13004
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
13005
|
-
label: salesChannel.name,
|
|
13006
|
-
value: salesChannel.id
|
|
13007
|
-
}));
|
|
13008
|
-
},
|
|
13009
|
-
defaultValue: order.sales_channel_id || void 0
|
|
13010
|
-
});
|
|
13011
|
-
return /* @__PURE__ */ jsx(
|
|
13012
|
-
Form$2.Field,
|
|
13013
|
-
{
|
|
13014
|
-
control,
|
|
13015
|
-
name: "sales_channel_id",
|
|
13016
|
-
render: ({ field }) => {
|
|
13017
|
-
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13018
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
13019
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
13020
|
-
Combobox,
|
|
13021
|
-
{
|
|
13022
|
-
options: salesChannels.options,
|
|
13023
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
13024
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
13025
|
-
searchValue: salesChannels.searchValue,
|
|
13026
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
13027
|
-
placeholder: "Select sales channel",
|
|
13028
|
-
...field
|
|
13029
|
-
}
|
|
13030
|
-
) }),
|
|
13031
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13032
|
-
] });
|
|
13033
|
-
}
|
|
13034
|
-
}
|
|
13035
|
-
);
|
|
13036
|
-
};
|
|
13037
|
-
const schema = objectType({
|
|
13038
|
-
sales_channel_id: stringType().min(1)
|
|
13039
|
-
});
|
|
13039
|
+
const schema = addressSchema;
|
|
13040
13040
|
const widgetModule = { widgets: [] };
|
|
13041
13041
|
const routeModule = {
|
|
13042
13042
|
routes: [
|
|
@@ -13082,20 +13082,20 @@ const routeModule = {
|
|
|
13082
13082
|
path: "/draft-orders/:id/promotions"
|
|
13083
13083
|
},
|
|
13084
13084
|
{
|
|
13085
|
-
Component:
|
|
13086
|
-
path: "/draft-orders/:id/
|
|
13085
|
+
Component: SalesChannel,
|
|
13086
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13087
13087
|
},
|
|
13088
13088
|
{
|
|
13089
|
-
Component:
|
|
13090
|
-
path: "/draft-orders/:id/shipping
|
|
13089
|
+
Component: Shipping,
|
|
13090
|
+
path: "/draft-orders/:id/shipping"
|
|
13091
13091
|
},
|
|
13092
13092
|
{
|
|
13093
13093
|
Component: TransferOwnership,
|
|
13094
13094
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13095
13095
|
},
|
|
13096
13096
|
{
|
|
13097
|
-
Component:
|
|
13098
|
-
path: "/draft-orders/:id/
|
|
13097
|
+
Component: ShippingAddress,
|
|
13098
|
+
path: "/draft-orders/:id/shipping-address"
|
|
13099
13099
|
}
|
|
13100
13100
|
]
|
|
13101
13101
|
}
|