@medusajs/draft-order 2.10.4-preview-20251005150154 → 2.10.4-preview-20251005210149
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 +310 -310
- package/.medusa/server/src/admin/index.mjs +310 -310
- package/package.json +16 -16
|
@@ -9778,6 +9778,74 @@ const CustomItemsForm = () => {
|
|
|
9778
9778
|
const schema$4 = objectType({
|
|
9779
9779
|
email: stringType().email()
|
|
9780
9780
|
});
|
|
9781
|
+
const Email = () => {
|
|
9782
|
+
const { id } = useParams();
|
|
9783
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
9784
|
+
fields: "+email"
|
|
9785
|
+
});
|
|
9786
|
+
if (isError) {
|
|
9787
|
+
throw error;
|
|
9788
|
+
}
|
|
9789
|
+
const isReady = !isPending && !!order;
|
|
9790
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9791
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
9792
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
|
|
9793
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
9794
|
+
] }),
|
|
9795
|
+
isReady && /* @__PURE__ */ jsx(EmailForm, { order })
|
|
9796
|
+
] });
|
|
9797
|
+
};
|
|
9798
|
+
const EmailForm = ({ order }) => {
|
|
9799
|
+
const form = useForm({
|
|
9800
|
+
defaultValues: {
|
|
9801
|
+
email: order.email ?? ""
|
|
9802
|
+
},
|
|
9803
|
+
resolver: zodResolver(schema$3)
|
|
9804
|
+
});
|
|
9805
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9806
|
+
const { handleSuccess } = useRouteModal();
|
|
9807
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
9808
|
+
await mutateAsync(
|
|
9809
|
+
{ email: data.email },
|
|
9810
|
+
{
|
|
9811
|
+
onSuccess: () => {
|
|
9812
|
+
handleSuccess();
|
|
9813
|
+
},
|
|
9814
|
+
onError: (error) => {
|
|
9815
|
+
toast.error(error.message);
|
|
9816
|
+
}
|
|
9817
|
+
}
|
|
9818
|
+
);
|
|
9819
|
+
});
|
|
9820
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
9821
|
+
KeyboundForm,
|
|
9822
|
+
{
|
|
9823
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
9824
|
+
onSubmit,
|
|
9825
|
+
children: [
|
|
9826
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
9827
|
+
Form$2.Field,
|
|
9828
|
+
{
|
|
9829
|
+
control: form.control,
|
|
9830
|
+
name: "email",
|
|
9831
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9832
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
|
|
9833
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9834
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9835
|
+
] })
|
|
9836
|
+
}
|
|
9837
|
+
) }),
|
|
9838
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9839
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9840
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9841
|
+
] }) })
|
|
9842
|
+
]
|
|
9843
|
+
}
|
|
9844
|
+
) });
|
|
9845
|
+
};
|
|
9846
|
+
const schema$3 = objectType({
|
|
9847
|
+
email: stringType().email()
|
|
9848
|
+
});
|
|
9781
9849
|
const NumberInput = forwardRef(
|
|
9782
9850
|
({
|
|
9783
9851
|
value,
|
|
@@ -10752,74 +10820,6 @@ const customItemSchema = objectType({
|
|
|
10752
10820
|
quantity: numberType(),
|
|
10753
10821
|
unit_price: unionType([numberType(), stringType()])
|
|
10754
10822
|
});
|
|
10755
|
-
const Email = () => {
|
|
10756
|
-
const { id } = useParams();
|
|
10757
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
10758
|
-
fields: "+email"
|
|
10759
|
-
});
|
|
10760
|
-
if (isError) {
|
|
10761
|
-
throw error;
|
|
10762
|
-
}
|
|
10763
|
-
const isReady = !isPending && !!order;
|
|
10764
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
10765
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
10766
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
|
|
10767
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
10768
|
-
] }),
|
|
10769
|
-
isReady && /* @__PURE__ */ jsx(EmailForm, { order })
|
|
10770
|
-
] });
|
|
10771
|
-
};
|
|
10772
|
-
const EmailForm = ({ order }) => {
|
|
10773
|
-
const form = useForm({
|
|
10774
|
-
defaultValues: {
|
|
10775
|
-
email: order.email ?? ""
|
|
10776
|
-
},
|
|
10777
|
-
resolver: zodResolver(schema$3)
|
|
10778
|
-
});
|
|
10779
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
10780
|
-
const { handleSuccess } = useRouteModal();
|
|
10781
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
10782
|
-
await mutateAsync(
|
|
10783
|
-
{ email: data.email },
|
|
10784
|
-
{
|
|
10785
|
-
onSuccess: () => {
|
|
10786
|
-
handleSuccess();
|
|
10787
|
-
},
|
|
10788
|
-
onError: (error) => {
|
|
10789
|
-
toast.error(error.message);
|
|
10790
|
-
}
|
|
10791
|
-
}
|
|
10792
|
-
);
|
|
10793
|
-
});
|
|
10794
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
10795
|
-
KeyboundForm,
|
|
10796
|
-
{
|
|
10797
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
10798
|
-
onSubmit,
|
|
10799
|
-
children: [
|
|
10800
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
10801
|
-
Form$2.Field,
|
|
10802
|
-
{
|
|
10803
|
-
control: form.control,
|
|
10804
|
-
name: "email",
|
|
10805
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
10806
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
|
|
10807
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
10808
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10809
|
-
] })
|
|
10810
|
-
}
|
|
10811
|
-
) }),
|
|
10812
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
10813
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
10814
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
10815
|
-
] }) })
|
|
10816
|
-
]
|
|
10817
|
-
}
|
|
10818
|
-
) });
|
|
10819
|
-
};
|
|
10820
|
-
const schema$3 = objectType({
|
|
10821
|
-
email: stringType().email()
|
|
10822
|
-
});
|
|
10823
10823
|
const InlineTip = forwardRef(
|
|
10824
10824
|
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
10825
10825
|
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
@@ -12360,60 +12360,44 @@ const CustomAmountField = ({
|
|
|
12360
12360
|
}
|
|
12361
12361
|
);
|
|
12362
12362
|
};
|
|
12363
|
-
const
|
|
12363
|
+
const TransferOwnership = () => {
|
|
12364
12364
|
const { id } = useParams();
|
|
12365
|
-
const {
|
|
12366
|
-
fields: "
|
|
12365
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
12366
|
+
fields: "id,customer_id,customer.*"
|
|
12367
12367
|
});
|
|
12368
12368
|
if (isError) {
|
|
12369
12369
|
throw error;
|
|
12370
12370
|
}
|
|
12371
|
-
const isReady = !isPending && !!
|
|
12371
|
+
const isReady = !isPending && !!draft_order;
|
|
12372
12372
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12373
12373
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12374
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "
|
|
12375
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "
|
|
12374
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Ownership" }) }),
|
|
12375
|
+
/* @__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" }) })
|
|
12376
12376
|
] }),
|
|
12377
|
-
isReady && /* @__PURE__ */ jsx(
|
|
12377
|
+
isReady && /* @__PURE__ */ jsx(TransferOwnershipForm, { order: draft_order })
|
|
12378
12378
|
] });
|
|
12379
12379
|
};
|
|
12380
|
-
const
|
|
12381
|
-
var _a, _b
|
|
12380
|
+
const TransferOwnershipForm = ({ order }) => {
|
|
12381
|
+
var _a, _b;
|
|
12382
12382
|
const form = useForm({
|
|
12383
12383
|
defaultValues: {
|
|
12384
|
-
|
|
12385
|
-
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12386
|
-
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12387
|
-
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12388
|
-
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12389
|
-
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12390
|
-
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12391
|
-
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12392
|
-
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12393
|
-
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12384
|
+
customer_id: order.customer_id || ""
|
|
12394
12385
|
},
|
|
12395
12386
|
resolver: zodResolver(schema$1)
|
|
12396
12387
|
});
|
|
12397
12388
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12398
12389
|
const { handleSuccess } = useRouteModal();
|
|
12390
|
+
const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
|
|
12391
|
+
const currentCustomer = order.customer ? {
|
|
12392
|
+
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
12393
|
+
value: order.customer.id
|
|
12394
|
+
} : null;
|
|
12399
12395
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
12400
12396
|
await mutateAsync(
|
|
12401
|
-
{
|
|
12402
|
-
shipping_address: {
|
|
12403
|
-
first_name: data.first_name,
|
|
12404
|
-
last_name: data.last_name,
|
|
12405
|
-
company: data.company,
|
|
12406
|
-
address_1: data.address_1,
|
|
12407
|
-
address_2: data.address_2,
|
|
12408
|
-
city: data.city,
|
|
12409
|
-
province: data.province,
|
|
12410
|
-
country_code: data.country_code,
|
|
12411
|
-
postal_code: data.postal_code,
|
|
12412
|
-
phone: data.phone
|
|
12413
|
-
}
|
|
12414
|
-
},
|
|
12397
|
+
{ customer_id: data.customer_id },
|
|
12415
12398
|
{
|
|
12416
12399
|
onSuccess: () => {
|
|
12400
|
+
toast.success("Customer updated");
|
|
12417
12401
|
handleSuccess();
|
|
12418
12402
|
},
|
|
12419
12403
|
onError: (error) => {
|
|
@@ -12428,210 +12412,23 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12428
12412
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
12429
12413
|
onSubmit,
|
|
12430
12414
|
children: [
|
|
12431
|
-
/* @__PURE__ */
|
|
12432
|
-
/* @__PURE__ */ jsx(
|
|
12433
|
-
|
|
12434
|
-
{
|
|
12435
|
-
|
|
12436
|
-
|
|
12437
|
-
|
|
12438
|
-
|
|
12439
|
-
|
|
12440
|
-
|
|
12441
|
-
|
|
12442
|
-
}
|
|
12443
|
-
),
|
|
12444
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12445
|
-
/* @__PURE__ */ jsx(
|
|
12446
|
-
Form$2.Field,
|
|
12447
|
-
{
|
|
12448
|
-
control: form.control,
|
|
12449
|
-
name: "first_name",
|
|
12450
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12451
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
12452
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12453
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12454
|
-
] })
|
|
12455
|
-
}
|
|
12456
|
-
),
|
|
12457
|
-
/* @__PURE__ */ jsx(
|
|
12458
|
-
Form$2.Field,
|
|
12459
|
-
{
|
|
12460
|
-
control: form.control,
|
|
12461
|
-
name: "last_name",
|
|
12462
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12463
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
12464
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12465
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12466
|
-
] })
|
|
12467
|
-
}
|
|
12468
|
-
)
|
|
12415
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
12416
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsx(Illustration, {}) }),
|
|
12417
|
+
currentCustomer && /* @__PURE__ */ jsxs("div", { className: "flex flex-col space-y-3", children: [
|
|
12418
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
12419
|
+
/* @__PURE__ */ jsx(Label$1, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
|
|
12420
|
+
/* @__PURE__ */ jsx(Hint$1, { children: "The customer that is currently associated with this draft order." })
|
|
12421
|
+
] }),
|
|
12422
|
+
/* @__PURE__ */ jsxs(Select, { disabled: true, value: currentCustomer.value, children: [
|
|
12423
|
+
/* @__PURE__ */ jsx(Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsx(Select.Value, {}) }),
|
|
12424
|
+
/* @__PURE__ */ jsx(Select.Content, { children: /* @__PURE__ */ jsx(Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
|
|
12425
|
+
] })
|
|
12469
12426
|
] }),
|
|
12470
12427
|
/* @__PURE__ */ jsx(
|
|
12471
|
-
|
|
12472
|
-
{
|
|
12473
|
-
control: form.control,
|
|
12474
|
-
name: "company",
|
|
12475
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12476
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12477
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12478
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12479
|
-
] })
|
|
12480
|
-
}
|
|
12481
|
-
),
|
|
12482
|
-
/* @__PURE__ */ jsx(
|
|
12483
|
-
Form$2.Field,
|
|
12428
|
+
CustomerField,
|
|
12484
12429
|
{
|
|
12485
12430
|
control: form.control,
|
|
12486
|
-
|
|
12487
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12488
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
12489
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12490
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12491
|
-
] })
|
|
12492
|
-
}
|
|
12493
|
-
),
|
|
12494
|
-
/* @__PURE__ */ jsx(
|
|
12495
|
-
Form$2.Field,
|
|
12496
|
-
{
|
|
12497
|
-
control: form.control,
|
|
12498
|
-
name: "address_2",
|
|
12499
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12500
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12501
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12502
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12503
|
-
] })
|
|
12504
|
-
}
|
|
12505
|
-
),
|
|
12506
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12507
|
-
/* @__PURE__ */ jsx(
|
|
12508
|
-
Form$2.Field,
|
|
12509
|
-
{
|
|
12510
|
-
control: form.control,
|
|
12511
|
-
name: "postal_code",
|
|
12512
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12513
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
12514
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12515
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12516
|
-
] })
|
|
12517
|
-
}
|
|
12518
|
-
),
|
|
12519
|
-
/* @__PURE__ */ jsx(
|
|
12520
|
-
Form$2.Field,
|
|
12521
|
-
{
|
|
12522
|
-
control: form.control,
|
|
12523
|
-
name: "city",
|
|
12524
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12525
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
12526
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12527
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12528
|
-
] })
|
|
12529
|
-
}
|
|
12530
|
-
)
|
|
12531
|
-
] }),
|
|
12532
|
-
/* @__PURE__ */ jsx(
|
|
12533
|
-
Form$2.Field,
|
|
12534
|
-
{
|
|
12535
|
-
control: form.control,
|
|
12536
|
-
name: "province",
|
|
12537
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12538
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
12539
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12540
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12541
|
-
] })
|
|
12542
|
-
}
|
|
12543
|
-
),
|
|
12544
|
-
/* @__PURE__ */ jsx(
|
|
12545
|
-
Form$2.Field,
|
|
12546
|
-
{
|
|
12547
|
-
control: form.control,
|
|
12548
|
-
name: "phone",
|
|
12549
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12550
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
12551
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12552
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12553
|
-
] })
|
|
12554
|
-
}
|
|
12555
|
-
)
|
|
12556
|
-
] }) }),
|
|
12557
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12558
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12559
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12560
|
-
] }) })
|
|
12561
|
-
]
|
|
12562
|
-
}
|
|
12563
|
-
) });
|
|
12564
|
-
};
|
|
12565
|
-
const schema$1 = addressSchema;
|
|
12566
|
-
const TransferOwnership = () => {
|
|
12567
|
-
const { id } = useParams();
|
|
12568
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
12569
|
-
fields: "id,customer_id,customer.*"
|
|
12570
|
-
});
|
|
12571
|
-
if (isError) {
|
|
12572
|
-
throw error;
|
|
12573
|
-
}
|
|
12574
|
-
const isReady = !isPending && !!draft_order;
|
|
12575
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12576
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12577
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Ownership" }) }),
|
|
12578
|
-
/* @__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" }) })
|
|
12579
|
-
] }),
|
|
12580
|
-
isReady && /* @__PURE__ */ jsx(TransferOwnershipForm, { order: draft_order })
|
|
12581
|
-
] });
|
|
12582
|
-
};
|
|
12583
|
-
const TransferOwnershipForm = ({ order }) => {
|
|
12584
|
-
var _a, _b;
|
|
12585
|
-
const form = useForm({
|
|
12586
|
-
defaultValues: {
|
|
12587
|
-
customer_id: order.customer_id || ""
|
|
12588
|
-
},
|
|
12589
|
-
resolver: zodResolver(schema)
|
|
12590
|
-
});
|
|
12591
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12592
|
-
const { handleSuccess } = useRouteModal();
|
|
12593
|
-
const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
|
|
12594
|
-
const currentCustomer = order.customer ? {
|
|
12595
|
-
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
12596
|
-
value: order.customer.id
|
|
12597
|
-
} : null;
|
|
12598
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12599
|
-
await mutateAsync(
|
|
12600
|
-
{ customer_id: data.customer_id },
|
|
12601
|
-
{
|
|
12602
|
-
onSuccess: () => {
|
|
12603
|
-
toast.success("Customer updated");
|
|
12604
|
-
handleSuccess();
|
|
12605
|
-
},
|
|
12606
|
-
onError: (error) => {
|
|
12607
|
-
toast.error(error.message);
|
|
12608
|
-
}
|
|
12609
|
-
}
|
|
12610
|
-
);
|
|
12611
|
-
});
|
|
12612
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12613
|
-
KeyboundForm,
|
|
12614
|
-
{
|
|
12615
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12616
|
-
onSubmit,
|
|
12617
|
-
children: [
|
|
12618
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
12619
|
-
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsx(Illustration, {}) }),
|
|
12620
|
-
currentCustomer && /* @__PURE__ */ jsxs("div", { className: "flex flex-col space-y-3", children: [
|
|
12621
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
12622
|
-
/* @__PURE__ */ jsx(Label$1, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
|
|
12623
|
-
/* @__PURE__ */ jsx(Hint$1, { children: "The customer that is currently associated with this draft order." })
|
|
12624
|
-
] }),
|
|
12625
|
-
/* @__PURE__ */ jsxs(Select, { disabled: true, value: currentCustomer.value, children: [
|
|
12626
|
-
/* @__PURE__ */ jsx(Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsx(Select.Value, {}) }),
|
|
12627
|
-
/* @__PURE__ */ jsx(Select.Content, { children: /* @__PURE__ */ jsx(Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
|
|
12628
|
-
] })
|
|
12629
|
-
] }),
|
|
12630
|
-
/* @__PURE__ */ jsx(
|
|
12631
|
-
CustomerField,
|
|
12632
|
-
{
|
|
12633
|
-
control: form.control,
|
|
12634
|
-
currentCustomerId: order.customer_id
|
|
12431
|
+
currentCustomerId: order.customer_id
|
|
12635
12432
|
}
|
|
12636
12433
|
)
|
|
12637
12434
|
] }),
|
|
@@ -13036,9 +12833,212 @@ const Illustration = () => {
|
|
|
13036
12833
|
}
|
|
13037
12834
|
);
|
|
13038
12835
|
};
|
|
13039
|
-
const schema = objectType({
|
|
12836
|
+
const schema$1 = objectType({
|
|
13040
12837
|
customer_id: stringType().min(1)
|
|
13041
12838
|
});
|
|
12839
|
+
const ShippingAddress = () => {
|
|
12840
|
+
const { id } = useParams();
|
|
12841
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
12842
|
+
fields: "+shipping_address"
|
|
12843
|
+
});
|
|
12844
|
+
if (isError) {
|
|
12845
|
+
throw error;
|
|
12846
|
+
}
|
|
12847
|
+
const isReady = !isPending && !!order;
|
|
12848
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12849
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12850
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
|
|
12851
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
12852
|
+
] }),
|
|
12853
|
+
isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
|
|
12854
|
+
] });
|
|
12855
|
+
};
|
|
12856
|
+
const ShippingAddressForm = ({ order }) => {
|
|
12857
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12858
|
+
const form = useForm({
|
|
12859
|
+
defaultValues: {
|
|
12860
|
+
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12861
|
+
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12862
|
+
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12863
|
+
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12864
|
+
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12865
|
+
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12866
|
+
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12867
|
+
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12868
|
+
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12869
|
+
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12870
|
+
},
|
|
12871
|
+
resolver: zodResolver(schema)
|
|
12872
|
+
});
|
|
12873
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12874
|
+
const { handleSuccess } = useRouteModal();
|
|
12875
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12876
|
+
await mutateAsync(
|
|
12877
|
+
{
|
|
12878
|
+
shipping_address: {
|
|
12879
|
+
first_name: data.first_name,
|
|
12880
|
+
last_name: data.last_name,
|
|
12881
|
+
company: data.company,
|
|
12882
|
+
address_1: data.address_1,
|
|
12883
|
+
address_2: data.address_2,
|
|
12884
|
+
city: data.city,
|
|
12885
|
+
province: data.province,
|
|
12886
|
+
country_code: data.country_code,
|
|
12887
|
+
postal_code: data.postal_code,
|
|
12888
|
+
phone: data.phone
|
|
12889
|
+
}
|
|
12890
|
+
},
|
|
12891
|
+
{
|
|
12892
|
+
onSuccess: () => {
|
|
12893
|
+
handleSuccess();
|
|
12894
|
+
},
|
|
12895
|
+
onError: (error) => {
|
|
12896
|
+
toast.error(error.message);
|
|
12897
|
+
}
|
|
12898
|
+
}
|
|
12899
|
+
);
|
|
12900
|
+
});
|
|
12901
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12902
|
+
KeyboundForm,
|
|
12903
|
+
{
|
|
12904
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12905
|
+
onSubmit,
|
|
12906
|
+
children: [
|
|
12907
|
+
/* @__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: [
|
|
12908
|
+
/* @__PURE__ */ jsx(
|
|
12909
|
+
Form$2.Field,
|
|
12910
|
+
{
|
|
12911
|
+
control: form.control,
|
|
12912
|
+
name: "country_code",
|
|
12913
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12914
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
12915
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
12916
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12917
|
+
] })
|
|
12918
|
+
}
|
|
12919
|
+
),
|
|
12920
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12921
|
+
/* @__PURE__ */ jsx(
|
|
12922
|
+
Form$2.Field,
|
|
12923
|
+
{
|
|
12924
|
+
control: form.control,
|
|
12925
|
+
name: "first_name",
|
|
12926
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12927
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
12928
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12929
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12930
|
+
] })
|
|
12931
|
+
}
|
|
12932
|
+
),
|
|
12933
|
+
/* @__PURE__ */ jsx(
|
|
12934
|
+
Form$2.Field,
|
|
12935
|
+
{
|
|
12936
|
+
control: form.control,
|
|
12937
|
+
name: "last_name",
|
|
12938
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12939
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
12940
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12941
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12942
|
+
] })
|
|
12943
|
+
}
|
|
12944
|
+
)
|
|
12945
|
+
] }),
|
|
12946
|
+
/* @__PURE__ */ jsx(
|
|
12947
|
+
Form$2.Field,
|
|
12948
|
+
{
|
|
12949
|
+
control: form.control,
|
|
12950
|
+
name: "company",
|
|
12951
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12952
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12953
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12954
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12955
|
+
] })
|
|
12956
|
+
}
|
|
12957
|
+
),
|
|
12958
|
+
/* @__PURE__ */ jsx(
|
|
12959
|
+
Form$2.Field,
|
|
12960
|
+
{
|
|
12961
|
+
control: form.control,
|
|
12962
|
+
name: "address_1",
|
|
12963
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12964
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
12965
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12966
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12967
|
+
] })
|
|
12968
|
+
}
|
|
12969
|
+
),
|
|
12970
|
+
/* @__PURE__ */ jsx(
|
|
12971
|
+
Form$2.Field,
|
|
12972
|
+
{
|
|
12973
|
+
control: form.control,
|
|
12974
|
+
name: "address_2",
|
|
12975
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12976
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12977
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12978
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12979
|
+
] })
|
|
12980
|
+
}
|
|
12981
|
+
),
|
|
12982
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12983
|
+
/* @__PURE__ */ jsx(
|
|
12984
|
+
Form$2.Field,
|
|
12985
|
+
{
|
|
12986
|
+
control: form.control,
|
|
12987
|
+
name: "postal_code",
|
|
12988
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12989
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
12990
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12991
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12992
|
+
] })
|
|
12993
|
+
}
|
|
12994
|
+
),
|
|
12995
|
+
/* @__PURE__ */ jsx(
|
|
12996
|
+
Form$2.Field,
|
|
12997
|
+
{
|
|
12998
|
+
control: form.control,
|
|
12999
|
+
name: "city",
|
|
13000
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13001
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
13002
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13003
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13004
|
+
] })
|
|
13005
|
+
}
|
|
13006
|
+
)
|
|
13007
|
+
] }),
|
|
13008
|
+
/* @__PURE__ */ jsx(
|
|
13009
|
+
Form$2.Field,
|
|
13010
|
+
{
|
|
13011
|
+
control: form.control,
|
|
13012
|
+
name: "province",
|
|
13013
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13014
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
13015
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13016
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13017
|
+
] })
|
|
13018
|
+
}
|
|
13019
|
+
),
|
|
13020
|
+
/* @__PURE__ */ jsx(
|
|
13021
|
+
Form$2.Field,
|
|
13022
|
+
{
|
|
13023
|
+
control: form.control,
|
|
13024
|
+
name: "phone",
|
|
13025
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13026
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
13027
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13028
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13029
|
+
] })
|
|
13030
|
+
}
|
|
13031
|
+
)
|
|
13032
|
+
] }) }),
|
|
13033
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13034
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
13035
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
13036
|
+
] }) })
|
|
13037
|
+
]
|
|
13038
|
+
}
|
|
13039
|
+
) });
|
|
13040
|
+
};
|
|
13041
|
+
const schema = addressSchema;
|
|
13042
13042
|
const widgetModule = { widgets: [] };
|
|
13043
13043
|
const routeModule = {
|
|
13044
13044
|
routes: [
|
|
@@ -13067,14 +13067,14 @@ const routeModule = {
|
|
|
13067
13067
|
Component: CustomItems,
|
|
13068
13068
|
path: "/draft-orders/:id/custom-items"
|
|
13069
13069
|
},
|
|
13070
|
-
{
|
|
13071
|
-
Component: Items,
|
|
13072
|
-
path: "/draft-orders/:id/items"
|
|
13073
|
-
},
|
|
13074
13070
|
{
|
|
13075
13071
|
Component: Email,
|
|
13076
13072
|
path: "/draft-orders/:id/email"
|
|
13077
13073
|
},
|
|
13074
|
+
{
|
|
13075
|
+
Component: Items,
|
|
13076
|
+
path: "/draft-orders/:id/items"
|
|
13077
|
+
},
|
|
13078
13078
|
{
|
|
13079
13079
|
Component: Metadata,
|
|
13080
13080
|
path: "/draft-orders/:id/metadata"
|
|
@@ -13091,13 +13091,13 @@ const routeModule = {
|
|
|
13091
13091
|
Component: Shipping,
|
|
13092
13092
|
path: "/draft-orders/:id/shipping"
|
|
13093
13093
|
},
|
|
13094
|
-
{
|
|
13095
|
-
Component: ShippingAddress,
|
|
13096
|
-
path: "/draft-orders/:id/shipping-address"
|
|
13097
|
-
},
|
|
13098
13094
|
{
|
|
13099
13095
|
Component: TransferOwnership,
|
|
13100
13096
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13097
|
+
},
|
|
13098
|
+
{
|
|
13099
|
+
Component: ShippingAddress,
|
|
13100
|
+
path: "/draft-orders/:id/shipping-address"
|
|
13101
13101
|
}
|
|
13102
13102
|
]
|
|
13103
13103
|
}
|