@medusajs/draft-order 2.10.4-preview-20250929090207 → 2.10.4-preview-20250929120206
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 +375 -375
- package/.medusa/server/src/admin/index.mjs +375 -375
- package/package.json +16 -16
|
@@ -9567,31 +9567,10 @@ const ID = () => {
|
|
|
9567
9567
|
/* @__PURE__ */ jsx(Outlet, {})
|
|
9568
9568
|
] });
|
|
9569
9569
|
};
|
|
9570
|
-
const
|
|
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 = () => {
|
|
9570
|
+
const BillingAddress = () => {
|
|
9592
9571
|
const { id } = useParams();
|
|
9593
9572
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
9594
|
-
fields: "+
|
|
9573
|
+
fields: "+billing_address"
|
|
9595
9574
|
});
|
|
9596
9575
|
if (isError) {
|
|
9597
9576
|
throw error;
|
|
@@ -9599,24 +9578,34 @@ const Email = () => {
|
|
|
9599
9578
|
const isReady = !isPending && !!order;
|
|
9600
9579
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9601
9580
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
9602
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit
|
|
9603
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the
|
|
9581
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
|
|
9582
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
9604
9583
|
] }),
|
|
9605
|
-
isReady && /* @__PURE__ */ jsx(
|
|
9584
|
+
isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
|
|
9606
9585
|
] });
|
|
9607
9586
|
};
|
|
9608
|
-
const
|
|
9587
|
+
const BillingAddressForm = ({ order }) => {
|
|
9588
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
9609
9589
|
const form = useForm({
|
|
9610
9590
|
defaultValues: {
|
|
9611
|
-
|
|
9591
|
+
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
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) ?? ""
|
|
9612
9601
|
},
|
|
9613
|
-
resolver: zodResolver(schema$
|
|
9602
|
+
resolver: zodResolver(schema$5)
|
|
9614
9603
|
});
|
|
9615
9604
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9616
9605
|
const { handleSuccess } = useRouteModal();
|
|
9617
9606
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
9618
9607
|
await mutateAsync(
|
|
9619
|
-
{
|
|
9608
|
+
{ billing_address: data },
|
|
9620
9609
|
{
|
|
9621
9610
|
onSuccess: () => {
|
|
9622
9611
|
handleSuccess();
|
|
@@ -9633,18 +9622,132 @@ const EmailForm = ({ order }) => {
|
|
|
9633
9622
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
9634
9623
|
onSubmit,
|
|
9635
9624
|
children: [
|
|
9636
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */
|
|
9637
|
-
|
|
9638
|
-
|
|
9639
|
-
|
|
9640
|
-
|
|
9641
|
-
|
|
9642
|
-
/* @__PURE__ */
|
|
9643
|
-
|
|
9644
|
-
|
|
9645
|
-
|
|
9646
|
-
|
|
9647
|
-
|
|
9625
|
+
/* @__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: [
|
|
9626
|
+
/* @__PURE__ */ jsx(
|
|
9627
|
+
Form$2.Field,
|
|
9628
|
+
{
|
|
9629
|
+
control: form.control,
|
|
9630
|
+
name: "country_code",
|
|
9631
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9632
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
9633
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
9634
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
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
|
+
] }) }),
|
|
9648
9751
|
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9649
9752
|
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9650
9753
|
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
@@ -9653,6 +9756,25 @@ const EmailForm = ({ order }) => {
|
|
|
9653
9756
|
}
|
|
9654
9757
|
) });
|
|
9655
9758
|
};
|
|
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
|
+
};
|
|
9656
9778
|
const schema$4 = objectType({
|
|
9657
9779
|
email: stringType().email()
|
|
9658
9780
|
});
|
|
@@ -10980,49 +11102,117 @@ function getHasUneditableRows(metadata) {
|
|
|
10980
11102
|
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
10981
11103
|
);
|
|
10982
11104
|
}
|
|
10983
|
-
const
|
|
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
|
|
11000
|
-
});
|
|
11001
|
-
return { ...data, ...rest };
|
|
11002
|
-
};
|
|
11003
|
-
const Promotions = () => {
|
|
11105
|
+
const Email = () => {
|
|
11004
11106
|
const { id } = useParams();
|
|
11005
|
-
const {
|
|
11006
|
-
|
|
11007
|
-
|
|
11008
|
-
|
|
11009
|
-
|
|
11010
|
-
useInitiateOrderEdit({ preview });
|
|
11011
|
-
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11012
|
-
if (isPreviewError) {
|
|
11013
|
-
throw previewError;
|
|
11107
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
11108
|
+
fields: "+email"
|
|
11109
|
+
});
|
|
11110
|
+
if (isError) {
|
|
11111
|
+
throw error;
|
|
11014
11112
|
}
|
|
11015
|
-
const isReady = !!
|
|
11016
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, {
|
|
11017
|
-
/* @__PURE__ */
|
|
11018
|
-
|
|
11113
|
+
const isReady = !isPending && !!order;
|
|
11114
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11115
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11116
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
|
|
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 })
|
|
11019
11120
|
] });
|
|
11020
11121
|
};
|
|
11021
|
-
const
|
|
11022
|
-
const
|
|
11023
|
-
|
|
11024
|
-
|
|
11025
|
-
|
|
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 })
|
|
11209
|
+
] });
|
|
11210
|
+
};
|
|
11211
|
+
const PromotionForm = ({ preview }) => {
|
|
11212
|
+
const { items, shipping_methods } = preview;
|
|
11213
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
11214
|
+
const [comboboxValue, setComboboxValue] = useState("");
|
|
11215
|
+
const { handleSuccess } = useRouteModal();
|
|
11026
11216
|
const { mutateAsync: addPromotions, isPending: isAddingPromotions } = useDraftOrderAddPromotions(preview.id);
|
|
11027
11217
|
const promoIds = getPromotionIds(items, shipping_methods);
|
|
11028
11218
|
const { promotions, isPending, isError, error } = usePromotions(
|
|
@@ -11257,112 +11447,6 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11257
11447
|
}
|
|
11258
11448
|
return Array.from(promotionIds);
|
|
11259
11449
|
}
|
|
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
|
-
});
|
|
11366
11450
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11367
11451
|
const Shipping = () => {
|
|
11368
11452
|
var _a;
|
|
@@ -12646,37 +12730,33 @@ const Illustration = () => {
|
|
|
12646
12730
|
const schema$2 = objectType({
|
|
12647
12731
|
customer_id: stringType().min(1)
|
|
12648
12732
|
});
|
|
12649
|
-
const
|
|
12733
|
+
const SalesChannel = () => {
|
|
12650
12734
|
const { id } = useParams();
|
|
12651
|
-
const {
|
|
12652
|
-
|
|
12653
|
-
|
|
12735
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12736
|
+
id,
|
|
12737
|
+
{
|
|
12738
|
+
fields: "+sales_channel_id"
|
|
12739
|
+
},
|
|
12740
|
+
{
|
|
12741
|
+
enabled: !!id
|
|
12742
|
+
}
|
|
12743
|
+
);
|
|
12654
12744
|
if (isError) {
|
|
12655
12745
|
throw error;
|
|
12656
12746
|
}
|
|
12657
|
-
const
|
|
12747
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
12658
12748
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12659
12749
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12660
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit
|
|
12661
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", 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" }) })
|
|
12662
12752
|
] }),
|
|
12663
|
-
|
|
12753
|
+
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
12664
12754
|
] });
|
|
12665
12755
|
};
|
|
12666
|
-
const
|
|
12667
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12756
|
+
const SalesChannelForm = ({ order }) => {
|
|
12668
12757
|
const form = useForm({
|
|
12669
12758
|
defaultValues: {
|
|
12670
|
-
|
|
12671
|
-
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12672
|
-
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12673
|
-
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12674
|
-
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12675
|
-
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12676
|
-
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12677
|
-
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12678
|
-
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12679
|
-
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12759
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
12680
12760
|
},
|
|
12681
12761
|
resolver: zodResolver(schema$1)
|
|
12682
12762
|
});
|
|
@@ -12685,21 +12765,11 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12685
12765
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
12686
12766
|
await mutateAsync(
|
|
12687
12767
|
{
|
|
12688
|
-
|
|
12689
|
-
first_name: data.first_name,
|
|
12690
|
-
last_name: data.last_name,
|
|
12691
|
-
company: data.company,
|
|
12692
|
-
address_1: data.address_1,
|
|
12693
|
-
address_2: data.address_2,
|
|
12694
|
-
city: data.city,
|
|
12695
|
-
province: data.province,
|
|
12696
|
-
country_code: data.country_code,
|
|
12697
|
-
postal_code: data.postal_code,
|
|
12698
|
-
phone: data.phone
|
|
12699
|
-
}
|
|
12768
|
+
sales_channel_id: data.sales_channel_id
|
|
12700
12769
|
},
|
|
12701
12770
|
{
|
|
12702
12771
|
onSuccess: () => {
|
|
12772
|
+
toast.success("Sales channel updated");
|
|
12703
12773
|
handleSuccess();
|
|
12704
12774
|
},
|
|
12705
12775
|
onError: (error) => {
|
|
@@ -12714,132 +12784,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12714
12784
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
12715
12785
|
onSubmit,
|
|
12716
12786
|
children: [
|
|
12717
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */
|
|
12718
|
-
/* @__PURE__ */ jsx(
|
|
12719
|
-
Form$2.Field,
|
|
12720
|
-
{
|
|
12721
|
-
control: form.control,
|
|
12722
|
-
name: "country_code",
|
|
12723
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12724
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
12725
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
12726
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12727
|
-
] })
|
|
12728
|
-
}
|
|
12729
|
-
),
|
|
12730
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12731
|
-
/* @__PURE__ */ jsx(
|
|
12732
|
-
Form$2.Field,
|
|
12733
|
-
{
|
|
12734
|
-
control: form.control,
|
|
12735
|
-
name: "first_name",
|
|
12736
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12737
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
12738
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12739
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12740
|
-
] })
|
|
12741
|
-
}
|
|
12742
|
-
),
|
|
12743
|
-
/* @__PURE__ */ jsx(
|
|
12744
|
-
Form$2.Field,
|
|
12745
|
-
{
|
|
12746
|
-
control: form.control,
|
|
12747
|
-
name: "last_name",
|
|
12748
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12749
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
12750
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12751
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12752
|
-
] })
|
|
12753
|
-
}
|
|
12754
|
-
)
|
|
12755
|
-
] }),
|
|
12756
|
-
/* @__PURE__ */ jsx(
|
|
12757
|
-
Form$2.Field,
|
|
12758
|
-
{
|
|
12759
|
-
control: form.control,
|
|
12760
|
-
name: "company",
|
|
12761
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12762
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12763
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12764
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12765
|
-
] })
|
|
12766
|
-
}
|
|
12767
|
-
),
|
|
12768
|
-
/* @__PURE__ */ jsx(
|
|
12769
|
-
Form$2.Field,
|
|
12770
|
-
{
|
|
12771
|
-
control: form.control,
|
|
12772
|
-
name: "address_1",
|
|
12773
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12774
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
12775
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12776
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12777
|
-
] })
|
|
12778
|
-
}
|
|
12779
|
-
),
|
|
12780
|
-
/* @__PURE__ */ jsx(
|
|
12781
|
-
Form$2.Field,
|
|
12782
|
-
{
|
|
12783
|
-
control: form.control,
|
|
12784
|
-
name: "address_2",
|
|
12785
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12786
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12787
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12788
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12789
|
-
] })
|
|
12790
|
-
}
|
|
12791
|
-
),
|
|
12792
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12793
|
-
/* @__PURE__ */ jsx(
|
|
12794
|
-
Form$2.Field,
|
|
12795
|
-
{
|
|
12796
|
-
control: form.control,
|
|
12797
|
-
name: "postal_code",
|
|
12798
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12799
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
12800
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12801
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12802
|
-
] })
|
|
12803
|
-
}
|
|
12804
|
-
),
|
|
12805
|
-
/* @__PURE__ */ jsx(
|
|
12806
|
-
Form$2.Field,
|
|
12807
|
-
{
|
|
12808
|
-
control: form.control,
|
|
12809
|
-
name: "city",
|
|
12810
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12811
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
12812
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12813
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12814
|
-
] })
|
|
12815
|
-
}
|
|
12816
|
-
)
|
|
12817
|
-
] }),
|
|
12818
|
-
/* @__PURE__ */ jsx(
|
|
12819
|
-
Form$2.Field,
|
|
12820
|
-
{
|
|
12821
|
-
control: form.control,
|
|
12822
|
-
name: "province",
|
|
12823
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12824
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
12825
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12826
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12827
|
-
] })
|
|
12828
|
-
}
|
|
12829
|
-
),
|
|
12830
|
-
/* @__PURE__ */ jsx(
|
|
12831
|
-
Form$2.Field,
|
|
12832
|
-
{
|
|
12833
|
-
control: form.control,
|
|
12834
|
-
name: "phone",
|
|
12835
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12836
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
12837
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12838
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12839
|
-
] })
|
|
12840
|
-
}
|
|
12841
|
-
)
|
|
12842
|
-
] }) }),
|
|
12787
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12843
12788
|
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12844
12789
|
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12845
12790
|
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
@@ -12848,11 +12793,53 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12848
12793
|
}
|
|
12849
12794
|
) });
|
|
12850
12795
|
};
|
|
12851
|
-
const
|
|
12852
|
-
const
|
|
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
|
+
const schema$1 = objectType({
|
|
12837
|
+
sales_channel_id: stringType().min(1)
|
|
12838
|
+
});
|
|
12839
|
+
const ShippingAddress = () => {
|
|
12853
12840
|
const { id } = useParams();
|
|
12854
12841
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
12855
|
-
fields: "+
|
|
12842
|
+
fields: "+shipping_address"
|
|
12856
12843
|
});
|
|
12857
12844
|
if (isError) {
|
|
12858
12845
|
throw error;
|
|
@@ -12860,26 +12847,26 @@ const BillingAddress = () => {
|
|
|
12860
12847
|
const isReady = !isPending && !!order;
|
|
12861
12848
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12862
12849
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12863
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit
|
|
12864
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the
|
|
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" }) })
|
|
12865
12852
|
] }),
|
|
12866
|
-
isReady && /* @__PURE__ */ jsx(
|
|
12853
|
+
isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
|
|
12867
12854
|
] });
|
|
12868
12855
|
};
|
|
12869
|
-
const
|
|
12856
|
+
const ShippingAddressForm = ({ order }) => {
|
|
12870
12857
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12871
12858
|
const form = useForm({
|
|
12872
12859
|
defaultValues: {
|
|
12873
|
-
first_name: ((_a = order.
|
|
12874
|
-
last_name: ((_b = order.
|
|
12875
|
-
company: ((_c = order.
|
|
12876
|
-
address_1: ((_d = order.
|
|
12877
|
-
address_2: ((_e = order.
|
|
12878
|
-
city: ((_f = order.
|
|
12879
|
-
province: ((_g = order.
|
|
12880
|
-
country_code: ((_h = order.
|
|
12881
|
-
postal_code: ((_i = order.
|
|
12882
|
-
phone: ((_j = order.
|
|
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) ?? ""
|
|
12883
12870
|
},
|
|
12884
12871
|
resolver: zodResolver(schema)
|
|
12885
12872
|
});
|
|
@@ -12887,7 +12874,20 @@ const BillingAddressForm = ({ order }) => {
|
|
|
12887
12874
|
const { handleSuccess } = useRouteModal();
|
|
12888
12875
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
12889
12876
|
await mutateAsync(
|
|
12890
|
-
{
|
|
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
12891
|
{
|
|
12892
12892
|
onSuccess: () => {
|
|
12893
12893
|
handleSuccess();
|
|
@@ -13060,12 +13060,12 @@ const routeModule = {
|
|
|
13060
13060
|
loader,
|
|
13061
13061
|
children: [
|
|
13062
13062
|
{
|
|
13063
|
-
Component:
|
|
13064
|
-
path: "/draft-orders/:id/
|
|
13063
|
+
Component: BillingAddress,
|
|
13064
|
+
path: "/draft-orders/:id/billing-address"
|
|
13065
13065
|
},
|
|
13066
13066
|
{
|
|
13067
|
-
Component:
|
|
13068
|
-
path: "/draft-orders/:id/
|
|
13067
|
+
Component: CustomItems,
|
|
13068
|
+
path: "/draft-orders/:id/custom-items"
|
|
13069
13069
|
},
|
|
13070
13070
|
{
|
|
13071
13071
|
Component: Items,
|
|
@@ -13076,12 +13076,12 @@ const routeModule = {
|
|
|
13076
13076
|
path: "/draft-orders/:id/metadata"
|
|
13077
13077
|
},
|
|
13078
13078
|
{
|
|
13079
|
-
Component:
|
|
13080
|
-
path: "/draft-orders/:id/
|
|
13079
|
+
Component: Email,
|
|
13080
|
+
path: "/draft-orders/:id/email"
|
|
13081
13081
|
},
|
|
13082
13082
|
{
|
|
13083
|
-
Component:
|
|
13084
|
-
path: "/draft-orders/:id/
|
|
13083
|
+
Component: Promotions,
|
|
13084
|
+
path: "/draft-orders/:id/promotions"
|
|
13085
13085
|
},
|
|
13086
13086
|
{
|
|
13087
13087
|
Component: Shipping,
|
|
@@ -13092,12 +13092,12 @@ const routeModule = {
|
|
|
13092
13092
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13093
13093
|
},
|
|
13094
13094
|
{
|
|
13095
|
-
Component:
|
|
13096
|
-
path: "/draft-orders/:id/
|
|
13095
|
+
Component: SalesChannel,
|
|
13096
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13097
13097
|
},
|
|
13098
13098
|
{
|
|
13099
|
-
Component:
|
|
13100
|
-
path: "/draft-orders/:id/
|
|
13099
|
+
Component: ShippingAddress,
|
|
13100
|
+
path: "/draft-orders/:id/shipping-address"
|
|
13101
13101
|
}
|
|
13102
13102
|
]
|
|
13103
13103
|
}
|