@medusajs/draft-order 2.10.0-preview-20250827210153 → 2.10.0-preview-20250828031543
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 +457 -457
- package/.medusa/server/src/admin/index.mjs +457 -457
- package/package.json +18 -18
|
@@ -9554,6 +9554,196 @@ const ID = () => {
|
|
|
9554
9554
|
/* @__PURE__ */ jsx(Outlet, {})
|
|
9555
9555
|
] });
|
|
9556
9556
|
};
|
|
9557
|
+
const BillingAddress = () => {
|
|
9558
|
+
const { id } = useParams();
|
|
9559
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
9560
|
+
fields: "+billing_address"
|
|
9561
|
+
});
|
|
9562
|
+
if (isError) {
|
|
9563
|
+
throw error;
|
|
9564
|
+
}
|
|
9565
|
+
const isReady = !isPending && !!order;
|
|
9566
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9567
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
9568
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
|
|
9569
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
9570
|
+
] }),
|
|
9571
|
+
isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
|
|
9572
|
+
] });
|
|
9573
|
+
};
|
|
9574
|
+
const BillingAddressForm = ({ order }) => {
|
|
9575
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
9576
|
+
const form = useForm({
|
|
9577
|
+
defaultValues: {
|
|
9578
|
+
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
9579
|
+
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
9580
|
+
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
9581
|
+
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
9582
|
+
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
9583
|
+
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
9584
|
+
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
9585
|
+
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
9586
|
+
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9587
|
+
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9588
|
+
},
|
|
9589
|
+
resolver: zodResolver(schema$5)
|
|
9590
|
+
});
|
|
9591
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9592
|
+
const { handleSuccess } = useRouteModal();
|
|
9593
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
9594
|
+
await mutateAsync(
|
|
9595
|
+
{ billing_address: data },
|
|
9596
|
+
{
|
|
9597
|
+
onSuccess: () => {
|
|
9598
|
+
handleSuccess();
|
|
9599
|
+
},
|
|
9600
|
+
onError: (error) => {
|
|
9601
|
+
toast.error(error.message);
|
|
9602
|
+
}
|
|
9603
|
+
}
|
|
9604
|
+
);
|
|
9605
|
+
});
|
|
9606
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
9607
|
+
KeyboundForm,
|
|
9608
|
+
{
|
|
9609
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
9610
|
+
onSubmit,
|
|
9611
|
+
children: [
|
|
9612
|
+
/* @__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: [
|
|
9613
|
+
/* @__PURE__ */ jsx(
|
|
9614
|
+
Form$2.Field,
|
|
9615
|
+
{
|
|
9616
|
+
control: form.control,
|
|
9617
|
+
name: "country_code",
|
|
9618
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9619
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
9620
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
9621
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9622
|
+
] })
|
|
9623
|
+
}
|
|
9624
|
+
),
|
|
9625
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9626
|
+
/* @__PURE__ */ jsx(
|
|
9627
|
+
Form$2.Field,
|
|
9628
|
+
{
|
|
9629
|
+
control: form.control,
|
|
9630
|
+
name: "first_name",
|
|
9631
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9632
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
9633
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9634
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9635
|
+
] })
|
|
9636
|
+
}
|
|
9637
|
+
),
|
|
9638
|
+
/* @__PURE__ */ jsx(
|
|
9639
|
+
Form$2.Field,
|
|
9640
|
+
{
|
|
9641
|
+
control: form.control,
|
|
9642
|
+
name: "last_name",
|
|
9643
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9644
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
9645
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9646
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9647
|
+
] })
|
|
9648
|
+
}
|
|
9649
|
+
)
|
|
9650
|
+
] }),
|
|
9651
|
+
/* @__PURE__ */ jsx(
|
|
9652
|
+
Form$2.Field,
|
|
9653
|
+
{
|
|
9654
|
+
control: form.control,
|
|
9655
|
+
name: "company",
|
|
9656
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9657
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
9658
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9659
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9660
|
+
] })
|
|
9661
|
+
}
|
|
9662
|
+
),
|
|
9663
|
+
/* @__PURE__ */ jsx(
|
|
9664
|
+
Form$2.Field,
|
|
9665
|
+
{
|
|
9666
|
+
control: form.control,
|
|
9667
|
+
name: "address_1",
|
|
9668
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9669
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
9670
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9671
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9672
|
+
] })
|
|
9673
|
+
}
|
|
9674
|
+
),
|
|
9675
|
+
/* @__PURE__ */ jsx(
|
|
9676
|
+
Form$2.Field,
|
|
9677
|
+
{
|
|
9678
|
+
control: form.control,
|
|
9679
|
+
name: "address_2",
|
|
9680
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9681
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
9682
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9683
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9684
|
+
] })
|
|
9685
|
+
}
|
|
9686
|
+
),
|
|
9687
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9688
|
+
/* @__PURE__ */ jsx(
|
|
9689
|
+
Form$2.Field,
|
|
9690
|
+
{
|
|
9691
|
+
control: form.control,
|
|
9692
|
+
name: "postal_code",
|
|
9693
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9694
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
9695
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9696
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9697
|
+
] })
|
|
9698
|
+
}
|
|
9699
|
+
),
|
|
9700
|
+
/* @__PURE__ */ jsx(
|
|
9701
|
+
Form$2.Field,
|
|
9702
|
+
{
|
|
9703
|
+
control: form.control,
|
|
9704
|
+
name: "city",
|
|
9705
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9706
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
9707
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9708
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9709
|
+
] })
|
|
9710
|
+
}
|
|
9711
|
+
)
|
|
9712
|
+
] }),
|
|
9713
|
+
/* @__PURE__ */ jsx(
|
|
9714
|
+
Form$2.Field,
|
|
9715
|
+
{
|
|
9716
|
+
control: form.control,
|
|
9717
|
+
name: "province",
|
|
9718
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9719
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
9720
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9721
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9722
|
+
] })
|
|
9723
|
+
}
|
|
9724
|
+
),
|
|
9725
|
+
/* @__PURE__ */ jsx(
|
|
9726
|
+
Form$2.Field,
|
|
9727
|
+
{
|
|
9728
|
+
control: form.control,
|
|
9729
|
+
name: "phone",
|
|
9730
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9731
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
9732
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9733
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9734
|
+
] })
|
|
9735
|
+
}
|
|
9736
|
+
)
|
|
9737
|
+
] }) }),
|
|
9738
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9739
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9740
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9741
|
+
] }) })
|
|
9742
|
+
]
|
|
9743
|
+
}
|
|
9744
|
+
) });
|
|
9745
|
+
};
|
|
9746
|
+
const schema$5 = addressSchema;
|
|
9557
9747
|
const CustomItems = () => {
|
|
9558
9748
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9559
9749
|
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
@@ -9562,7 +9752,7 @@ const CustomItems = () => {
|
|
|
9562
9752
|
};
|
|
9563
9753
|
const CustomItemsForm = () => {
|
|
9564
9754
|
const form = useForm({
|
|
9565
|
-
resolver: zodResolver(schema$
|
|
9755
|
+
resolver: zodResolver(schema$4)
|
|
9566
9756
|
});
|
|
9567
9757
|
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9568
9758
|
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
@@ -9572,7 +9762,7 @@ const CustomItemsForm = () => {
|
|
|
9572
9762
|
] }) })
|
|
9573
9763
|
] }) });
|
|
9574
9764
|
};
|
|
9575
|
-
const schema$
|
|
9765
|
+
const schema$4 = objectType({
|
|
9576
9766
|
email: stringType().email()
|
|
9577
9767
|
});
|
|
9578
9768
|
const Email = () => {
|
|
@@ -9597,7 +9787,7 @@ const EmailForm = ({ order }) => {
|
|
|
9597
9787
|
defaultValues: {
|
|
9598
9788
|
email: order.email ?? ""
|
|
9599
9789
|
},
|
|
9600
|
-
resolver: zodResolver(schema$
|
|
9790
|
+
resolver: zodResolver(schema$3)
|
|
9601
9791
|
});
|
|
9602
9792
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9603
9793
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9640,7 +9830,7 @@ const EmailForm = ({ order }) => {
|
|
|
9640
9830
|
}
|
|
9641
9831
|
) });
|
|
9642
9832
|
};
|
|
9643
|
-
const schema$
|
|
9833
|
+
const schema$3 = objectType({
|
|
9644
9834
|
email: stringType().email()
|
|
9645
9835
|
});
|
|
9646
9836
|
const NumberInput = forwardRef(
|
|
@@ -10967,232 +11157,42 @@ function getHasUneditableRows(metadata) {
|
|
|
10967
11157
|
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
10968
11158
|
);
|
|
10969
11159
|
}
|
|
10970
|
-
const
|
|
10971
|
-
|
|
10972
|
-
|
|
10973
|
-
|
|
11160
|
+
const PROMOTION_QUERY_KEY = "promotions";
|
|
11161
|
+
const promotionsQueryKeys = {
|
|
11162
|
+
list: (query2) => [
|
|
11163
|
+
PROMOTION_QUERY_KEY,
|
|
11164
|
+
query2 ? query2 : void 0
|
|
11165
|
+
],
|
|
11166
|
+
detail: (id, query2) => [
|
|
11167
|
+
PROMOTION_QUERY_KEY,
|
|
11168
|
+
id,
|
|
11169
|
+
query2 ? query2 : void 0
|
|
11170
|
+
]
|
|
11171
|
+
};
|
|
11172
|
+
const usePromotions = (query2, options) => {
|
|
11173
|
+
const { data, ...rest } = useQuery({
|
|
11174
|
+
queryKey: promotionsQueryKeys.list(query2),
|
|
11175
|
+
queryFn: async () => sdk.admin.promotion.list(query2),
|
|
11176
|
+
...options
|
|
10974
11177
|
});
|
|
10975
|
-
|
|
10976
|
-
|
|
11178
|
+
return { ...data, ...rest };
|
|
11179
|
+
};
|
|
11180
|
+
const Promotions = () => {
|
|
11181
|
+
const { id } = useParams();
|
|
11182
|
+
const {
|
|
11183
|
+
order: preview,
|
|
11184
|
+
isError: isPreviewError,
|
|
11185
|
+
error: previewError
|
|
11186
|
+
} = useOrderPreview(id, void 0);
|
|
11187
|
+
useInitiateOrderEdit({ preview });
|
|
11188
|
+
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11189
|
+
if (isPreviewError) {
|
|
11190
|
+
throw previewError;
|
|
10977
11191
|
}
|
|
10978
|
-
const isReady =
|
|
10979
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
10980
|
-
/* @__PURE__ */
|
|
10981
|
-
|
|
10982
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
10983
|
-
] }),
|
|
10984
|
-
isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
|
|
10985
|
-
] });
|
|
10986
|
-
};
|
|
10987
|
-
const BillingAddressForm = ({ order }) => {
|
|
10988
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
10989
|
-
const form = useForm({
|
|
10990
|
-
defaultValues: {
|
|
10991
|
-
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
10992
|
-
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
10993
|
-
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
10994
|
-
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
10995
|
-
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
10996
|
-
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
10997
|
-
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
10998
|
-
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
10999
|
-
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
11000
|
-
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
11001
|
-
},
|
|
11002
|
-
resolver: zodResolver(schema$3)
|
|
11003
|
-
});
|
|
11004
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11005
|
-
const { handleSuccess } = useRouteModal();
|
|
11006
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
11007
|
-
await mutateAsync(
|
|
11008
|
-
{ billing_address: data },
|
|
11009
|
-
{
|
|
11010
|
-
onSuccess: () => {
|
|
11011
|
-
handleSuccess();
|
|
11012
|
-
},
|
|
11013
|
-
onError: (error) => {
|
|
11014
|
-
toast.error(error.message);
|
|
11015
|
-
}
|
|
11016
|
-
}
|
|
11017
|
-
);
|
|
11018
|
-
});
|
|
11019
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11020
|
-
KeyboundForm,
|
|
11021
|
-
{
|
|
11022
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
11023
|
-
onSubmit,
|
|
11024
|
-
children: [
|
|
11025
|
-
/* @__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: [
|
|
11026
|
-
/* @__PURE__ */ jsx(
|
|
11027
|
-
Form$2.Field,
|
|
11028
|
-
{
|
|
11029
|
-
control: form.control,
|
|
11030
|
-
name: "country_code",
|
|
11031
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11032
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
11033
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
11034
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11035
|
-
] })
|
|
11036
|
-
}
|
|
11037
|
-
),
|
|
11038
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11039
|
-
/* @__PURE__ */ jsx(
|
|
11040
|
-
Form$2.Field,
|
|
11041
|
-
{
|
|
11042
|
-
control: form.control,
|
|
11043
|
-
name: "first_name",
|
|
11044
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11045
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
11046
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11047
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11048
|
-
] })
|
|
11049
|
-
}
|
|
11050
|
-
),
|
|
11051
|
-
/* @__PURE__ */ jsx(
|
|
11052
|
-
Form$2.Field,
|
|
11053
|
-
{
|
|
11054
|
-
control: form.control,
|
|
11055
|
-
name: "last_name",
|
|
11056
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11057
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
11058
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11059
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11060
|
-
] })
|
|
11061
|
-
}
|
|
11062
|
-
)
|
|
11063
|
-
] }),
|
|
11064
|
-
/* @__PURE__ */ jsx(
|
|
11065
|
-
Form$2.Field,
|
|
11066
|
-
{
|
|
11067
|
-
control: form.control,
|
|
11068
|
-
name: "company",
|
|
11069
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11070
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
11071
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11072
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11073
|
-
] })
|
|
11074
|
-
}
|
|
11075
|
-
),
|
|
11076
|
-
/* @__PURE__ */ jsx(
|
|
11077
|
-
Form$2.Field,
|
|
11078
|
-
{
|
|
11079
|
-
control: form.control,
|
|
11080
|
-
name: "address_1",
|
|
11081
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11082
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
11083
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11084
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11085
|
-
] })
|
|
11086
|
-
}
|
|
11087
|
-
),
|
|
11088
|
-
/* @__PURE__ */ jsx(
|
|
11089
|
-
Form$2.Field,
|
|
11090
|
-
{
|
|
11091
|
-
control: form.control,
|
|
11092
|
-
name: "address_2",
|
|
11093
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11094
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
11095
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11096
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11097
|
-
] })
|
|
11098
|
-
}
|
|
11099
|
-
),
|
|
11100
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11101
|
-
/* @__PURE__ */ jsx(
|
|
11102
|
-
Form$2.Field,
|
|
11103
|
-
{
|
|
11104
|
-
control: form.control,
|
|
11105
|
-
name: "postal_code",
|
|
11106
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11107
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
11108
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11109
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11110
|
-
] })
|
|
11111
|
-
}
|
|
11112
|
-
),
|
|
11113
|
-
/* @__PURE__ */ jsx(
|
|
11114
|
-
Form$2.Field,
|
|
11115
|
-
{
|
|
11116
|
-
control: form.control,
|
|
11117
|
-
name: "city",
|
|
11118
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11119
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
11120
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11121
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11122
|
-
] })
|
|
11123
|
-
}
|
|
11124
|
-
)
|
|
11125
|
-
] }),
|
|
11126
|
-
/* @__PURE__ */ jsx(
|
|
11127
|
-
Form$2.Field,
|
|
11128
|
-
{
|
|
11129
|
-
control: form.control,
|
|
11130
|
-
name: "province",
|
|
11131
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11132
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
11133
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11134
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11135
|
-
] })
|
|
11136
|
-
}
|
|
11137
|
-
),
|
|
11138
|
-
/* @__PURE__ */ jsx(
|
|
11139
|
-
Form$2.Field,
|
|
11140
|
-
{
|
|
11141
|
-
control: form.control,
|
|
11142
|
-
name: "phone",
|
|
11143
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11144
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
11145
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11146
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11147
|
-
] })
|
|
11148
|
-
}
|
|
11149
|
-
)
|
|
11150
|
-
] }) }),
|
|
11151
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11152
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11153
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11154
|
-
] }) })
|
|
11155
|
-
]
|
|
11156
|
-
}
|
|
11157
|
-
) });
|
|
11158
|
-
};
|
|
11159
|
-
const schema$3 = addressSchema;
|
|
11160
|
-
const PROMOTION_QUERY_KEY = "promotions";
|
|
11161
|
-
const promotionsQueryKeys = {
|
|
11162
|
-
list: (query2) => [
|
|
11163
|
-
PROMOTION_QUERY_KEY,
|
|
11164
|
-
query2 ? query2 : void 0
|
|
11165
|
-
],
|
|
11166
|
-
detail: (id, query2) => [
|
|
11167
|
-
PROMOTION_QUERY_KEY,
|
|
11168
|
-
id,
|
|
11169
|
-
query2 ? query2 : void 0
|
|
11170
|
-
]
|
|
11171
|
-
};
|
|
11172
|
-
const usePromotions = (query2, options) => {
|
|
11173
|
-
const { data, ...rest } = useQuery({
|
|
11174
|
-
queryKey: promotionsQueryKeys.list(query2),
|
|
11175
|
-
queryFn: async () => sdk.admin.promotion.list(query2),
|
|
11176
|
-
...options
|
|
11177
|
-
});
|
|
11178
|
-
return { ...data, ...rest };
|
|
11179
|
-
};
|
|
11180
|
-
const Promotions = () => {
|
|
11181
|
-
const { id } = useParams();
|
|
11182
|
-
const {
|
|
11183
|
-
order: preview,
|
|
11184
|
-
isError: isPreviewError,
|
|
11185
|
-
error: previewError
|
|
11186
|
-
} = useOrderPreview(id, void 0);
|
|
11187
|
-
useInitiateOrderEdit({ preview });
|
|
11188
|
-
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11189
|
-
if (isPreviewError) {
|
|
11190
|
-
throw previewError;
|
|
11191
|
-
}
|
|
11192
|
-
const isReady = !!preview;
|
|
11193
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { onClose: onCancel, children: [
|
|
11194
|
-
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Promotions" }) }) }),
|
|
11195
|
-
isReady && /* @__PURE__ */ jsx(PromotionForm, { preview })
|
|
11192
|
+
const isReady = !!preview;
|
|
11193
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { onClose: onCancel, children: [
|
|
11194
|
+
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Promotions" }) }) }),
|
|
11195
|
+
isReady && /* @__PURE__ */ jsx(PromotionForm, { preview })
|
|
11196
11196
|
] });
|
|
11197
11197
|
};
|
|
11198
11198
|
const PromotionForm = ({ preview }) => {
|
|
@@ -12347,247 +12347,44 @@ const CustomAmountField = ({
|
|
|
12347
12347
|
}
|
|
12348
12348
|
);
|
|
12349
12349
|
};
|
|
12350
|
-
const
|
|
12350
|
+
const TransferOwnership = () => {
|
|
12351
12351
|
const { id } = useParams();
|
|
12352
|
-
const {
|
|
12353
|
-
fields: "
|
|
12352
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
12353
|
+
fields: "id,customer_id,customer.*"
|
|
12354
12354
|
});
|
|
12355
12355
|
if (isError) {
|
|
12356
12356
|
throw error;
|
|
12357
12357
|
}
|
|
12358
|
-
const isReady = !isPending && !!
|
|
12358
|
+
const isReady = !isPending && !!draft_order;
|
|
12359
12359
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12360
12360
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12361
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "
|
|
12362
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "
|
|
12361
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Ownership" }) }),
|
|
12362
|
+
/* @__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" }) })
|
|
12363
12363
|
] }),
|
|
12364
|
-
isReady && /* @__PURE__ */ jsx(
|
|
12364
|
+
isReady && /* @__PURE__ */ jsx(TransferOwnershipForm, { order: draft_order })
|
|
12365
12365
|
] });
|
|
12366
12366
|
};
|
|
12367
|
-
const
|
|
12368
|
-
var _a, _b
|
|
12367
|
+
const TransferOwnershipForm = ({ order }) => {
|
|
12368
|
+
var _a, _b;
|
|
12369
12369
|
const form = useForm({
|
|
12370
12370
|
defaultValues: {
|
|
12371
|
-
|
|
12372
|
-
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12373
|
-
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12374
|
-
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12375
|
-
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12376
|
-
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12377
|
-
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12378
|
-
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12379
|
-
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12380
|
-
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12371
|
+
customer_id: order.customer_id || ""
|
|
12381
12372
|
},
|
|
12382
12373
|
resolver: zodResolver(schema$1)
|
|
12383
12374
|
});
|
|
12384
12375
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12385
12376
|
const { handleSuccess } = useRouteModal();
|
|
12377
|
+
const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
|
|
12378
|
+
const currentCustomer = order.customer ? {
|
|
12379
|
+
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
12380
|
+
value: order.customer.id
|
|
12381
|
+
} : null;
|
|
12386
12382
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
12387
12383
|
await mutateAsync(
|
|
12388
|
-
{
|
|
12389
|
-
shipping_address: {
|
|
12390
|
-
first_name: data.first_name,
|
|
12391
|
-
last_name: data.last_name,
|
|
12392
|
-
company: data.company,
|
|
12393
|
-
address_1: data.address_1,
|
|
12394
|
-
address_2: data.address_2,
|
|
12395
|
-
city: data.city,
|
|
12396
|
-
province: data.province,
|
|
12397
|
-
country_code: data.country_code,
|
|
12398
|
-
postal_code: data.postal_code,
|
|
12399
|
-
phone: data.phone
|
|
12400
|
-
}
|
|
12401
|
-
},
|
|
12384
|
+
{ customer_id: data.customer_id },
|
|
12402
12385
|
{
|
|
12403
12386
|
onSuccess: () => {
|
|
12404
|
-
|
|
12405
|
-
},
|
|
12406
|
-
onError: (error) => {
|
|
12407
|
-
toast.error(error.message);
|
|
12408
|
-
}
|
|
12409
|
-
}
|
|
12410
|
-
);
|
|
12411
|
-
});
|
|
12412
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12413
|
-
KeyboundForm,
|
|
12414
|
-
{
|
|
12415
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12416
|
-
onSubmit,
|
|
12417
|
-
children: [
|
|
12418
|
-
/* @__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: [
|
|
12419
|
-
/* @__PURE__ */ jsx(
|
|
12420
|
-
Form$2.Field,
|
|
12421
|
-
{
|
|
12422
|
-
control: form.control,
|
|
12423
|
-
name: "country_code",
|
|
12424
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12425
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
12426
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
12427
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12428
|
-
] })
|
|
12429
|
-
}
|
|
12430
|
-
),
|
|
12431
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12432
|
-
/* @__PURE__ */ jsx(
|
|
12433
|
-
Form$2.Field,
|
|
12434
|
-
{
|
|
12435
|
-
control: form.control,
|
|
12436
|
-
name: "first_name",
|
|
12437
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12438
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
12439
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12440
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12441
|
-
] })
|
|
12442
|
-
}
|
|
12443
|
-
),
|
|
12444
|
-
/* @__PURE__ */ jsx(
|
|
12445
|
-
Form$2.Field,
|
|
12446
|
-
{
|
|
12447
|
-
control: form.control,
|
|
12448
|
-
name: "last_name",
|
|
12449
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12450
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
12451
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12452
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12453
|
-
] })
|
|
12454
|
-
}
|
|
12455
|
-
)
|
|
12456
|
-
] }),
|
|
12457
|
-
/* @__PURE__ */ jsx(
|
|
12458
|
-
Form$2.Field,
|
|
12459
|
-
{
|
|
12460
|
-
control: form.control,
|
|
12461
|
-
name: "company",
|
|
12462
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12463
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12464
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12465
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12466
|
-
] })
|
|
12467
|
-
}
|
|
12468
|
-
),
|
|
12469
|
-
/* @__PURE__ */ jsx(
|
|
12470
|
-
Form$2.Field,
|
|
12471
|
-
{
|
|
12472
|
-
control: form.control,
|
|
12473
|
-
name: "address_1",
|
|
12474
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12475
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
12476
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12477
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12478
|
-
] })
|
|
12479
|
-
}
|
|
12480
|
-
),
|
|
12481
|
-
/* @__PURE__ */ jsx(
|
|
12482
|
-
Form$2.Field,
|
|
12483
|
-
{
|
|
12484
|
-
control: form.control,
|
|
12485
|
-
name: "address_2",
|
|
12486
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12487
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12488
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12489
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12490
|
-
] })
|
|
12491
|
-
}
|
|
12492
|
-
),
|
|
12493
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12494
|
-
/* @__PURE__ */ jsx(
|
|
12495
|
-
Form$2.Field,
|
|
12496
|
-
{
|
|
12497
|
-
control: form.control,
|
|
12498
|
-
name: "postal_code",
|
|
12499
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12500
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
12501
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12502
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12503
|
-
] })
|
|
12504
|
-
}
|
|
12505
|
-
),
|
|
12506
|
-
/* @__PURE__ */ jsx(
|
|
12507
|
-
Form$2.Field,
|
|
12508
|
-
{
|
|
12509
|
-
control: form.control,
|
|
12510
|
-
name: "city",
|
|
12511
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12512
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
12513
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12514
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12515
|
-
] })
|
|
12516
|
-
}
|
|
12517
|
-
)
|
|
12518
|
-
] }),
|
|
12519
|
-
/* @__PURE__ */ jsx(
|
|
12520
|
-
Form$2.Field,
|
|
12521
|
-
{
|
|
12522
|
-
control: form.control,
|
|
12523
|
-
name: "province",
|
|
12524
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12525
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
12526
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12527
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12528
|
-
] })
|
|
12529
|
-
}
|
|
12530
|
-
),
|
|
12531
|
-
/* @__PURE__ */ jsx(
|
|
12532
|
-
Form$2.Field,
|
|
12533
|
-
{
|
|
12534
|
-
control: form.control,
|
|
12535
|
-
name: "phone",
|
|
12536
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12537
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
12538
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12539
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12540
|
-
] })
|
|
12541
|
-
}
|
|
12542
|
-
)
|
|
12543
|
-
] }) }),
|
|
12544
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12545
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12546
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12547
|
-
] }) })
|
|
12548
|
-
]
|
|
12549
|
-
}
|
|
12550
|
-
) });
|
|
12551
|
-
};
|
|
12552
|
-
const schema$1 = addressSchema;
|
|
12553
|
-
const TransferOwnership = () => {
|
|
12554
|
-
const { id } = useParams();
|
|
12555
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
12556
|
-
fields: "id,customer_id,customer.*"
|
|
12557
|
-
});
|
|
12558
|
-
if (isError) {
|
|
12559
|
-
throw error;
|
|
12560
|
-
}
|
|
12561
|
-
const isReady = !isPending && !!draft_order;
|
|
12562
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12563
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12564
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Ownership" }) }),
|
|
12565
|
-
/* @__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" }) })
|
|
12566
|
-
] }),
|
|
12567
|
-
isReady && /* @__PURE__ */ jsx(TransferOwnershipForm, { order: draft_order })
|
|
12568
|
-
] });
|
|
12569
|
-
};
|
|
12570
|
-
const TransferOwnershipForm = ({ order }) => {
|
|
12571
|
-
var _a, _b;
|
|
12572
|
-
const form = useForm({
|
|
12573
|
-
defaultValues: {
|
|
12574
|
-
customer_id: order.customer_id || ""
|
|
12575
|
-
},
|
|
12576
|
-
resolver: zodResolver(schema)
|
|
12577
|
-
});
|
|
12578
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12579
|
-
const { handleSuccess } = useRouteModal();
|
|
12580
|
-
const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
|
|
12581
|
-
const currentCustomer = order.customer ? {
|
|
12582
|
-
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
12583
|
-
value: order.customer.id
|
|
12584
|
-
} : null;
|
|
12585
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12586
|
-
await mutateAsync(
|
|
12587
|
-
{ customer_id: data.customer_id },
|
|
12588
|
-
{
|
|
12589
|
-
onSuccess: () => {
|
|
12590
|
-
toast.success("Customer updated");
|
|
12387
|
+
toast.success("Customer updated");
|
|
12591
12388
|
handleSuccess();
|
|
12592
12389
|
},
|
|
12593
12390
|
onError: (error) => {
|
|
@@ -13023,9 +12820,212 @@ const Illustration = () => {
|
|
|
13023
12820
|
}
|
|
13024
12821
|
);
|
|
13025
12822
|
};
|
|
13026
|
-
const schema = objectType({
|
|
12823
|
+
const schema$1 = objectType({
|
|
13027
12824
|
customer_id: stringType().min(1)
|
|
13028
12825
|
});
|
|
12826
|
+
const ShippingAddress = () => {
|
|
12827
|
+
const { id } = useParams();
|
|
12828
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
12829
|
+
fields: "+shipping_address"
|
|
12830
|
+
});
|
|
12831
|
+
if (isError) {
|
|
12832
|
+
throw error;
|
|
12833
|
+
}
|
|
12834
|
+
const isReady = !isPending && !!order;
|
|
12835
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12836
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12837
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
|
|
12838
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
12839
|
+
] }),
|
|
12840
|
+
isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
|
|
12841
|
+
] });
|
|
12842
|
+
};
|
|
12843
|
+
const ShippingAddressForm = ({ order }) => {
|
|
12844
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12845
|
+
const form = useForm({
|
|
12846
|
+
defaultValues: {
|
|
12847
|
+
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12848
|
+
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12849
|
+
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12850
|
+
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12851
|
+
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12852
|
+
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12853
|
+
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12854
|
+
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12855
|
+
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12856
|
+
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12857
|
+
},
|
|
12858
|
+
resolver: zodResolver(schema)
|
|
12859
|
+
});
|
|
12860
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12861
|
+
const { handleSuccess } = useRouteModal();
|
|
12862
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12863
|
+
await mutateAsync(
|
|
12864
|
+
{
|
|
12865
|
+
shipping_address: {
|
|
12866
|
+
first_name: data.first_name,
|
|
12867
|
+
last_name: data.last_name,
|
|
12868
|
+
company: data.company,
|
|
12869
|
+
address_1: data.address_1,
|
|
12870
|
+
address_2: data.address_2,
|
|
12871
|
+
city: data.city,
|
|
12872
|
+
province: data.province,
|
|
12873
|
+
country_code: data.country_code,
|
|
12874
|
+
postal_code: data.postal_code,
|
|
12875
|
+
phone: data.phone
|
|
12876
|
+
}
|
|
12877
|
+
},
|
|
12878
|
+
{
|
|
12879
|
+
onSuccess: () => {
|
|
12880
|
+
handleSuccess();
|
|
12881
|
+
},
|
|
12882
|
+
onError: (error) => {
|
|
12883
|
+
toast.error(error.message);
|
|
12884
|
+
}
|
|
12885
|
+
}
|
|
12886
|
+
);
|
|
12887
|
+
});
|
|
12888
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12889
|
+
KeyboundForm,
|
|
12890
|
+
{
|
|
12891
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12892
|
+
onSubmit,
|
|
12893
|
+
children: [
|
|
12894
|
+
/* @__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: [
|
|
12895
|
+
/* @__PURE__ */ jsx(
|
|
12896
|
+
Form$2.Field,
|
|
12897
|
+
{
|
|
12898
|
+
control: form.control,
|
|
12899
|
+
name: "country_code",
|
|
12900
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12901
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
12902
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
12903
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12904
|
+
] })
|
|
12905
|
+
}
|
|
12906
|
+
),
|
|
12907
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12908
|
+
/* @__PURE__ */ jsx(
|
|
12909
|
+
Form$2.Field,
|
|
12910
|
+
{
|
|
12911
|
+
control: form.control,
|
|
12912
|
+
name: "first_name",
|
|
12913
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12914
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
12915
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12916
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12917
|
+
] })
|
|
12918
|
+
}
|
|
12919
|
+
),
|
|
12920
|
+
/* @__PURE__ */ jsx(
|
|
12921
|
+
Form$2.Field,
|
|
12922
|
+
{
|
|
12923
|
+
control: form.control,
|
|
12924
|
+
name: "last_name",
|
|
12925
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12926
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
12927
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12928
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12929
|
+
] })
|
|
12930
|
+
}
|
|
12931
|
+
)
|
|
12932
|
+
] }),
|
|
12933
|
+
/* @__PURE__ */ jsx(
|
|
12934
|
+
Form$2.Field,
|
|
12935
|
+
{
|
|
12936
|
+
control: form.control,
|
|
12937
|
+
name: "company",
|
|
12938
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12939
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12940
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12941
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12942
|
+
] })
|
|
12943
|
+
}
|
|
12944
|
+
),
|
|
12945
|
+
/* @__PURE__ */ jsx(
|
|
12946
|
+
Form$2.Field,
|
|
12947
|
+
{
|
|
12948
|
+
control: form.control,
|
|
12949
|
+
name: "address_1",
|
|
12950
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12951
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
12952
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12953
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12954
|
+
] })
|
|
12955
|
+
}
|
|
12956
|
+
),
|
|
12957
|
+
/* @__PURE__ */ jsx(
|
|
12958
|
+
Form$2.Field,
|
|
12959
|
+
{
|
|
12960
|
+
control: form.control,
|
|
12961
|
+
name: "address_2",
|
|
12962
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12963
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12964
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12965
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12966
|
+
] })
|
|
12967
|
+
}
|
|
12968
|
+
),
|
|
12969
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12970
|
+
/* @__PURE__ */ jsx(
|
|
12971
|
+
Form$2.Field,
|
|
12972
|
+
{
|
|
12973
|
+
control: form.control,
|
|
12974
|
+
name: "postal_code",
|
|
12975
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12976
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
12977
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12978
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12979
|
+
] })
|
|
12980
|
+
}
|
|
12981
|
+
),
|
|
12982
|
+
/* @__PURE__ */ jsx(
|
|
12983
|
+
Form$2.Field,
|
|
12984
|
+
{
|
|
12985
|
+
control: form.control,
|
|
12986
|
+
name: "city",
|
|
12987
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12988
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
12989
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12990
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12991
|
+
] })
|
|
12992
|
+
}
|
|
12993
|
+
)
|
|
12994
|
+
] }),
|
|
12995
|
+
/* @__PURE__ */ jsx(
|
|
12996
|
+
Form$2.Field,
|
|
12997
|
+
{
|
|
12998
|
+
control: form.control,
|
|
12999
|
+
name: "province",
|
|
13000
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13001
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
13002
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13003
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13004
|
+
] })
|
|
13005
|
+
}
|
|
13006
|
+
),
|
|
13007
|
+
/* @__PURE__ */ jsx(
|
|
13008
|
+
Form$2.Field,
|
|
13009
|
+
{
|
|
13010
|
+
control: form.control,
|
|
13011
|
+
name: "phone",
|
|
13012
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13013
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
13014
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13015
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13016
|
+
] })
|
|
13017
|
+
}
|
|
13018
|
+
)
|
|
13019
|
+
] }) }),
|
|
13020
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13021
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
13022
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
13023
|
+
] }) })
|
|
13024
|
+
]
|
|
13025
|
+
}
|
|
13026
|
+
) });
|
|
13027
|
+
};
|
|
13028
|
+
const schema = addressSchema;
|
|
13029
13029
|
const widgetModule = { widgets: [] };
|
|
13030
13030
|
const routeModule = {
|
|
13031
13031
|
routes: [
|
|
@@ -13046,6 +13046,10 @@ const routeModule = {
|
|
|
13046
13046
|
handle,
|
|
13047
13047
|
loader,
|
|
13048
13048
|
children: [
|
|
13049
|
+
{
|
|
13050
|
+
Component: BillingAddress,
|
|
13051
|
+
path: "/draft-orders/:id/billing-address"
|
|
13052
|
+
},
|
|
13049
13053
|
{
|
|
13050
13054
|
Component: CustomItems,
|
|
13051
13055
|
path: "/draft-orders/:id/custom-items"
|
|
@@ -13062,10 +13066,6 @@ const routeModule = {
|
|
|
13062
13066
|
Component: Metadata,
|
|
13063
13067
|
path: "/draft-orders/:id/metadata"
|
|
13064
13068
|
},
|
|
13065
|
-
{
|
|
13066
|
-
Component: BillingAddress,
|
|
13067
|
-
path: "/draft-orders/:id/billing-address"
|
|
13068
|
-
},
|
|
13069
13069
|
{
|
|
13070
13070
|
Component: Promotions,
|
|
13071
13071
|
path: "/draft-orders/:id/promotions"
|
|
@@ -13078,13 +13078,13 @@ const routeModule = {
|
|
|
13078
13078
|
Component: Shipping,
|
|
13079
13079
|
path: "/draft-orders/:id/shipping"
|
|
13080
13080
|
},
|
|
13081
|
-
{
|
|
13082
|
-
Component: ShippingAddress,
|
|
13083
|
-
path: "/draft-orders/:id/shipping-address"
|
|
13084
|
-
},
|
|
13085
13081
|
{
|
|
13086
13082
|
Component: TransferOwnership,
|
|
13087
13083
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13084
|
+
},
|
|
13085
|
+
{
|
|
13086
|
+
Component: ShippingAddress,
|
|
13087
|
+
path: "/draft-orders/:id/shipping-address"
|
|
13088
13088
|
}
|
|
13089
13089
|
]
|
|
13090
13090
|
}
|