@medusajs/draft-order 2.11.2-preview-20251027032612 → 2.11.2-preview-20251027060158
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 +423 -423
- package/.medusa/server/src/admin/index.mjs +423 -423
- package/package.json +16 -16
|
@@ -9565,31 +9565,10 @@ const ID = () => {
|
|
|
9565
9565
|
/* @__PURE__ */ jsx(Outlet, {})
|
|
9566
9566
|
] });
|
|
9567
9567
|
};
|
|
9568
|
-
const
|
|
9569
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9570
|
-
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
9571
|
-
/* @__PURE__ */ jsx(CustomItemsForm, {})
|
|
9572
|
-
] });
|
|
9573
|
-
};
|
|
9574
|
-
const CustomItemsForm = () => {
|
|
9575
|
-
const form = useForm({
|
|
9576
|
-
resolver: zodResolver(schema$5)
|
|
9577
|
-
});
|
|
9578
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9579
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
9580
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9581
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9582
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
|
|
9583
|
-
] }) })
|
|
9584
|
-
] }) });
|
|
9585
|
-
};
|
|
9586
|
-
const schema$5 = objectType({
|
|
9587
|
-
email: stringType().email()
|
|
9588
|
-
});
|
|
9589
|
-
const Email = () => {
|
|
9568
|
+
const BillingAddress = () => {
|
|
9590
9569
|
const { id } = useParams();
|
|
9591
9570
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
9592
|
-
fields: "+
|
|
9571
|
+
fields: "+billing_address"
|
|
9593
9572
|
});
|
|
9594
9573
|
if (isError) {
|
|
9595
9574
|
throw error;
|
|
@@ -9597,24 +9576,34 @@ const Email = () => {
|
|
|
9597
9576
|
const isReady = !isPending && !!order;
|
|
9598
9577
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9599
9578
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
9600
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit
|
|
9601
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the
|
|
9579
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
|
|
9580
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
9602
9581
|
] }),
|
|
9603
|
-
isReady && /* @__PURE__ */ jsx(
|
|
9582
|
+
isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
|
|
9604
9583
|
] });
|
|
9605
9584
|
};
|
|
9606
|
-
const
|
|
9585
|
+
const BillingAddressForm = ({ order }) => {
|
|
9586
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
9607
9587
|
const form = useForm({
|
|
9608
9588
|
defaultValues: {
|
|
9609
|
-
|
|
9589
|
+
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
9590
|
+
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
9591
|
+
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
9592
|
+
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
9593
|
+
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
9594
|
+
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
9595
|
+
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
9596
|
+
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
9597
|
+
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9598
|
+
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9610
9599
|
},
|
|
9611
|
-
resolver: zodResolver(schema$
|
|
9600
|
+
resolver: zodResolver(schema$5)
|
|
9612
9601
|
});
|
|
9613
9602
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9614
9603
|
const { handleSuccess } = useRouteModal();
|
|
9615
9604
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
9616
9605
|
await mutateAsync(
|
|
9617
|
-
{
|
|
9606
|
+
{ billing_address: data },
|
|
9618
9607
|
{
|
|
9619
9608
|
onSuccess: () => {
|
|
9620
9609
|
handleSuccess();
|
|
@@ -9631,18 +9620,132 @@ const EmailForm = ({ order }) => {
|
|
|
9631
9620
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
9632
9621
|
onSubmit,
|
|
9633
9622
|
children: [
|
|
9634
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */
|
|
9635
|
-
|
|
9636
|
-
|
|
9637
|
-
|
|
9638
|
-
|
|
9639
|
-
|
|
9640
|
-
/* @__PURE__ */
|
|
9641
|
-
|
|
9642
|
-
|
|
9643
|
-
|
|
9644
|
-
|
|
9645
|
-
|
|
9623
|
+
/* @__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: [
|
|
9624
|
+
/* @__PURE__ */ jsx(
|
|
9625
|
+
Form$2.Field,
|
|
9626
|
+
{
|
|
9627
|
+
control: form.control,
|
|
9628
|
+
name: "country_code",
|
|
9629
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9630
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
9631
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
9632
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9633
|
+
] })
|
|
9634
|
+
}
|
|
9635
|
+
),
|
|
9636
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9637
|
+
/* @__PURE__ */ jsx(
|
|
9638
|
+
Form$2.Field,
|
|
9639
|
+
{
|
|
9640
|
+
control: form.control,
|
|
9641
|
+
name: "first_name",
|
|
9642
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9643
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
9644
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9645
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9646
|
+
] })
|
|
9647
|
+
}
|
|
9648
|
+
),
|
|
9649
|
+
/* @__PURE__ */ jsx(
|
|
9650
|
+
Form$2.Field,
|
|
9651
|
+
{
|
|
9652
|
+
control: form.control,
|
|
9653
|
+
name: "last_name",
|
|
9654
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9655
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
9656
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9657
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9658
|
+
] })
|
|
9659
|
+
}
|
|
9660
|
+
)
|
|
9661
|
+
] }),
|
|
9662
|
+
/* @__PURE__ */ jsx(
|
|
9663
|
+
Form$2.Field,
|
|
9664
|
+
{
|
|
9665
|
+
control: form.control,
|
|
9666
|
+
name: "company",
|
|
9667
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9668
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
9669
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9670
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9671
|
+
] })
|
|
9672
|
+
}
|
|
9673
|
+
),
|
|
9674
|
+
/* @__PURE__ */ jsx(
|
|
9675
|
+
Form$2.Field,
|
|
9676
|
+
{
|
|
9677
|
+
control: form.control,
|
|
9678
|
+
name: "address_1",
|
|
9679
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9680
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
9681
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9682
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9683
|
+
] })
|
|
9684
|
+
}
|
|
9685
|
+
),
|
|
9686
|
+
/* @__PURE__ */ jsx(
|
|
9687
|
+
Form$2.Field,
|
|
9688
|
+
{
|
|
9689
|
+
control: form.control,
|
|
9690
|
+
name: "address_2",
|
|
9691
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9692
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
9693
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9694
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9695
|
+
] })
|
|
9696
|
+
}
|
|
9697
|
+
),
|
|
9698
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9699
|
+
/* @__PURE__ */ jsx(
|
|
9700
|
+
Form$2.Field,
|
|
9701
|
+
{
|
|
9702
|
+
control: form.control,
|
|
9703
|
+
name: "postal_code",
|
|
9704
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9705
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
9706
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9707
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9708
|
+
] })
|
|
9709
|
+
}
|
|
9710
|
+
),
|
|
9711
|
+
/* @__PURE__ */ jsx(
|
|
9712
|
+
Form$2.Field,
|
|
9713
|
+
{
|
|
9714
|
+
control: form.control,
|
|
9715
|
+
name: "city",
|
|
9716
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9717
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
9718
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9719
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9720
|
+
] })
|
|
9721
|
+
}
|
|
9722
|
+
)
|
|
9723
|
+
] }),
|
|
9724
|
+
/* @__PURE__ */ jsx(
|
|
9725
|
+
Form$2.Field,
|
|
9726
|
+
{
|
|
9727
|
+
control: form.control,
|
|
9728
|
+
name: "province",
|
|
9729
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9730
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
9731
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9732
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9733
|
+
] })
|
|
9734
|
+
}
|
|
9735
|
+
),
|
|
9736
|
+
/* @__PURE__ */ jsx(
|
|
9737
|
+
Form$2.Field,
|
|
9738
|
+
{
|
|
9739
|
+
control: form.control,
|
|
9740
|
+
name: "phone",
|
|
9741
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9742
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
9743
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9744
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9745
|
+
] })
|
|
9746
|
+
}
|
|
9747
|
+
)
|
|
9748
|
+
] }) }),
|
|
9646
9749
|
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9647
9750
|
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9648
9751
|
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
@@ -9651,6 +9754,25 @@ const EmailForm = ({ order }) => {
|
|
|
9651
9754
|
}
|
|
9652
9755
|
) });
|
|
9653
9756
|
};
|
|
9757
|
+
const schema$5 = addressSchema;
|
|
9758
|
+
const CustomItems = () => {
|
|
9759
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9760
|
+
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
9761
|
+
/* @__PURE__ */ jsx(CustomItemsForm, {})
|
|
9762
|
+
] });
|
|
9763
|
+
};
|
|
9764
|
+
const CustomItemsForm = () => {
|
|
9765
|
+
const form = useForm({
|
|
9766
|
+
resolver: zodResolver(schema$4)
|
|
9767
|
+
});
|
|
9768
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9769
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
9770
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9771
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9772
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
|
|
9773
|
+
] }) })
|
|
9774
|
+
] }) });
|
|
9775
|
+
};
|
|
9654
9776
|
const schema$4 = objectType({
|
|
9655
9777
|
email: stringType().email()
|
|
9656
9778
|
});
|
|
@@ -10628,54 +10750,10 @@ const customItemSchema = objectType({
|
|
|
10628
10750
|
quantity: numberType(),
|
|
10629
10751
|
unit_price: unionType([numberType(), stringType()])
|
|
10630
10752
|
});
|
|
10631
|
-
const
|
|
10632
|
-
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
10633
|
-
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
10634
|
-
return /* @__PURE__ */ jsxs(
|
|
10635
|
-
"div",
|
|
10636
|
-
{
|
|
10637
|
-
ref,
|
|
10638
|
-
className: clx(
|
|
10639
|
-
"bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
|
|
10640
|
-
className
|
|
10641
|
-
),
|
|
10642
|
-
...props,
|
|
10643
|
-
children: [
|
|
10644
|
-
/* @__PURE__ */ jsx(
|
|
10645
|
-
"div",
|
|
10646
|
-
{
|
|
10647
|
-
role: "presentation",
|
|
10648
|
-
className: clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
|
|
10649
|
-
"bg-ui-tag-orange-icon": variant === "warning"
|
|
10650
|
-
})
|
|
10651
|
-
}
|
|
10652
|
-
),
|
|
10653
|
-
/* @__PURE__ */ jsxs("div", { className: "text-pretty", children: [
|
|
10654
|
-
/* @__PURE__ */ jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
|
|
10655
|
-
labelValue,
|
|
10656
|
-
":"
|
|
10657
|
-
] }),
|
|
10658
|
-
" ",
|
|
10659
|
-
children
|
|
10660
|
-
] })
|
|
10661
|
-
]
|
|
10662
|
-
}
|
|
10663
|
-
);
|
|
10664
|
-
}
|
|
10665
|
-
);
|
|
10666
|
-
InlineTip.displayName = "InlineTip";
|
|
10667
|
-
const MetadataFieldSchema = objectType({
|
|
10668
|
-
key: stringType(),
|
|
10669
|
-
disabled: booleanType().optional(),
|
|
10670
|
-
value: anyType()
|
|
10671
|
-
});
|
|
10672
|
-
const MetadataSchema = objectType({
|
|
10673
|
-
metadata: arrayType(MetadataFieldSchema)
|
|
10674
|
-
});
|
|
10675
|
-
const Metadata = () => {
|
|
10753
|
+
const Email = () => {
|
|
10676
10754
|
const { id } = useParams();
|
|
10677
10755
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
10678
|
-
fields: "
|
|
10756
|
+
fields: "+email"
|
|
10679
10757
|
});
|
|
10680
10758
|
if (isError) {
|
|
10681
10759
|
throw error;
|
|
@@ -10683,8 +10761,120 @@ const Metadata = () => {
|
|
|
10683
10761
|
const isReady = !isPending && !!order;
|
|
10684
10762
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
10685
10763
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
10686
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "
|
|
10687
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "
|
|
10764
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
|
|
10765
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
10766
|
+
] }),
|
|
10767
|
+
isReady && /* @__PURE__ */ jsx(EmailForm, { order })
|
|
10768
|
+
] });
|
|
10769
|
+
};
|
|
10770
|
+
const EmailForm = ({ order }) => {
|
|
10771
|
+
const form = useForm({
|
|
10772
|
+
defaultValues: {
|
|
10773
|
+
email: order.email ?? ""
|
|
10774
|
+
},
|
|
10775
|
+
resolver: zodResolver(schema$3)
|
|
10776
|
+
});
|
|
10777
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
10778
|
+
const { handleSuccess } = useRouteModal();
|
|
10779
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
10780
|
+
await mutateAsync(
|
|
10781
|
+
{ email: data.email },
|
|
10782
|
+
{
|
|
10783
|
+
onSuccess: () => {
|
|
10784
|
+
handleSuccess();
|
|
10785
|
+
},
|
|
10786
|
+
onError: (error) => {
|
|
10787
|
+
toast.error(error.message);
|
|
10788
|
+
}
|
|
10789
|
+
}
|
|
10790
|
+
);
|
|
10791
|
+
});
|
|
10792
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
10793
|
+
KeyboundForm,
|
|
10794
|
+
{
|
|
10795
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
10796
|
+
onSubmit,
|
|
10797
|
+
children: [
|
|
10798
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
10799
|
+
Form$2.Field,
|
|
10800
|
+
{
|
|
10801
|
+
control: form.control,
|
|
10802
|
+
name: "email",
|
|
10803
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
10804
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
|
|
10805
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
10806
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10807
|
+
] })
|
|
10808
|
+
}
|
|
10809
|
+
) }),
|
|
10810
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
10811
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
10812
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
10813
|
+
] }) })
|
|
10814
|
+
]
|
|
10815
|
+
}
|
|
10816
|
+
) });
|
|
10817
|
+
};
|
|
10818
|
+
const schema$3 = objectType({
|
|
10819
|
+
email: stringType().email()
|
|
10820
|
+
});
|
|
10821
|
+
const InlineTip = forwardRef(
|
|
10822
|
+
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
10823
|
+
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
10824
|
+
return /* @__PURE__ */ jsxs(
|
|
10825
|
+
"div",
|
|
10826
|
+
{
|
|
10827
|
+
ref,
|
|
10828
|
+
className: clx(
|
|
10829
|
+
"bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
|
|
10830
|
+
className
|
|
10831
|
+
),
|
|
10832
|
+
...props,
|
|
10833
|
+
children: [
|
|
10834
|
+
/* @__PURE__ */ jsx(
|
|
10835
|
+
"div",
|
|
10836
|
+
{
|
|
10837
|
+
role: "presentation",
|
|
10838
|
+
className: clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
|
|
10839
|
+
"bg-ui-tag-orange-icon": variant === "warning"
|
|
10840
|
+
})
|
|
10841
|
+
}
|
|
10842
|
+
),
|
|
10843
|
+
/* @__PURE__ */ jsxs("div", { className: "text-pretty", children: [
|
|
10844
|
+
/* @__PURE__ */ jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
|
|
10845
|
+
labelValue,
|
|
10846
|
+
":"
|
|
10847
|
+
] }),
|
|
10848
|
+
" ",
|
|
10849
|
+
children
|
|
10850
|
+
] })
|
|
10851
|
+
]
|
|
10852
|
+
}
|
|
10853
|
+
);
|
|
10854
|
+
}
|
|
10855
|
+
);
|
|
10856
|
+
InlineTip.displayName = "InlineTip";
|
|
10857
|
+
const MetadataFieldSchema = objectType({
|
|
10858
|
+
key: stringType(),
|
|
10859
|
+
disabled: booleanType().optional(),
|
|
10860
|
+
value: anyType()
|
|
10861
|
+
});
|
|
10862
|
+
const MetadataSchema = objectType({
|
|
10863
|
+
metadata: arrayType(MetadataFieldSchema)
|
|
10864
|
+
});
|
|
10865
|
+
const Metadata = () => {
|
|
10866
|
+
const { id } = useParams();
|
|
10867
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
10868
|
+
fields: "metadata"
|
|
10869
|
+
});
|
|
10870
|
+
if (isError) {
|
|
10871
|
+
throw error;
|
|
10872
|
+
}
|
|
10873
|
+
const isReady = !isPending && !!order;
|
|
10874
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
10875
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
10876
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Metadata" }) }),
|
|
10877
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
|
|
10688
10878
|
] }),
|
|
10689
10879
|
!isReady ? /* @__PURE__ */ jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
|
|
10690
10880
|
] });
|
|
@@ -11255,112 +11445,6 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11255
11445
|
}
|
|
11256
11446
|
return Array.from(promotionIds);
|
|
11257
11447
|
}
|
|
11258
|
-
const SalesChannel = () => {
|
|
11259
|
-
const { id } = useParams();
|
|
11260
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11261
|
-
id,
|
|
11262
|
-
{
|
|
11263
|
-
fields: "+sales_channel_id"
|
|
11264
|
-
},
|
|
11265
|
-
{
|
|
11266
|
-
enabled: !!id
|
|
11267
|
-
}
|
|
11268
|
-
);
|
|
11269
|
-
if (isError) {
|
|
11270
|
-
throw error;
|
|
11271
|
-
}
|
|
11272
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
11273
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11274
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11275
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
11276
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
11277
|
-
] }),
|
|
11278
|
-
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
11279
|
-
] });
|
|
11280
|
-
};
|
|
11281
|
-
const SalesChannelForm = ({ order }) => {
|
|
11282
|
-
const form = useForm({
|
|
11283
|
-
defaultValues: {
|
|
11284
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
11285
|
-
},
|
|
11286
|
-
resolver: zodResolver(schema$3)
|
|
11287
|
-
});
|
|
11288
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11289
|
-
const { handleSuccess } = useRouteModal();
|
|
11290
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
11291
|
-
await mutateAsync(
|
|
11292
|
-
{
|
|
11293
|
-
sales_channel_id: data.sales_channel_id
|
|
11294
|
-
},
|
|
11295
|
-
{
|
|
11296
|
-
onSuccess: () => {
|
|
11297
|
-
toast.success("Sales channel updated");
|
|
11298
|
-
handleSuccess();
|
|
11299
|
-
},
|
|
11300
|
-
onError: (error) => {
|
|
11301
|
-
toast.error(error.message);
|
|
11302
|
-
}
|
|
11303
|
-
}
|
|
11304
|
-
);
|
|
11305
|
-
});
|
|
11306
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11307
|
-
KeyboundForm,
|
|
11308
|
-
{
|
|
11309
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
11310
|
-
onSubmit,
|
|
11311
|
-
children: [
|
|
11312
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11313
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11314
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11315
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11316
|
-
] }) })
|
|
11317
|
-
]
|
|
11318
|
-
}
|
|
11319
|
-
) });
|
|
11320
|
-
};
|
|
11321
|
-
const SalesChannelField = ({ control, order }) => {
|
|
11322
|
-
const salesChannels = useComboboxData({
|
|
11323
|
-
queryFn: async (params) => {
|
|
11324
|
-
return await sdk.admin.salesChannel.list(params);
|
|
11325
|
-
},
|
|
11326
|
-
queryKey: ["sales-channels"],
|
|
11327
|
-
getOptions: (data) => {
|
|
11328
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
11329
|
-
label: salesChannel.name,
|
|
11330
|
-
value: salesChannel.id
|
|
11331
|
-
}));
|
|
11332
|
-
},
|
|
11333
|
-
defaultValue: order.sales_channel_id || void 0
|
|
11334
|
-
});
|
|
11335
|
-
return /* @__PURE__ */ jsx(
|
|
11336
|
-
Form$2.Field,
|
|
11337
|
-
{
|
|
11338
|
-
control,
|
|
11339
|
-
name: "sales_channel_id",
|
|
11340
|
-
render: ({ field }) => {
|
|
11341
|
-
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11342
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11343
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
11344
|
-
Combobox,
|
|
11345
|
-
{
|
|
11346
|
-
options: salesChannels.options,
|
|
11347
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
11348
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11349
|
-
searchValue: salesChannels.searchValue,
|
|
11350
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11351
|
-
placeholder: "Select sales channel",
|
|
11352
|
-
...field
|
|
11353
|
-
}
|
|
11354
|
-
) }),
|
|
11355
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11356
|
-
] });
|
|
11357
|
-
}
|
|
11358
|
-
}
|
|
11359
|
-
);
|
|
11360
|
-
};
|
|
11361
|
-
const schema$3 = objectType({
|
|
11362
|
-
sales_channel_id: stringType().min(1)
|
|
11363
|
-
});
|
|
11364
11448
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11365
11449
|
const Shipping = () => {
|
|
11366
11450
|
var _a;
|
|
@@ -12168,37 +12252,33 @@ const CustomAmountField = ({
|
|
|
12168
12252
|
}
|
|
12169
12253
|
);
|
|
12170
12254
|
};
|
|
12171
|
-
const
|
|
12255
|
+
const SalesChannel = () => {
|
|
12172
12256
|
const { id } = useParams();
|
|
12173
|
-
const {
|
|
12174
|
-
|
|
12175
|
-
|
|
12257
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12258
|
+
id,
|
|
12259
|
+
{
|
|
12260
|
+
fields: "+sales_channel_id"
|
|
12261
|
+
},
|
|
12262
|
+
{
|
|
12263
|
+
enabled: !!id
|
|
12264
|
+
}
|
|
12265
|
+
);
|
|
12176
12266
|
if (isError) {
|
|
12177
12267
|
throw error;
|
|
12178
12268
|
}
|
|
12179
|
-
const
|
|
12269
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
12180
12270
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12181
12271
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12182
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit
|
|
12183
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "
|
|
12272
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
12273
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
12184
12274
|
] }),
|
|
12185
|
-
|
|
12275
|
+
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
12186
12276
|
] });
|
|
12187
12277
|
};
|
|
12188
|
-
const
|
|
12189
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12278
|
+
const SalesChannelForm = ({ order }) => {
|
|
12190
12279
|
const form = useForm({
|
|
12191
12280
|
defaultValues: {
|
|
12192
|
-
|
|
12193
|
-
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12194
|
-
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12195
|
-
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12196
|
-
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12197
|
-
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12198
|
-
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12199
|
-
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12200
|
-
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12201
|
-
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12281
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
12202
12282
|
},
|
|
12203
12283
|
resolver: zodResolver(schema$2)
|
|
12204
12284
|
});
|
|
@@ -12207,8 +12287,118 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12207
12287
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
12208
12288
|
await mutateAsync(
|
|
12209
12289
|
{
|
|
12210
|
-
|
|
12211
|
-
|
|
12290
|
+
sales_channel_id: data.sales_channel_id
|
|
12291
|
+
},
|
|
12292
|
+
{
|
|
12293
|
+
onSuccess: () => {
|
|
12294
|
+
toast.success("Sales channel updated");
|
|
12295
|
+
handleSuccess();
|
|
12296
|
+
},
|
|
12297
|
+
onError: (error) => {
|
|
12298
|
+
toast.error(error.message);
|
|
12299
|
+
}
|
|
12300
|
+
}
|
|
12301
|
+
);
|
|
12302
|
+
});
|
|
12303
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12304
|
+
KeyboundForm,
|
|
12305
|
+
{
|
|
12306
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12307
|
+
onSubmit,
|
|
12308
|
+
children: [
|
|
12309
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12310
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12311
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12312
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12313
|
+
] }) })
|
|
12314
|
+
]
|
|
12315
|
+
}
|
|
12316
|
+
) });
|
|
12317
|
+
};
|
|
12318
|
+
const SalesChannelField = ({ control, order }) => {
|
|
12319
|
+
const salesChannels = useComboboxData({
|
|
12320
|
+
queryFn: async (params) => {
|
|
12321
|
+
return await sdk.admin.salesChannel.list(params);
|
|
12322
|
+
},
|
|
12323
|
+
queryKey: ["sales-channels"],
|
|
12324
|
+
getOptions: (data) => {
|
|
12325
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
12326
|
+
label: salesChannel.name,
|
|
12327
|
+
value: salesChannel.id
|
|
12328
|
+
}));
|
|
12329
|
+
},
|
|
12330
|
+
defaultValue: order.sales_channel_id || void 0
|
|
12331
|
+
});
|
|
12332
|
+
return /* @__PURE__ */ jsx(
|
|
12333
|
+
Form$2.Field,
|
|
12334
|
+
{
|
|
12335
|
+
control,
|
|
12336
|
+
name: "sales_channel_id",
|
|
12337
|
+
render: ({ field }) => {
|
|
12338
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12339
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
12340
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
12341
|
+
Combobox,
|
|
12342
|
+
{
|
|
12343
|
+
options: salesChannels.options,
|
|
12344
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
12345
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
12346
|
+
searchValue: salesChannels.searchValue,
|
|
12347
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
12348
|
+
placeholder: "Select sales channel",
|
|
12349
|
+
...field
|
|
12350
|
+
}
|
|
12351
|
+
) }),
|
|
12352
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12353
|
+
] });
|
|
12354
|
+
}
|
|
12355
|
+
}
|
|
12356
|
+
);
|
|
12357
|
+
};
|
|
12358
|
+
const schema$2 = objectType({
|
|
12359
|
+
sales_channel_id: stringType().min(1)
|
|
12360
|
+
});
|
|
12361
|
+
const ShippingAddress = () => {
|
|
12362
|
+
const { id } = useParams();
|
|
12363
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
12364
|
+
fields: "+shipping_address"
|
|
12365
|
+
});
|
|
12366
|
+
if (isError) {
|
|
12367
|
+
throw error;
|
|
12368
|
+
}
|
|
12369
|
+
const isReady = !isPending && !!order;
|
|
12370
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12371
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12372
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
|
|
12373
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
12374
|
+
] }),
|
|
12375
|
+
isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
|
|
12376
|
+
] });
|
|
12377
|
+
};
|
|
12378
|
+
const ShippingAddressForm = ({ order }) => {
|
|
12379
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12380
|
+
const form = useForm({
|
|
12381
|
+
defaultValues: {
|
|
12382
|
+
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12383
|
+
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12384
|
+
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12385
|
+
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12386
|
+
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12387
|
+
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12388
|
+
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12389
|
+
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12390
|
+
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12391
|
+
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12392
|
+
},
|
|
12393
|
+
resolver: zodResolver(schema$1)
|
|
12394
|
+
});
|
|
12395
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12396
|
+
const { handleSuccess } = useRouteModal();
|
|
12397
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12398
|
+
await mutateAsync(
|
|
12399
|
+
{
|
|
12400
|
+
shipping_address: {
|
|
12401
|
+
first_name: data.first_name,
|
|
12212
12402
|
last_name: data.last_name,
|
|
12213
12403
|
company: data.company,
|
|
12214
12404
|
address_1: data.address_1,
|
|
@@ -12370,7 +12560,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12370
12560
|
}
|
|
12371
12561
|
) });
|
|
12372
12562
|
};
|
|
12373
|
-
const schema$
|
|
12563
|
+
const schema$1 = addressSchema;
|
|
12374
12564
|
const TransferOwnership = () => {
|
|
12375
12565
|
const { id } = useParams();
|
|
12376
12566
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -12394,7 +12584,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12394
12584
|
defaultValues: {
|
|
12395
12585
|
customer_id: order.customer_id || ""
|
|
12396
12586
|
},
|
|
12397
|
-
resolver: zodResolver(schema
|
|
12587
|
+
resolver: zodResolver(schema)
|
|
12398
12588
|
});
|
|
12399
12589
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12400
12590
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12844,199 +13034,9 @@ const Illustration = () => {
|
|
|
12844
13034
|
}
|
|
12845
13035
|
);
|
|
12846
13036
|
};
|
|
12847
|
-
const schema
|
|
13037
|
+
const schema = objectType({
|
|
12848
13038
|
customer_id: stringType().min(1)
|
|
12849
13039
|
});
|
|
12850
|
-
const BillingAddress = () => {
|
|
12851
|
-
const { id } = useParams();
|
|
12852
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
12853
|
-
fields: "+billing_address"
|
|
12854
|
-
});
|
|
12855
|
-
if (isError) {
|
|
12856
|
-
throw error;
|
|
12857
|
-
}
|
|
12858
|
-
const isReady = !isPending && !!order;
|
|
12859
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12860
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12861
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
|
|
12862
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
12863
|
-
] }),
|
|
12864
|
-
isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
|
|
12865
|
-
] });
|
|
12866
|
-
};
|
|
12867
|
-
const BillingAddressForm = ({ order }) => {
|
|
12868
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12869
|
-
const form = useForm({
|
|
12870
|
-
defaultValues: {
|
|
12871
|
-
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12872
|
-
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12873
|
-
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
12874
|
-
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12875
|
-
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12876
|
-
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
12877
|
-
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
12878
|
-
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12879
|
-
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12880
|
-
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
12881
|
-
},
|
|
12882
|
-
resolver: zodResolver(schema)
|
|
12883
|
-
});
|
|
12884
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12885
|
-
const { handleSuccess } = useRouteModal();
|
|
12886
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12887
|
-
await mutateAsync(
|
|
12888
|
-
{ billing_address: data },
|
|
12889
|
-
{
|
|
12890
|
-
onSuccess: () => {
|
|
12891
|
-
handleSuccess();
|
|
12892
|
-
},
|
|
12893
|
-
onError: (error) => {
|
|
12894
|
-
toast.error(error.message);
|
|
12895
|
-
}
|
|
12896
|
-
}
|
|
12897
|
-
);
|
|
12898
|
-
});
|
|
12899
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12900
|
-
KeyboundForm,
|
|
12901
|
-
{
|
|
12902
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12903
|
-
onSubmit,
|
|
12904
|
-
children: [
|
|
12905
|
-
/* @__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: [
|
|
12906
|
-
/* @__PURE__ */ jsx(
|
|
12907
|
-
Form$2.Field,
|
|
12908
|
-
{
|
|
12909
|
-
control: form.control,
|
|
12910
|
-
name: "country_code",
|
|
12911
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12912
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
12913
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
12914
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12915
|
-
] })
|
|
12916
|
-
}
|
|
12917
|
-
),
|
|
12918
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12919
|
-
/* @__PURE__ */ jsx(
|
|
12920
|
-
Form$2.Field,
|
|
12921
|
-
{
|
|
12922
|
-
control: form.control,
|
|
12923
|
-
name: "first_name",
|
|
12924
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12925
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
12926
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12927
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12928
|
-
] })
|
|
12929
|
-
}
|
|
12930
|
-
),
|
|
12931
|
-
/* @__PURE__ */ jsx(
|
|
12932
|
-
Form$2.Field,
|
|
12933
|
-
{
|
|
12934
|
-
control: form.control,
|
|
12935
|
-
name: "last_name",
|
|
12936
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12937
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
12938
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12939
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12940
|
-
] })
|
|
12941
|
-
}
|
|
12942
|
-
)
|
|
12943
|
-
] }),
|
|
12944
|
-
/* @__PURE__ */ jsx(
|
|
12945
|
-
Form$2.Field,
|
|
12946
|
-
{
|
|
12947
|
-
control: form.control,
|
|
12948
|
-
name: "company",
|
|
12949
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12950
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12951
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12952
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12953
|
-
] })
|
|
12954
|
-
}
|
|
12955
|
-
),
|
|
12956
|
-
/* @__PURE__ */ jsx(
|
|
12957
|
-
Form$2.Field,
|
|
12958
|
-
{
|
|
12959
|
-
control: form.control,
|
|
12960
|
-
name: "address_1",
|
|
12961
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12962
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
12963
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12964
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12965
|
-
] })
|
|
12966
|
-
}
|
|
12967
|
-
),
|
|
12968
|
-
/* @__PURE__ */ jsx(
|
|
12969
|
-
Form$2.Field,
|
|
12970
|
-
{
|
|
12971
|
-
control: form.control,
|
|
12972
|
-
name: "address_2",
|
|
12973
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12974
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12975
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12976
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12977
|
-
] })
|
|
12978
|
-
}
|
|
12979
|
-
),
|
|
12980
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12981
|
-
/* @__PURE__ */ jsx(
|
|
12982
|
-
Form$2.Field,
|
|
12983
|
-
{
|
|
12984
|
-
control: form.control,
|
|
12985
|
-
name: "postal_code",
|
|
12986
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12987
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
12988
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12989
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12990
|
-
] })
|
|
12991
|
-
}
|
|
12992
|
-
),
|
|
12993
|
-
/* @__PURE__ */ jsx(
|
|
12994
|
-
Form$2.Field,
|
|
12995
|
-
{
|
|
12996
|
-
control: form.control,
|
|
12997
|
-
name: "city",
|
|
12998
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12999
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
13000
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13001
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13002
|
-
] })
|
|
13003
|
-
}
|
|
13004
|
-
)
|
|
13005
|
-
] }),
|
|
13006
|
-
/* @__PURE__ */ jsx(
|
|
13007
|
-
Form$2.Field,
|
|
13008
|
-
{
|
|
13009
|
-
control: form.control,
|
|
13010
|
-
name: "province",
|
|
13011
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13012
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
13013
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13014
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13015
|
-
] })
|
|
13016
|
-
}
|
|
13017
|
-
),
|
|
13018
|
-
/* @__PURE__ */ jsx(
|
|
13019
|
-
Form$2.Field,
|
|
13020
|
-
{
|
|
13021
|
-
control: form.control,
|
|
13022
|
-
name: "phone",
|
|
13023
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13024
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
13025
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13026
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13027
|
-
] })
|
|
13028
|
-
}
|
|
13029
|
-
)
|
|
13030
|
-
] }) }),
|
|
13031
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13032
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
13033
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
13034
|
-
] }) })
|
|
13035
|
-
]
|
|
13036
|
-
}
|
|
13037
|
-
) });
|
|
13038
|
-
};
|
|
13039
|
-
const schema = addressSchema;
|
|
13040
13040
|
const widgetModule = { widgets: [] };
|
|
13041
13041
|
const routeModule = {
|
|
13042
13042
|
routes: [
|
|
@@ -13058,17 +13058,21 @@ const routeModule = {
|
|
|
13058
13058
|
loader,
|
|
13059
13059
|
children: [
|
|
13060
13060
|
{
|
|
13061
|
-
Component:
|
|
13062
|
-
path: "/draft-orders/:id/
|
|
13061
|
+
Component: BillingAddress,
|
|
13062
|
+
path: "/draft-orders/:id/billing-address"
|
|
13063
13063
|
},
|
|
13064
13064
|
{
|
|
13065
|
-
Component:
|
|
13066
|
-
path: "/draft-orders/:id/
|
|
13065
|
+
Component: CustomItems,
|
|
13066
|
+
path: "/draft-orders/:id/custom-items"
|
|
13067
13067
|
},
|
|
13068
13068
|
{
|
|
13069
13069
|
Component: Items,
|
|
13070
13070
|
path: "/draft-orders/:id/items"
|
|
13071
13071
|
},
|
|
13072
|
+
{
|
|
13073
|
+
Component: Email,
|
|
13074
|
+
path: "/draft-orders/:id/email"
|
|
13075
|
+
},
|
|
13072
13076
|
{
|
|
13073
13077
|
Component: Metadata,
|
|
13074
13078
|
path: "/draft-orders/:id/metadata"
|
|
@@ -13077,14 +13081,14 @@ const routeModule = {
|
|
|
13077
13081
|
Component: Promotions,
|
|
13078
13082
|
path: "/draft-orders/:id/promotions"
|
|
13079
13083
|
},
|
|
13080
|
-
{
|
|
13081
|
-
Component: SalesChannel,
|
|
13082
|
-
path: "/draft-orders/:id/sales-channel"
|
|
13083
|
-
},
|
|
13084
13084
|
{
|
|
13085
13085
|
Component: Shipping,
|
|
13086
13086
|
path: "/draft-orders/:id/shipping"
|
|
13087
13087
|
},
|
|
13088
|
+
{
|
|
13089
|
+
Component: SalesChannel,
|
|
13090
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13091
|
+
},
|
|
13088
13092
|
{
|
|
13089
13093
|
Component: ShippingAddress,
|
|
13090
13094
|
path: "/draft-orders/:id/shipping-address"
|
|
@@ -13092,10 +13096,6 @@ const routeModule = {
|
|
|
13092
13096
|
{
|
|
13093
13097
|
Component: TransferOwnership,
|
|
13094
13098
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13095
|
-
},
|
|
13096
|
-
{
|
|
13097
|
-
Component: BillingAddress,
|
|
13098
|
-
path: "/draft-orders/:id/billing-address"
|
|
13099
13099
|
}
|
|
13100
13100
|
]
|
|
13101
13101
|
}
|