@medusajs/draft-order 2.10.4-preview-20250929120206 → 2.10.4-preview-20250929180201
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 +448 -448
- package/.medusa/server/src/admin/index.mjs +448 -448
- package/package.json +16 -16
|
@@ -9567,10 +9567,31 @@ const ID = () => {
|
|
|
9567
9567
|
/* @__PURE__ */ jsx(Outlet, {})
|
|
9568
9568
|
] });
|
|
9569
9569
|
};
|
|
9570
|
-
const
|
|
9570
|
+
const CustomItems = () => {
|
|
9571
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9572
|
+
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
9573
|
+
/* @__PURE__ */ jsx(CustomItemsForm, {})
|
|
9574
|
+
] });
|
|
9575
|
+
};
|
|
9576
|
+
const CustomItemsForm = () => {
|
|
9577
|
+
const form = useForm({
|
|
9578
|
+
resolver: zodResolver(schema$5)
|
|
9579
|
+
});
|
|
9580
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9581
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
9582
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9583
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9584
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
|
|
9585
|
+
] }) })
|
|
9586
|
+
] }) });
|
|
9587
|
+
};
|
|
9588
|
+
const schema$5 = objectType({
|
|
9589
|
+
email: stringType().email()
|
|
9590
|
+
});
|
|
9591
|
+
const Email = () => {
|
|
9571
9592
|
const { id } = useParams();
|
|
9572
9593
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
9573
|
-
fields: "+
|
|
9594
|
+
fields: "+email"
|
|
9574
9595
|
});
|
|
9575
9596
|
if (isError) {
|
|
9576
9597
|
throw error;
|
|
@@ -9578,34 +9599,24 @@ const BillingAddress = () => {
|
|
|
9578
9599
|
const isReady = !isPending && !!order;
|
|
9579
9600
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9580
9601
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
9581
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit
|
|
9582
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the
|
|
9602
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
|
|
9603
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
9583
9604
|
] }),
|
|
9584
|
-
isReady && /* @__PURE__ */ jsx(
|
|
9605
|
+
isReady && /* @__PURE__ */ jsx(EmailForm, { order })
|
|
9585
9606
|
] });
|
|
9586
9607
|
};
|
|
9587
|
-
const
|
|
9588
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
9608
|
+
const EmailForm = ({ order }) => {
|
|
9589
9609
|
const form = useForm({
|
|
9590
9610
|
defaultValues: {
|
|
9591
|
-
|
|
9592
|
-
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
9593
|
-
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
9594
|
-
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
9595
|
-
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
9596
|
-
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
9597
|
-
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
9598
|
-
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
9599
|
-
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9600
|
-
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9611
|
+
email: order.email ?? ""
|
|
9601
9612
|
},
|
|
9602
|
-
resolver: zodResolver(schema$
|
|
9613
|
+
resolver: zodResolver(schema$4)
|
|
9603
9614
|
});
|
|
9604
9615
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9605
9616
|
const { handleSuccess } = useRouteModal();
|
|
9606
9617
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
9607
9618
|
await mutateAsync(
|
|
9608
|
-
{
|
|
9619
|
+
{ email: data.email },
|
|
9609
9620
|
{
|
|
9610
9621
|
onSuccess: () => {
|
|
9611
9622
|
handleSuccess();
|
|
@@ -9622,132 +9633,18 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9622
9633
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
9623
9634
|
onSubmit,
|
|
9624
9635
|
children: [
|
|
9625
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */
|
|
9626
|
-
|
|
9627
|
-
|
|
9628
|
-
|
|
9629
|
-
|
|
9630
|
-
|
|
9631
|
-
|
|
9632
|
-
|
|
9633
|
-
|
|
9634
|
-
|
|
9635
|
-
|
|
9636
|
-
|
|
9637
|
-
),
|
|
9638
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9639
|
-
/* @__PURE__ */ jsx(
|
|
9640
|
-
Form$2.Field,
|
|
9641
|
-
{
|
|
9642
|
-
control: form.control,
|
|
9643
|
-
name: "first_name",
|
|
9644
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9645
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
9646
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9647
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9648
|
-
] })
|
|
9649
|
-
}
|
|
9650
|
-
),
|
|
9651
|
-
/* @__PURE__ */ jsx(
|
|
9652
|
-
Form$2.Field,
|
|
9653
|
-
{
|
|
9654
|
-
control: form.control,
|
|
9655
|
-
name: "last_name",
|
|
9656
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9657
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
9658
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9659
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9660
|
-
] })
|
|
9661
|
-
}
|
|
9662
|
-
)
|
|
9663
|
-
] }),
|
|
9664
|
-
/* @__PURE__ */ jsx(
|
|
9665
|
-
Form$2.Field,
|
|
9666
|
-
{
|
|
9667
|
-
control: form.control,
|
|
9668
|
-
name: "company",
|
|
9669
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9670
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
9671
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9672
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9673
|
-
] })
|
|
9674
|
-
}
|
|
9675
|
-
),
|
|
9676
|
-
/* @__PURE__ */ jsx(
|
|
9677
|
-
Form$2.Field,
|
|
9678
|
-
{
|
|
9679
|
-
control: form.control,
|
|
9680
|
-
name: "address_1",
|
|
9681
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9682
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
9683
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9684
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9685
|
-
] })
|
|
9686
|
-
}
|
|
9687
|
-
),
|
|
9688
|
-
/* @__PURE__ */ jsx(
|
|
9689
|
-
Form$2.Field,
|
|
9690
|
-
{
|
|
9691
|
-
control: form.control,
|
|
9692
|
-
name: "address_2",
|
|
9693
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9694
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
9695
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9696
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9697
|
-
] })
|
|
9698
|
-
}
|
|
9699
|
-
),
|
|
9700
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9701
|
-
/* @__PURE__ */ jsx(
|
|
9702
|
-
Form$2.Field,
|
|
9703
|
-
{
|
|
9704
|
-
control: form.control,
|
|
9705
|
-
name: "postal_code",
|
|
9706
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9707
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
9708
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9709
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9710
|
-
] })
|
|
9711
|
-
}
|
|
9712
|
-
),
|
|
9713
|
-
/* @__PURE__ */ jsx(
|
|
9714
|
-
Form$2.Field,
|
|
9715
|
-
{
|
|
9716
|
-
control: form.control,
|
|
9717
|
-
name: "city",
|
|
9718
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9719
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
9720
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9721
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9722
|
-
] })
|
|
9723
|
-
}
|
|
9724
|
-
)
|
|
9725
|
-
] }),
|
|
9726
|
-
/* @__PURE__ */ jsx(
|
|
9727
|
-
Form$2.Field,
|
|
9728
|
-
{
|
|
9729
|
-
control: form.control,
|
|
9730
|
-
name: "province",
|
|
9731
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9732
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
9733
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9734
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9735
|
-
] })
|
|
9736
|
-
}
|
|
9737
|
-
),
|
|
9738
|
-
/* @__PURE__ */ jsx(
|
|
9739
|
-
Form$2.Field,
|
|
9740
|
-
{
|
|
9741
|
-
control: form.control,
|
|
9742
|
-
name: "phone",
|
|
9743
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9744
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
9745
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9746
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9747
|
-
] })
|
|
9748
|
-
}
|
|
9749
|
-
)
|
|
9750
|
-
] }) }),
|
|
9636
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
9637
|
+
Form$2.Field,
|
|
9638
|
+
{
|
|
9639
|
+
control: form.control,
|
|
9640
|
+
name: "email",
|
|
9641
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9642
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
|
|
9643
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9644
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9645
|
+
] })
|
|
9646
|
+
}
|
|
9647
|
+
) }),
|
|
9751
9648
|
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9752
9649
|
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9753
9650
|
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
@@ -9756,25 +9653,6 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9756
9653
|
}
|
|
9757
9654
|
) });
|
|
9758
9655
|
};
|
|
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
9656
|
const schema$4 = objectType({
|
|
9779
9657
|
email: stringType().email()
|
|
9780
9658
|
});
|
|
@@ -11102,110 +10980,42 @@ function getHasUneditableRows(metadata) {
|
|
|
11102
10980
|
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
11103
10981
|
);
|
|
11104
10982
|
}
|
|
11105
|
-
const
|
|
11106
|
-
|
|
11107
|
-
|
|
11108
|
-
|
|
10983
|
+
const PROMOTION_QUERY_KEY = "promotions";
|
|
10984
|
+
const promotionsQueryKeys = {
|
|
10985
|
+
list: (query2) => [
|
|
10986
|
+
PROMOTION_QUERY_KEY,
|
|
10987
|
+
query2 ? query2 : void 0
|
|
10988
|
+
],
|
|
10989
|
+
detail: (id, query2) => [
|
|
10990
|
+
PROMOTION_QUERY_KEY,
|
|
10991
|
+
id,
|
|
10992
|
+
query2 ? query2 : void 0
|
|
10993
|
+
]
|
|
10994
|
+
};
|
|
10995
|
+
const usePromotions = (query2, options) => {
|
|
10996
|
+
const { data, ...rest } = useQuery({
|
|
10997
|
+
queryKey: promotionsQueryKeys.list(query2),
|
|
10998
|
+
queryFn: async () => sdk.admin.promotion.list(query2),
|
|
10999
|
+
...options
|
|
11109
11000
|
});
|
|
11110
|
-
|
|
11111
|
-
|
|
11001
|
+
return { ...data, ...rest };
|
|
11002
|
+
};
|
|
11003
|
+
const Promotions = () => {
|
|
11004
|
+
const { id } = useParams();
|
|
11005
|
+
const {
|
|
11006
|
+
order: preview,
|
|
11007
|
+
isError: isPreviewError,
|
|
11008
|
+
error: previewError
|
|
11009
|
+
} = useOrderPreview(id, void 0);
|
|
11010
|
+
useInitiateOrderEdit({ preview });
|
|
11011
|
+
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11012
|
+
if (isPreviewError) {
|
|
11013
|
+
throw previewError;
|
|
11112
11014
|
}
|
|
11113
|
-
const isReady =
|
|
11114
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11115
|
-
/* @__PURE__ */
|
|
11116
|
-
|
|
11117
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
11118
|
-
] }),
|
|
11119
|
-
isReady && /* @__PURE__ */ jsx(EmailForm, { order })
|
|
11120
|
-
] });
|
|
11121
|
-
};
|
|
11122
|
-
const EmailForm = ({ order }) => {
|
|
11123
|
-
const form = useForm({
|
|
11124
|
-
defaultValues: {
|
|
11125
|
-
email: order.email ?? ""
|
|
11126
|
-
},
|
|
11127
|
-
resolver: zodResolver(schema$3)
|
|
11128
|
-
});
|
|
11129
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11130
|
-
const { handleSuccess } = useRouteModal();
|
|
11131
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
11132
|
-
await mutateAsync(
|
|
11133
|
-
{ email: data.email },
|
|
11134
|
-
{
|
|
11135
|
-
onSuccess: () => {
|
|
11136
|
-
handleSuccess();
|
|
11137
|
-
},
|
|
11138
|
-
onError: (error) => {
|
|
11139
|
-
toast.error(error.message);
|
|
11140
|
-
}
|
|
11141
|
-
}
|
|
11142
|
-
);
|
|
11143
|
-
});
|
|
11144
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11145
|
-
KeyboundForm,
|
|
11146
|
-
{
|
|
11147
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
11148
|
-
onSubmit,
|
|
11149
|
-
children: [
|
|
11150
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
11151
|
-
Form$2.Field,
|
|
11152
|
-
{
|
|
11153
|
-
control: form.control,
|
|
11154
|
-
name: "email",
|
|
11155
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11156
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
|
|
11157
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11158
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11159
|
-
] })
|
|
11160
|
-
}
|
|
11161
|
-
) }),
|
|
11162
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11163
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11164
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11165
|
-
] }) })
|
|
11166
|
-
]
|
|
11167
|
-
}
|
|
11168
|
-
) });
|
|
11169
|
-
};
|
|
11170
|
-
const schema$3 = objectType({
|
|
11171
|
-
email: stringType().email()
|
|
11172
|
-
});
|
|
11173
|
-
const PROMOTION_QUERY_KEY = "promotions";
|
|
11174
|
-
const promotionsQueryKeys = {
|
|
11175
|
-
list: (query2) => [
|
|
11176
|
-
PROMOTION_QUERY_KEY,
|
|
11177
|
-
query2 ? query2 : void 0
|
|
11178
|
-
],
|
|
11179
|
-
detail: (id, query2) => [
|
|
11180
|
-
PROMOTION_QUERY_KEY,
|
|
11181
|
-
id,
|
|
11182
|
-
query2 ? query2 : void 0
|
|
11183
|
-
]
|
|
11184
|
-
};
|
|
11185
|
-
const usePromotions = (query2, options) => {
|
|
11186
|
-
const { data, ...rest } = useQuery({
|
|
11187
|
-
queryKey: promotionsQueryKeys.list(query2),
|
|
11188
|
-
queryFn: async () => sdk.admin.promotion.list(query2),
|
|
11189
|
-
...options
|
|
11190
|
-
});
|
|
11191
|
-
return { ...data, ...rest };
|
|
11192
|
-
};
|
|
11193
|
-
const Promotions = () => {
|
|
11194
|
-
const { id } = useParams();
|
|
11195
|
-
const {
|
|
11196
|
-
order: preview,
|
|
11197
|
-
isError: isPreviewError,
|
|
11198
|
-
error: previewError
|
|
11199
|
-
} = useOrderPreview(id, void 0);
|
|
11200
|
-
useInitiateOrderEdit({ preview });
|
|
11201
|
-
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11202
|
-
if (isPreviewError) {
|
|
11203
|
-
throw previewError;
|
|
11204
|
-
}
|
|
11205
|
-
const isReady = !!preview;
|
|
11206
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { onClose: onCancel, children: [
|
|
11207
|
-
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Promotions" }) }) }),
|
|
11208
|
-
isReady && /* @__PURE__ */ jsx(PromotionForm, { preview })
|
|
11015
|
+
const isReady = !!preview;
|
|
11016
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { onClose: onCancel, children: [
|
|
11017
|
+
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Promotions" }) }) }),
|
|
11018
|
+
isReady && /* @__PURE__ */ jsx(PromotionForm, { preview })
|
|
11209
11019
|
] });
|
|
11210
11020
|
};
|
|
11211
11021
|
const PromotionForm = ({ preview }) => {
|
|
@@ -11447,6 +11257,112 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11447
11257
|
}
|
|
11448
11258
|
return Array.from(promotionIds);
|
|
11449
11259
|
}
|
|
11260
|
+
const SalesChannel = () => {
|
|
11261
|
+
const { id } = useParams();
|
|
11262
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11263
|
+
id,
|
|
11264
|
+
{
|
|
11265
|
+
fields: "+sales_channel_id"
|
|
11266
|
+
},
|
|
11267
|
+
{
|
|
11268
|
+
enabled: !!id
|
|
11269
|
+
}
|
|
11270
|
+
);
|
|
11271
|
+
if (isError) {
|
|
11272
|
+
throw error;
|
|
11273
|
+
}
|
|
11274
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
11275
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11276
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11277
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
11278
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
11279
|
+
] }),
|
|
11280
|
+
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
11281
|
+
] });
|
|
11282
|
+
};
|
|
11283
|
+
const SalesChannelForm = ({ order }) => {
|
|
11284
|
+
const form = useForm({
|
|
11285
|
+
defaultValues: {
|
|
11286
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
11287
|
+
},
|
|
11288
|
+
resolver: zodResolver(schema$3)
|
|
11289
|
+
});
|
|
11290
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11291
|
+
const { handleSuccess } = useRouteModal();
|
|
11292
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11293
|
+
await mutateAsync(
|
|
11294
|
+
{
|
|
11295
|
+
sales_channel_id: data.sales_channel_id
|
|
11296
|
+
},
|
|
11297
|
+
{
|
|
11298
|
+
onSuccess: () => {
|
|
11299
|
+
toast.success("Sales channel updated");
|
|
11300
|
+
handleSuccess();
|
|
11301
|
+
},
|
|
11302
|
+
onError: (error) => {
|
|
11303
|
+
toast.error(error.message);
|
|
11304
|
+
}
|
|
11305
|
+
}
|
|
11306
|
+
);
|
|
11307
|
+
});
|
|
11308
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11309
|
+
KeyboundForm,
|
|
11310
|
+
{
|
|
11311
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11312
|
+
onSubmit,
|
|
11313
|
+
children: [
|
|
11314
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11315
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11316
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11317
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11318
|
+
] }) })
|
|
11319
|
+
]
|
|
11320
|
+
}
|
|
11321
|
+
) });
|
|
11322
|
+
};
|
|
11323
|
+
const SalesChannelField = ({ control, order }) => {
|
|
11324
|
+
const salesChannels = useComboboxData({
|
|
11325
|
+
queryFn: async (params) => {
|
|
11326
|
+
return await sdk.admin.salesChannel.list(params);
|
|
11327
|
+
},
|
|
11328
|
+
queryKey: ["sales-channels"],
|
|
11329
|
+
getOptions: (data) => {
|
|
11330
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
11331
|
+
label: salesChannel.name,
|
|
11332
|
+
value: salesChannel.id
|
|
11333
|
+
}));
|
|
11334
|
+
},
|
|
11335
|
+
defaultValue: order.sales_channel_id || void 0
|
|
11336
|
+
});
|
|
11337
|
+
return /* @__PURE__ */ jsx(
|
|
11338
|
+
Form$2.Field,
|
|
11339
|
+
{
|
|
11340
|
+
control,
|
|
11341
|
+
name: "sales_channel_id",
|
|
11342
|
+
render: ({ field }) => {
|
|
11343
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11344
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11345
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
11346
|
+
Combobox,
|
|
11347
|
+
{
|
|
11348
|
+
options: salesChannels.options,
|
|
11349
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
11350
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11351
|
+
searchValue: salesChannels.searchValue,
|
|
11352
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11353
|
+
placeholder: "Select sales channel",
|
|
11354
|
+
...field
|
|
11355
|
+
}
|
|
11356
|
+
) }),
|
|
11357
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11358
|
+
] });
|
|
11359
|
+
}
|
|
11360
|
+
}
|
|
11361
|
+
);
|
|
11362
|
+
};
|
|
11363
|
+
const schema$3 = objectType({
|
|
11364
|
+
sales_channel_id: stringType().min(1)
|
|
11365
|
+
});
|
|
11450
11366
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11451
11367
|
const Shipping = () => {
|
|
11452
11368
|
var _a;
|
|
@@ -12254,44 +12170,60 @@ const CustomAmountField = ({
|
|
|
12254
12170
|
}
|
|
12255
12171
|
);
|
|
12256
12172
|
};
|
|
12257
|
-
const
|
|
12173
|
+
const ShippingAddress = () => {
|
|
12258
12174
|
const { id } = useParams();
|
|
12259
|
-
const {
|
|
12260
|
-
fields: "
|
|
12175
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
12176
|
+
fields: "+shipping_address"
|
|
12261
12177
|
});
|
|
12262
12178
|
if (isError) {
|
|
12263
12179
|
throw error;
|
|
12264
12180
|
}
|
|
12265
|
-
const isReady = !isPending && !!
|
|
12181
|
+
const isReady = !isPending && !!order;
|
|
12266
12182
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12267
12183
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12268
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "
|
|
12269
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "
|
|
12184
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
|
|
12185
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
12270
12186
|
] }),
|
|
12271
|
-
isReady && /* @__PURE__ */ jsx(
|
|
12187
|
+
isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
|
|
12272
12188
|
] });
|
|
12273
12189
|
};
|
|
12274
|
-
const
|
|
12275
|
-
var _a, _b;
|
|
12190
|
+
const ShippingAddressForm = ({ order }) => {
|
|
12191
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12276
12192
|
const form = useForm({
|
|
12277
12193
|
defaultValues: {
|
|
12278
|
-
|
|
12194
|
+
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12195
|
+
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12196
|
+
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12197
|
+
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12198
|
+
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12199
|
+
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12200
|
+
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12201
|
+
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12202
|
+
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12203
|
+
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12279
12204
|
},
|
|
12280
12205
|
resolver: zodResolver(schema$2)
|
|
12281
12206
|
});
|
|
12282
12207
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12283
12208
|
const { handleSuccess } = useRouteModal();
|
|
12284
|
-
const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
|
|
12285
|
-
const currentCustomer = order.customer ? {
|
|
12286
|
-
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
12287
|
-
value: order.customer.id
|
|
12288
|
-
} : null;
|
|
12289
12209
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
12290
12210
|
await mutateAsync(
|
|
12291
|
-
{
|
|
12211
|
+
{
|
|
12212
|
+
shipping_address: {
|
|
12213
|
+
first_name: data.first_name,
|
|
12214
|
+
last_name: data.last_name,
|
|
12215
|
+
company: data.company,
|
|
12216
|
+
address_1: data.address_1,
|
|
12217
|
+
address_2: data.address_2,
|
|
12218
|
+
city: data.city,
|
|
12219
|
+
province: data.province,
|
|
12220
|
+
country_code: data.country_code,
|
|
12221
|
+
postal_code: data.postal_code,
|
|
12222
|
+
phone: data.phone
|
|
12223
|
+
}
|
|
12224
|
+
},
|
|
12292
12225
|
{
|
|
12293
12226
|
onSuccess: () => {
|
|
12294
|
-
toast.success("Customer updated");
|
|
12295
12227
|
handleSuccess();
|
|
12296
12228
|
},
|
|
12297
12229
|
onError: (error) => {
|
|
@@ -12306,23 +12238,210 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12306
12238
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
12307
12239
|
onSubmit,
|
|
12308
12240
|
children: [
|
|
12309
|
-
/* @__PURE__ */
|
|
12310
|
-
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsx(Illustration, {}) }),
|
|
12311
|
-
currentCustomer && /* @__PURE__ */ jsxs("div", { className: "flex flex-col space-y-3", children: [
|
|
12312
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
12313
|
-
/* @__PURE__ */ jsx(Label$1, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
|
|
12314
|
-
/* @__PURE__ */ jsx(Hint$1, { children: "The customer that is currently associated with this draft order." })
|
|
12315
|
-
] }),
|
|
12316
|
-
/* @__PURE__ */ jsxs(Select, { disabled: true, value: currentCustomer.value, children: [
|
|
12317
|
-
/* @__PURE__ */ jsx(Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsx(Select.Value, {}) }),
|
|
12318
|
-
/* @__PURE__ */ jsx(Select.Content, { children: /* @__PURE__ */ jsx(Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
|
|
12319
|
-
] })
|
|
12320
|
-
] }),
|
|
12241
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
|
|
12321
12242
|
/* @__PURE__ */ jsx(
|
|
12322
|
-
|
|
12243
|
+
Form$2.Field,
|
|
12323
12244
|
{
|
|
12324
12245
|
control: form.control,
|
|
12325
|
-
|
|
12246
|
+
name: "country_code",
|
|
12247
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12248
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
12249
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
12250
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12251
|
+
] })
|
|
12252
|
+
}
|
|
12253
|
+
),
|
|
12254
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12255
|
+
/* @__PURE__ */ jsx(
|
|
12256
|
+
Form$2.Field,
|
|
12257
|
+
{
|
|
12258
|
+
control: form.control,
|
|
12259
|
+
name: "first_name",
|
|
12260
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12261
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
12262
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12263
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12264
|
+
] })
|
|
12265
|
+
}
|
|
12266
|
+
),
|
|
12267
|
+
/* @__PURE__ */ jsx(
|
|
12268
|
+
Form$2.Field,
|
|
12269
|
+
{
|
|
12270
|
+
control: form.control,
|
|
12271
|
+
name: "last_name",
|
|
12272
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12273
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
12274
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12275
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12276
|
+
] })
|
|
12277
|
+
}
|
|
12278
|
+
)
|
|
12279
|
+
] }),
|
|
12280
|
+
/* @__PURE__ */ jsx(
|
|
12281
|
+
Form$2.Field,
|
|
12282
|
+
{
|
|
12283
|
+
control: form.control,
|
|
12284
|
+
name: "company",
|
|
12285
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12286
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12287
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12288
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12289
|
+
] })
|
|
12290
|
+
}
|
|
12291
|
+
),
|
|
12292
|
+
/* @__PURE__ */ jsx(
|
|
12293
|
+
Form$2.Field,
|
|
12294
|
+
{
|
|
12295
|
+
control: form.control,
|
|
12296
|
+
name: "address_1",
|
|
12297
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12298
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
12299
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12300
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12301
|
+
] })
|
|
12302
|
+
}
|
|
12303
|
+
),
|
|
12304
|
+
/* @__PURE__ */ jsx(
|
|
12305
|
+
Form$2.Field,
|
|
12306
|
+
{
|
|
12307
|
+
control: form.control,
|
|
12308
|
+
name: "address_2",
|
|
12309
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12310
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12311
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12312
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12313
|
+
] })
|
|
12314
|
+
}
|
|
12315
|
+
),
|
|
12316
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12317
|
+
/* @__PURE__ */ jsx(
|
|
12318
|
+
Form$2.Field,
|
|
12319
|
+
{
|
|
12320
|
+
control: form.control,
|
|
12321
|
+
name: "postal_code",
|
|
12322
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12323
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
12324
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12325
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12326
|
+
] })
|
|
12327
|
+
}
|
|
12328
|
+
),
|
|
12329
|
+
/* @__PURE__ */ jsx(
|
|
12330
|
+
Form$2.Field,
|
|
12331
|
+
{
|
|
12332
|
+
control: form.control,
|
|
12333
|
+
name: "city",
|
|
12334
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12335
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
12336
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12337
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12338
|
+
] })
|
|
12339
|
+
}
|
|
12340
|
+
)
|
|
12341
|
+
] }),
|
|
12342
|
+
/* @__PURE__ */ jsx(
|
|
12343
|
+
Form$2.Field,
|
|
12344
|
+
{
|
|
12345
|
+
control: form.control,
|
|
12346
|
+
name: "province",
|
|
12347
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12348
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
12349
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12350
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12351
|
+
] })
|
|
12352
|
+
}
|
|
12353
|
+
),
|
|
12354
|
+
/* @__PURE__ */ jsx(
|
|
12355
|
+
Form$2.Field,
|
|
12356
|
+
{
|
|
12357
|
+
control: form.control,
|
|
12358
|
+
name: "phone",
|
|
12359
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12360
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
12361
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12362
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12363
|
+
] })
|
|
12364
|
+
}
|
|
12365
|
+
)
|
|
12366
|
+
] }) }),
|
|
12367
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12368
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12369
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12370
|
+
] }) })
|
|
12371
|
+
]
|
|
12372
|
+
}
|
|
12373
|
+
) });
|
|
12374
|
+
};
|
|
12375
|
+
const schema$2 = addressSchema;
|
|
12376
|
+
const TransferOwnership = () => {
|
|
12377
|
+
const { id } = useParams();
|
|
12378
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
12379
|
+
fields: "id,customer_id,customer.*"
|
|
12380
|
+
});
|
|
12381
|
+
if (isError) {
|
|
12382
|
+
throw error;
|
|
12383
|
+
}
|
|
12384
|
+
const isReady = !isPending && !!draft_order;
|
|
12385
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12386
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12387
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Ownership" }) }),
|
|
12388
|
+
/* @__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" }) })
|
|
12389
|
+
] }),
|
|
12390
|
+
isReady && /* @__PURE__ */ jsx(TransferOwnershipForm, { order: draft_order })
|
|
12391
|
+
] });
|
|
12392
|
+
};
|
|
12393
|
+
const TransferOwnershipForm = ({ order }) => {
|
|
12394
|
+
var _a, _b;
|
|
12395
|
+
const form = useForm({
|
|
12396
|
+
defaultValues: {
|
|
12397
|
+
customer_id: order.customer_id || ""
|
|
12398
|
+
},
|
|
12399
|
+
resolver: zodResolver(schema$1)
|
|
12400
|
+
});
|
|
12401
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12402
|
+
const { handleSuccess } = useRouteModal();
|
|
12403
|
+
const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
|
|
12404
|
+
const currentCustomer = order.customer ? {
|
|
12405
|
+
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
12406
|
+
value: order.customer.id
|
|
12407
|
+
} : null;
|
|
12408
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12409
|
+
await mutateAsync(
|
|
12410
|
+
{ customer_id: data.customer_id },
|
|
12411
|
+
{
|
|
12412
|
+
onSuccess: () => {
|
|
12413
|
+
toast.success("Customer updated");
|
|
12414
|
+
handleSuccess();
|
|
12415
|
+
},
|
|
12416
|
+
onError: (error) => {
|
|
12417
|
+
toast.error(error.message);
|
|
12418
|
+
}
|
|
12419
|
+
}
|
|
12420
|
+
);
|
|
12421
|
+
});
|
|
12422
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12423
|
+
KeyboundForm,
|
|
12424
|
+
{
|
|
12425
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12426
|
+
onSubmit,
|
|
12427
|
+
children: [
|
|
12428
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
12429
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsx(Illustration, {}) }),
|
|
12430
|
+
currentCustomer && /* @__PURE__ */ jsxs("div", { className: "flex flex-col space-y-3", children: [
|
|
12431
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
12432
|
+
/* @__PURE__ */ jsx(Label$1, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
|
|
12433
|
+
/* @__PURE__ */ jsx(Hint$1, { children: "The customer that is currently associated with this draft order." })
|
|
12434
|
+
] }),
|
|
12435
|
+
/* @__PURE__ */ jsxs(Select, { disabled: true, value: currentCustomer.value, children: [
|
|
12436
|
+
/* @__PURE__ */ jsx(Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsx(Select.Value, {}) }),
|
|
12437
|
+
/* @__PURE__ */ jsx(Select.Content, { children: /* @__PURE__ */ jsx(Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
|
|
12438
|
+
] })
|
|
12439
|
+
] }),
|
|
12440
|
+
/* @__PURE__ */ jsx(
|
|
12441
|
+
CustomerField,
|
|
12442
|
+
{
|
|
12443
|
+
control: form.control,
|
|
12444
|
+
currentCustomerId: order.customer_id
|
|
12326
12445
|
}
|
|
12327
12446
|
)
|
|
12328
12447
|
] }),
|
|
@@ -12727,119 +12846,13 @@ const Illustration = () => {
|
|
|
12727
12846
|
}
|
|
12728
12847
|
);
|
|
12729
12848
|
};
|
|
12730
|
-
const schema$2 = objectType({
|
|
12731
|
-
customer_id: stringType().min(1)
|
|
12732
|
-
});
|
|
12733
|
-
const SalesChannel = () => {
|
|
12734
|
-
const { id } = useParams();
|
|
12735
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12736
|
-
id,
|
|
12737
|
-
{
|
|
12738
|
-
fields: "+sales_channel_id"
|
|
12739
|
-
},
|
|
12740
|
-
{
|
|
12741
|
-
enabled: !!id
|
|
12742
|
-
}
|
|
12743
|
-
);
|
|
12744
|
-
if (isError) {
|
|
12745
|
-
throw error;
|
|
12746
|
-
}
|
|
12747
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
12748
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12749
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12750
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
12751
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
12752
|
-
] }),
|
|
12753
|
-
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
12754
|
-
] });
|
|
12755
|
-
};
|
|
12756
|
-
const SalesChannelForm = ({ order }) => {
|
|
12757
|
-
const form = useForm({
|
|
12758
|
-
defaultValues: {
|
|
12759
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
12760
|
-
},
|
|
12761
|
-
resolver: zodResolver(schema$1)
|
|
12762
|
-
});
|
|
12763
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12764
|
-
const { handleSuccess } = useRouteModal();
|
|
12765
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12766
|
-
await mutateAsync(
|
|
12767
|
-
{
|
|
12768
|
-
sales_channel_id: data.sales_channel_id
|
|
12769
|
-
},
|
|
12770
|
-
{
|
|
12771
|
-
onSuccess: () => {
|
|
12772
|
-
toast.success("Sales channel updated");
|
|
12773
|
-
handleSuccess();
|
|
12774
|
-
},
|
|
12775
|
-
onError: (error) => {
|
|
12776
|
-
toast.error(error.message);
|
|
12777
|
-
}
|
|
12778
|
-
}
|
|
12779
|
-
);
|
|
12780
|
-
});
|
|
12781
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12782
|
-
KeyboundForm,
|
|
12783
|
-
{
|
|
12784
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12785
|
-
onSubmit,
|
|
12786
|
-
children: [
|
|
12787
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12788
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12789
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12790
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12791
|
-
] }) })
|
|
12792
|
-
]
|
|
12793
|
-
}
|
|
12794
|
-
) });
|
|
12795
|
-
};
|
|
12796
|
-
const SalesChannelField = ({ control, order }) => {
|
|
12797
|
-
const salesChannels = useComboboxData({
|
|
12798
|
-
queryFn: async (params) => {
|
|
12799
|
-
return await sdk.admin.salesChannel.list(params);
|
|
12800
|
-
},
|
|
12801
|
-
queryKey: ["sales-channels"],
|
|
12802
|
-
getOptions: (data) => {
|
|
12803
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
12804
|
-
label: salesChannel.name,
|
|
12805
|
-
value: salesChannel.id
|
|
12806
|
-
}));
|
|
12807
|
-
},
|
|
12808
|
-
defaultValue: order.sales_channel_id || void 0
|
|
12809
|
-
});
|
|
12810
|
-
return /* @__PURE__ */ jsx(
|
|
12811
|
-
Form$2.Field,
|
|
12812
|
-
{
|
|
12813
|
-
control,
|
|
12814
|
-
name: "sales_channel_id",
|
|
12815
|
-
render: ({ field }) => {
|
|
12816
|
-
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12817
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
12818
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
12819
|
-
Combobox,
|
|
12820
|
-
{
|
|
12821
|
-
options: salesChannels.options,
|
|
12822
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
12823
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
12824
|
-
searchValue: salesChannels.searchValue,
|
|
12825
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
12826
|
-
placeholder: "Select sales channel",
|
|
12827
|
-
...field
|
|
12828
|
-
}
|
|
12829
|
-
) }),
|
|
12830
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12831
|
-
] });
|
|
12832
|
-
}
|
|
12833
|
-
}
|
|
12834
|
-
);
|
|
12835
|
-
};
|
|
12836
12849
|
const schema$1 = objectType({
|
|
12837
|
-
|
|
12850
|
+
customer_id: stringType().min(1)
|
|
12838
12851
|
});
|
|
12839
|
-
const
|
|
12852
|
+
const BillingAddress = () => {
|
|
12840
12853
|
const { id } = useParams();
|
|
12841
12854
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
12842
|
-
fields: "+
|
|
12855
|
+
fields: "+billing_address"
|
|
12843
12856
|
});
|
|
12844
12857
|
if (isError) {
|
|
12845
12858
|
throw error;
|
|
@@ -12847,26 +12860,26 @@ const ShippingAddress = () => {
|
|
|
12847
12860
|
const isReady = !isPending && !!order;
|
|
12848
12861
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12849
12862
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12850
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit
|
|
12851
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the
|
|
12863
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
|
|
12864
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
12852
12865
|
] }),
|
|
12853
|
-
isReady && /* @__PURE__ */ jsx(
|
|
12866
|
+
isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
|
|
12854
12867
|
] });
|
|
12855
12868
|
};
|
|
12856
|
-
const
|
|
12869
|
+
const BillingAddressForm = ({ order }) => {
|
|
12857
12870
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12858
12871
|
const form = useForm({
|
|
12859
12872
|
defaultValues: {
|
|
12860
|
-
first_name: ((_a = order.
|
|
12861
|
-
last_name: ((_b = order.
|
|
12862
|
-
company: ((_c = order.
|
|
12863
|
-
address_1: ((_d = order.
|
|
12864
|
-
address_2: ((_e = order.
|
|
12865
|
-
city: ((_f = order.
|
|
12866
|
-
province: ((_g = order.
|
|
12867
|
-
country_code: ((_h = order.
|
|
12868
|
-
postal_code: ((_i = order.
|
|
12869
|
-
phone: ((_j = order.
|
|
12873
|
+
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12874
|
+
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12875
|
+
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
12876
|
+
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12877
|
+
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12878
|
+
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
12879
|
+
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
12880
|
+
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12881
|
+
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12882
|
+
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
12870
12883
|
},
|
|
12871
12884
|
resolver: zodResolver(schema)
|
|
12872
12885
|
});
|
|
@@ -12874,20 +12887,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12874
12887
|
const { handleSuccess } = useRouteModal();
|
|
12875
12888
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
12876
12889
|
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
|
-
},
|
|
12890
|
+
{ billing_address: data },
|
|
12891
12891
|
{
|
|
12892
12892
|
onSuccess: () => {
|
|
12893
12893
|
handleSuccess();
|
|
@@ -13059,14 +13059,14 @@ const routeModule = {
|
|
|
13059
13059
|
handle,
|
|
13060
13060
|
loader,
|
|
13061
13061
|
children: [
|
|
13062
|
-
{
|
|
13063
|
-
Component: BillingAddress,
|
|
13064
|
-
path: "/draft-orders/:id/billing-address"
|
|
13065
|
-
},
|
|
13066
13062
|
{
|
|
13067
13063
|
Component: CustomItems,
|
|
13068
13064
|
path: "/draft-orders/:id/custom-items"
|
|
13069
13065
|
},
|
|
13066
|
+
{
|
|
13067
|
+
Component: Email,
|
|
13068
|
+
path: "/draft-orders/:id/email"
|
|
13069
|
+
},
|
|
13070
13070
|
{
|
|
13071
13071
|
Component: Items,
|
|
13072
13072
|
path: "/draft-orders/:id/items"
|
|
@@ -13075,29 +13075,29 @@ const routeModule = {
|
|
|
13075
13075
|
Component: Metadata,
|
|
13076
13076
|
path: "/draft-orders/:id/metadata"
|
|
13077
13077
|
},
|
|
13078
|
-
{
|
|
13079
|
-
Component: Email,
|
|
13080
|
-
path: "/draft-orders/:id/email"
|
|
13081
|
-
},
|
|
13082
13078
|
{
|
|
13083
13079
|
Component: Promotions,
|
|
13084
13080
|
path: "/draft-orders/:id/promotions"
|
|
13085
13081
|
},
|
|
13082
|
+
{
|
|
13083
|
+
Component: SalesChannel,
|
|
13084
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13085
|
+
},
|
|
13086
13086
|
{
|
|
13087
13087
|
Component: Shipping,
|
|
13088
13088
|
path: "/draft-orders/:id/shipping"
|
|
13089
13089
|
},
|
|
13090
13090
|
{
|
|
13091
|
-
Component:
|
|
13092
|
-
path: "/draft-orders/:id/
|
|
13091
|
+
Component: ShippingAddress,
|
|
13092
|
+
path: "/draft-orders/:id/shipping-address"
|
|
13093
13093
|
},
|
|
13094
13094
|
{
|
|
13095
|
-
Component:
|
|
13096
|
-
path: "/draft-orders/:id/
|
|
13095
|
+
Component: TransferOwnership,
|
|
13096
|
+
path: "/draft-orders/:id/transfer-ownership"
|
|
13097
13097
|
},
|
|
13098
13098
|
{
|
|
13099
|
-
Component:
|
|
13100
|
-
path: "/draft-orders/:id/
|
|
13099
|
+
Component: BillingAddress,
|
|
13100
|
+
path: "/draft-orders/:id/billing-address"
|
|
13101
13101
|
}
|
|
13102
13102
|
]
|
|
13103
13103
|
}
|