@medusajs/draft-order 2.11.0-preview-20251018031037 → 2.11.0-preview-20251018060206
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 +292 -292
- package/.medusa/server/src/admin/index.mjs +292 -292
- package/package.json +16 -16
|
@@ -9757,6 +9757,27 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9757
9757
|
) });
|
|
9758
9758
|
};
|
|
9759
9759
|
const schema$5 = addressSchema;
|
|
9760
|
+
const CustomItems = () => {
|
|
9761
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9762
|
+
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
9763
|
+
/* @__PURE__ */ jsx(CustomItemsForm, {})
|
|
9764
|
+
] });
|
|
9765
|
+
};
|
|
9766
|
+
const CustomItemsForm = () => {
|
|
9767
|
+
const form = useForm({
|
|
9768
|
+
resolver: zodResolver(schema$4)
|
|
9769
|
+
});
|
|
9770
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9771
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
9772
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9773
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9774
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
|
|
9775
|
+
] }) })
|
|
9776
|
+
] }) });
|
|
9777
|
+
};
|
|
9778
|
+
const schema$4 = objectType({
|
|
9779
|
+
email: stringType().email()
|
|
9780
|
+
});
|
|
9760
9781
|
const Email = () => {
|
|
9761
9782
|
const { id } = useParams();
|
|
9762
9783
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -9779,7 +9800,7 @@ const EmailForm = ({ order }) => {
|
|
|
9779
9800
|
defaultValues: {
|
|
9780
9801
|
email: order.email ?? ""
|
|
9781
9802
|
},
|
|
9782
|
-
resolver: zodResolver(schema$
|
|
9803
|
+
resolver: zodResolver(schema$3)
|
|
9783
9804
|
});
|
|
9784
9805
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9785
9806
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9822,7 +9843,7 @@ const EmailForm = ({ order }) => {
|
|
|
9822
9843
|
}
|
|
9823
9844
|
) });
|
|
9824
9845
|
};
|
|
9825
|
-
const schema$
|
|
9846
|
+
const schema$3 = objectType({
|
|
9826
9847
|
email: stringType().email()
|
|
9827
9848
|
});
|
|
9828
9849
|
const NumberInput = forwardRef(
|
|
@@ -11426,46 +11447,60 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11426
11447
|
}
|
|
11427
11448
|
return Array.from(promotionIds);
|
|
11428
11449
|
}
|
|
11429
|
-
const
|
|
11450
|
+
const ShippingAddress = () => {
|
|
11430
11451
|
const { id } = useParams();
|
|
11431
|
-
const {
|
|
11432
|
-
|
|
11433
|
-
|
|
11434
|
-
fields: "+sales_channel_id"
|
|
11435
|
-
},
|
|
11436
|
-
{
|
|
11437
|
-
enabled: !!id
|
|
11438
|
-
}
|
|
11439
|
-
);
|
|
11452
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
11453
|
+
fields: "+shipping_address"
|
|
11454
|
+
});
|
|
11440
11455
|
if (isError) {
|
|
11441
11456
|
throw error;
|
|
11442
11457
|
}
|
|
11443
|
-
const
|
|
11458
|
+
const isReady = !isPending && !!order;
|
|
11444
11459
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11445
11460
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11446
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit
|
|
11447
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "
|
|
11461
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
|
|
11462
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
11448
11463
|
] }),
|
|
11449
|
-
|
|
11464
|
+
isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
|
|
11450
11465
|
] });
|
|
11451
11466
|
};
|
|
11452
|
-
const
|
|
11467
|
+
const ShippingAddressForm = ({ order }) => {
|
|
11468
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
11453
11469
|
const form = useForm({
|
|
11454
11470
|
defaultValues: {
|
|
11455
|
-
|
|
11471
|
+
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
11472
|
+
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
11473
|
+
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
11474
|
+
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
11475
|
+
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
11476
|
+
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
11477
|
+
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
11478
|
+
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
11479
|
+
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
11480
|
+
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
11456
11481
|
},
|
|
11457
|
-
resolver: zodResolver(schema$
|
|
11482
|
+
resolver: zodResolver(schema$2)
|
|
11458
11483
|
});
|
|
11459
11484
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11460
11485
|
const { handleSuccess } = useRouteModal();
|
|
11461
11486
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
11462
11487
|
await mutateAsync(
|
|
11463
11488
|
{
|
|
11464
|
-
|
|
11489
|
+
shipping_address: {
|
|
11490
|
+
first_name: data.first_name,
|
|
11491
|
+
last_name: data.last_name,
|
|
11492
|
+
company: data.company,
|
|
11493
|
+
address_1: data.address_1,
|
|
11494
|
+
address_2: data.address_2,
|
|
11495
|
+
city: data.city,
|
|
11496
|
+
province: data.province,
|
|
11497
|
+
country_code: data.country_code,
|
|
11498
|
+
postal_code: data.postal_code,
|
|
11499
|
+
phone: data.phone
|
|
11500
|
+
}
|
|
11465
11501
|
},
|
|
11466
11502
|
{
|
|
11467
11503
|
onSuccess: () => {
|
|
11468
|
-
toast.success("Sales channel updated");
|
|
11469
11504
|
handleSuccess();
|
|
11470
11505
|
},
|
|
11471
11506
|
onError: (error) => {
|
|
@@ -11480,7 +11515,132 @@ const SalesChannelForm = ({ order }) => {
|
|
|
11480
11515
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
11481
11516
|
onSubmit,
|
|
11482
11517
|
children: [
|
|
11483
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */
|
|
11518
|
+
/* @__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: [
|
|
11519
|
+
/* @__PURE__ */ jsx(
|
|
11520
|
+
Form$2.Field,
|
|
11521
|
+
{
|
|
11522
|
+
control: form.control,
|
|
11523
|
+
name: "country_code",
|
|
11524
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11525
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
11526
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
11527
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11528
|
+
] })
|
|
11529
|
+
}
|
|
11530
|
+
),
|
|
11531
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11532
|
+
/* @__PURE__ */ jsx(
|
|
11533
|
+
Form$2.Field,
|
|
11534
|
+
{
|
|
11535
|
+
control: form.control,
|
|
11536
|
+
name: "first_name",
|
|
11537
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11538
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
11539
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11540
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11541
|
+
] })
|
|
11542
|
+
}
|
|
11543
|
+
),
|
|
11544
|
+
/* @__PURE__ */ jsx(
|
|
11545
|
+
Form$2.Field,
|
|
11546
|
+
{
|
|
11547
|
+
control: form.control,
|
|
11548
|
+
name: "last_name",
|
|
11549
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11550
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
11551
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11552
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11553
|
+
] })
|
|
11554
|
+
}
|
|
11555
|
+
)
|
|
11556
|
+
] }),
|
|
11557
|
+
/* @__PURE__ */ jsx(
|
|
11558
|
+
Form$2.Field,
|
|
11559
|
+
{
|
|
11560
|
+
control: form.control,
|
|
11561
|
+
name: "company",
|
|
11562
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11563
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
11564
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11565
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11566
|
+
] })
|
|
11567
|
+
}
|
|
11568
|
+
),
|
|
11569
|
+
/* @__PURE__ */ jsx(
|
|
11570
|
+
Form$2.Field,
|
|
11571
|
+
{
|
|
11572
|
+
control: form.control,
|
|
11573
|
+
name: "address_1",
|
|
11574
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11575
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
11576
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11577
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11578
|
+
] })
|
|
11579
|
+
}
|
|
11580
|
+
),
|
|
11581
|
+
/* @__PURE__ */ jsx(
|
|
11582
|
+
Form$2.Field,
|
|
11583
|
+
{
|
|
11584
|
+
control: form.control,
|
|
11585
|
+
name: "address_2",
|
|
11586
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11587
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
11588
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11589
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11590
|
+
] })
|
|
11591
|
+
}
|
|
11592
|
+
),
|
|
11593
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11594
|
+
/* @__PURE__ */ jsx(
|
|
11595
|
+
Form$2.Field,
|
|
11596
|
+
{
|
|
11597
|
+
control: form.control,
|
|
11598
|
+
name: "postal_code",
|
|
11599
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11600
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
11601
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11602
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11603
|
+
] })
|
|
11604
|
+
}
|
|
11605
|
+
),
|
|
11606
|
+
/* @__PURE__ */ jsx(
|
|
11607
|
+
Form$2.Field,
|
|
11608
|
+
{
|
|
11609
|
+
control: form.control,
|
|
11610
|
+
name: "city",
|
|
11611
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11612
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
11613
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11614
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11615
|
+
] })
|
|
11616
|
+
}
|
|
11617
|
+
)
|
|
11618
|
+
] }),
|
|
11619
|
+
/* @__PURE__ */ jsx(
|
|
11620
|
+
Form$2.Field,
|
|
11621
|
+
{
|
|
11622
|
+
control: form.control,
|
|
11623
|
+
name: "province",
|
|
11624
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11625
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
11626
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11627
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11628
|
+
] })
|
|
11629
|
+
}
|
|
11630
|
+
),
|
|
11631
|
+
/* @__PURE__ */ jsx(
|
|
11632
|
+
Form$2.Field,
|
|
11633
|
+
{
|
|
11634
|
+
control: form.control,
|
|
11635
|
+
name: "phone",
|
|
11636
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11637
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
11638
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11639
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11640
|
+
] })
|
|
11641
|
+
}
|
|
11642
|
+
)
|
|
11643
|
+
] }) }),
|
|
11484
11644
|
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11485
11645
|
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11486
11646
|
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
@@ -11489,49 +11649,7 @@ const SalesChannelForm = ({ order }) => {
|
|
|
11489
11649
|
}
|
|
11490
11650
|
) });
|
|
11491
11651
|
};
|
|
11492
|
-
const
|
|
11493
|
-
const salesChannels = useComboboxData({
|
|
11494
|
-
queryFn: async (params) => {
|
|
11495
|
-
return await sdk.admin.salesChannel.list(params);
|
|
11496
|
-
},
|
|
11497
|
-
queryKey: ["sales-channels"],
|
|
11498
|
-
getOptions: (data) => {
|
|
11499
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
11500
|
-
label: salesChannel.name,
|
|
11501
|
-
value: salesChannel.id
|
|
11502
|
-
}));
|
|
11503
|
-
},
|
|
11504
|
-
defaultValue: order.sales_channel_id || void 0
|
|
11505
|
-
});
|
|
11506
|
-
return /* @__PURE__ */ jsx(
|
|
11507
|
-
Form$2.Field,
|
|
11508
|
-
{
|
|
11509
|
-
control,
|
|
11510
|
-
name: "sales_channel_id",
|
|
11511
|
-
render: ({ field }) => {
|
|
11512
|
-
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11513
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11514
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
11515
|
-
Combobox,
|
|
11516
|
-
{
|
|
11517
|
-
options: salesChannels.options,
|
|
11518
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
11519
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11520
|
-
searchValue: salesChannels.searchValue,
|
|
11521
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11522
|
-
placeholder: "Select sales channel",
|
|
11523
|
-
...field
|
|
11524
|
-
}
|
|
11525
|
-
) }),
|
|
11526
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11527
|
-
] });
|
|
11528
|
-
}
|
|
11529
|
-
}
|
|
11530
|
-
);
|
|
11531
|
-
};
|
|
11532
|
-
const schema$3 = objectType({
|
|
11533
|
-
sales_channel_id: stringType().min(1)
|
|
11534
|
-
});
|
|
11652
|
+
const schema$2 = addressSchema;
|
|
11535
11653
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11536
11654
|
const Shipping = () => {
|
|
11537
11655
|
var _a;
|
|
@@ -12339,218 +12457,15 @@ const CustomAmountField = ({
|
|
|
12339
12457
|
}
|
|
12340
12458
|
);
|
|
12341
12459
|
};
|
|
12342
|
-
const
|
|
12460
|
+
const TransferOwnership = () => {
|
|
12343
12461
|
const { id } = useParams();
|
|
12344
|
-
const {
|
|
12345
|
-
fields: "
|
|
12462
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
12463
|
+
fields: "id,customer_id,customer.*"
|
|
12346
12464
|
});
|
|
12347
12465
|
if (isError) {
|
|
12348
12466
|
throw error;
|
|
12349
12467
|
}
|
|
12350
|
-
const isReady = !isPending && !!
|
|
12351
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12352
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12353
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
|
|
12354
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
12355
|
-
] }),
|
|
12356
|
-
isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
|
|
12357
|
-
] });
|
|
12358
|
-
};
|
|
12359
|
-
const ShippingAddressForm = ({ order }) => {
|
|
12360
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12361
|
-
const form = useForm({
|
|
12362
|
-
defaultValues: {
|
|
12363
|
-
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12364
|
-
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12365
|
-
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12366
|
-
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12367
|
-
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12368
|
-
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12369
|
-
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12370
|
-
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12371
|
-
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12372
|
-
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12373
|
-
},
|
|
12374
|
-
resolver: zodResolver(schema$2)
|
|
12375
|
-
});
|
|
12376
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12377
|
-
const { handleSuccess } = useRouteModal();
|
|
12378
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12379
|
-
await mutateAsync(
|
|
12380
|
-
{
|
|
12381
|
-
shipping_address: {
|
|
12382
|
-
first_name: data.first_name,
|
|
12383
|
-
last_name: data.last_name,
|
|
12384
|
-
company: data.company,
|
|
12385
|
-
address_1: data.address_1,
|
|
12386
|
-
address_2: data.address_2,
|
|
12387
|
-
city: data.city,
|
|
12388
|
-
province: data.province,
|
|
12389
|
-
country_code: data.country_code,
|
|
12390
|
-
postal_code: data.postal_code,
|
|
12391
|
-
phone: data.phone
|
|
12392
|
-
}
|
|
12393
|
-
},
|
|
12394
|
-
{
|
|
12395
|
-
onSuccess: () => {
|
|
12396
|
-
handleSuccess();
|
|
12397
|
-
},
|
|
12398
|
-
onError: (error) => {
|
|
12399
|
-
toast.error(error.message);
|
|
12400
|
-
}
|
|
12401
|
-
}
|
|
12402
|
-
);
|
|
12403
|
-
});
|
|
12404
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12405
|
-
KeyboundForm,
|
|
12406
|
-
{
|
|
12407
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12408
|
-
onSubmit,
|
|
12409
|
-
children: [
|
|
12410
|
-
/* @__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: [
|
|
12411
|
-
/* @__PURE__ */ jsx(
|
|
12412
|
-
Form$2.Field,
|
|
12413
|
-
{
|
|
12414
|
-
control: form.control,
|
|
12415
|
-
name: "country_code",
|
|
12416
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12417
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
12418
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
12419
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12420
|
-
] })
|
|
12421
|
-
}
|
|
12422
|
-
),
|
|
12423
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12424
|
-
/* @__PURE__ */ jsx(
|
|
12425
|
-
Form$2.Field,
|
|
12426
|
-
{
|
|
12427
|
-
control: form.control,
|
|
12428
|
-
name: "first_name",
|
|
12429
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12430
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
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: "last_name",
|
|
12441
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12442
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
12443
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12444
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12445
|
-
] })
|
|
12446
|
-
}
|
|
12447
|
-
)
|
|
12448
|
-
] }),
|
|
12449
|
-
/* @__PURE__ */ jsx(
|
|
12450
|
-
Form$2.Field,
|
|
12451
|
-
{
|
|
12452
|
-
control: form.control,
|
|
12453
|
-
name: "company",
|
|
12454
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12455
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12456
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12457
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12458
|
-
] })
|
|
12459
|
-
}
|
|
12460
|
-
),
|
|
12461
|
-
/* @__PURE__ */ jsx(
|
|
12462
|
-
Form$2.Field,
|
|
12463
|
-
{
|
|
12464
|
-
control: form.control,
|
|
12465
|
-
name: "address_1",
|
|
12466
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12467
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
12468
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12469
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12470
|
-
] })
|
|
12471
|
-
}
|
|
12472
|
-
),
|
|
12473
|
-
/* @__PURE__ */ jsx(
|
|
12474
|
-
Form$2.Field,
|
|
12475
|
-
{
|
|
12476
|
-
control: form.control,
|
|
12477
|
-
name: "address_2",
|
|
12478
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12479
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12480
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12481
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12482
|
-
] })
|
|
12483
|
-
}
|
|
12484
|
-
),
|
|
12485
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12486
|
-
/* @__PURE__ */ jsx(
|
|
12487
|
-
Form$2.Field,
|
|
12488
|
-
{
|
|
12489
|
-
control: form.control,
|
|
12490
|
-
name: "postal_code",
|
|
12491
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12492
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
12493
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12494
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12495
|
-
] })
|
|
12496
|
-
}
|
|
12497
|
-
),
|
|
12498
|
-
/* @__PURE__ */ jsx(
|
|
12499
|
-
Form$2.Field,
|
|
12500
|
-
{
|
|
12501
|
-
control: form.control,
|
|
12502
|
-
name: "city",
|
|
12503
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12504
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
12505
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12506
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12507
|
-
] })
|
|
12508
|
-
}
|
|
12509
|
-
)
|
|
12510
|
-
] }),
|
|
12511
|
-
/* @__PURE__ */ jsx(
|
|
12512
|
-
Form$2.Field,
|
|
12513
|
-
{
|
|
12514
|
-
control: form.control,
|
|
12515
|
-
name: "province",
|
|
12516
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12517
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
12518
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12519
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12520
|
-
] })
|
|
12521
|
-
}
|
|
12522
|
-
),
|
|
12523
|
-
/* @__PURE__ */ jsx(
|
|
12524
|
-
Form$2.Field,
|
|
12525
|
-
{
|
|
12526
|
-
control: form.control,
|
|
12527
|
-
name: "phone",
|
|
12528
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12529
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
12530
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12531
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12532
|
-
] })
|
|
12533
|
-
}
|
|
12534
|
-
)
|
|
12535
|
-
] }) }),
|
|
12536
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12537
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12538
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12539
|
-
] }) })
|
|
12540
|
-
]
|
|
12541
|
-
}
|
|
12542
|
-
) });
|
|
12543
|
-
};
|
|
12544
|
-
const schema$2 = addressSchema;
|
|
12545
|
-
const TransferOwnership = () => {
|
|
12546
|
-
const { id } = useParams();
|
|
12547
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
12548
|
-
fields: "id,customer_id,customer.*"
|
|
12549
|
-
});
|
|
12550
|
-
if (isError) {
|
|
12551
|
-
throw error;
|
|
12552
|
-
}
|
|
12553
|
-
const isReady = !isPending && !!draft_order;
|
|
12468
|
+
const isReady = !isPending && !!draft_order;
|
|
12554
12469
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12555
12470
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12556
12471
|
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Ownership" }) }),
|
|
@@ -13018,26 +12933,111 @@ const Illustration = () => {
|
|
|
13018
12933
|
const schema$1 = objectType({
|
|
13019
12934
|
customer_id: stringType().min(1)
|
|
13020
12935
|
});
|
|
13021
|
-
const
|
|
12936
|
+
const SalesChannel = () => {
|
|
12937
|
+
const { id } = useParams();
|
|
12938
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12939
|
+
id,
|
|
12940
|
+
{
|
|
12941
|
+
fields: "+sales_channel_id"
|
|
12942
|
+
},
|
|
12943
|
+
{
|
|
12944
|
+
enabled: !!id
|
|
12945
|
+
}
|
|
12946
|
+
);
|
|
12947
|
+
if (isError) {
|
|
12948
|
+
throw error;
|
|
12949
|
+
}
|
|
12950
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
13022
12951
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
13023
|
-
/* @__PURE__ */
|
|
13024
|
-
|
|
12952
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12953
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
12954
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
12955
|
+
] }),
|
|
12956
|
+
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
13025
12957
|
] });
|
|
13026
12958
|
};
|
|
13027
|
-
const
|
|
12959
|
+
const SalesChannelForm = ({ order }) => {
|
|
13028
12960
|
const form = useForm({
|
|
12961
|
+
defaultValues: {
|
|
12962
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
12963
|
+
},
|
|
13029
12964
|
resolver: zodResolver(schema)
|
|
13030
12965
|
});
|
|
13031
|
-
|
|
13032
|
-
|
|
13033
|
-
|
|
13034
|
-
|
|
13035
|
-
|
|
13036
|
-
|
|
13037
|
-
|
|
12966
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12967
|
+
const { handleSuccess } = useRouteModal();
|
|
12968
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12969
|
+
await mutateAsync(
|
|
12970
|
+
{
|
|
12971
|
+
sales_channel_id: data.sales_channel_id
|
|
12972
|
+
},
|
|
12973
|
+
{
|
|
12974
|
+
onSuccess: () => {
|
|
12975
|
+
toast.success("Sales channel updated");
|
|
12976
|
+
handleSuccess();
|
|
12977
|
+
},
|
|
12978
|
+
onError: (error) => {
|
|
12979
|
+
toast.error(error.message);
|
|
12980
|
+
}
|
|
12981
|
+
}
|
|
12982
|
+
);
|
|
12983
|
+
});
|
|
12984
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12985
|
+
KeyboundForm,
|
|
12986
|
+
{
|
|
12987
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12988
|
+
onSubmit,
|
|
12989
|
+
children: [
|
|
12990
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12991
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12992
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12993
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12994
|
+
] }) })
|
|
12995
|
+
]
|
|
12996
|
+
}
|
|
12997
|
+
) });
|
|
12998
|
+
};
|
|
12999
|
+
const SalesChannelField = ({ control, order }) => {
|
|
13000
|
+
const salesChannels = useComboboxData({
|
|
13001
|
+
queryFn: async (params) => {
|
|
13002
|
+
return await sdk.admin.salesChannel.list(params);
|
|
13003
|
+
},
|
|
13004
|
+
queryKey: ["sales-channels"],
|
|
13005
|
+
getOptions: (data) => {
|
|
13006
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
13007
|
+
label: salesChannel.name,
|
|
13008
|
+
value: salesChannel.id
|
|
13009
|
+
}));
|
|
13010
|
+
},
|
|
13011
|
+
defaultValue: order.sales_channel_id || void 0
|
|
13012
|
+
});
|
|
13013
|
+
return /* @__PURE__ */ jsx(
|
|
13014
|
+
Form$2.Field,
|
|
13015
|
+
{
|
|
13016
|
+
control,
|
|
13017
|
+
name: "sales_channel_id",
|
|
13018
|
+
render: ({ field }) => {
|
|
13019
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13020
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
13021
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
13022
|
+
Combobox,
|
|
13023
|
+
{
|
|
13024
|
+
options: salesChannels.options,
|
|
13025
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
13026
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
13027
|
+
searchValue: salesChannels.searchValue,
|
|
13028
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
13029
|
+
placeholder: "Select sales channel",
|
|
13030
|
+
...field
|
|
13031
|
+
}
|
|
13032
|
+
) }),
|
|
13033
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13034
|
+
] });
|
|
13035
|
+
}
|
|
13036
|
+
}
|
|
13037
|
+
);
|
|
13038
13038
|
};
|
|
13039
13039
|
const schema = objectType({
|
|
13040
|
-
|
|
13040
|
+
sales_channel_id: stringType().min(1)
|
|
13041
13041
|
});
|
|
13042
13042
|
const widgetModule = { widgets: [] };
|
|
13043
13043
|
const routeModule = {
|
|
@@ -13063,6 +13063,10 @@ const routeModule = {
|
|
|
13063
13063
|
Component: BillingAddress,
|
|
13064
13064
|
path: "/draft-orders/:id/billing-address"
|
|
13065
13065
|
},
|
|
13066
|
+
{
|
|
13067
|
+
Component: CustomItems,
|
|
13068
|
+
path: "/draft-orders/:id/custom-items"
|
|
13069
|
+
},
|
|
13066
13070
|
{
|
|
13067
13071
|
Component: Email,
|
|
13068
13072
|
path: "/draft-orders/:id/email"
|
|
@@ -13080,24 +13084,20 @@ const routeModule = {
|
|
|
13080
13084
|
path: "/draft-orders/:id/promotions"
|
|
13081
13085
|
},
|
|
13082
13086
|
{
|
|
13083
|
-
Component:
|
|
13084
|
-
path: "/draft-orders/:id/
|
|
13087
|
+
Component: ShippingAddress,
|
|
13088
|
+
path: "/draft-orders/:id/shipping-address"
|
|
13085
13089
|
},
|
|
13086
13090
|
{
|
|
13087
13091
|
Component: Shipping,
|
|
13088
13092
|
path: "/draft-orders/:id/shipping"
|
|
13089
13093
|
},
|
|
13090
|
-
{
|
|
13091
|
-
Component: ShippingAddress,
|
|
13092
|
-
path: "/draft-orders/:id/shipping-address"
|
|
13093
|
-
},
|
|
13094
13094
|
{
|
|
13095
13095
|
Component: TransferOwnership,
|
|
13096
13096
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13097
13097
|
},
|
|
13098
13098
|
{
|
|
13099
|
-
Component:
|
|
13100
|
-
path: "/draft-orders/:id/
|
|
13099
|
+
Component: SalesChannel,
|
|
13100
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13101
13101
|
}
|
|
13102
13102
|
]
|
|
13103
13103
|
}
|