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