@medusajs/draft-order 2.11.1-preview-20251024120210 → 2.11.1-preview-20251024150200
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 +597 -597
- package/.medusa/server/src/admin/index.mjs +597 -597
- package/package.json +16 -16
|
@@ -9586,74 +9586,6 @@ const CustomItemsForm = () => {
|
|
|
9586
9586
|
const schema$5 = objectType({
|
|
9587
9587
|
email: stringType().email()
|
|
9588
9588
|
});
|
|
9589
|
-
const Email = () => {
|
|
9590
|
-
const { id } = useParams();
|
|
9591
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
9592
|
-
fields: "+email"
|
|
9593
|
-
});
|
|
9594
|
-
if (isError) {
|
|
9595
|
-
throw error;
|
|
9596
|
-
}
|
|
9597
|
-
const isReady = !isPending && !!order;
|
|
9598
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9599
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
9600
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
|
|
9601
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
9602
|
-
] }),
|
|
9603
|
-
isReady && /* @__PURE__ */ jsx(EmailForm, { order })
|
|
9604
|
-
] });
|
|
9605
|
-
};
|
|
9606
|
-
const EmailForm = ({ order }) => {
|
|
9607
|
-
const form = useForm({
|
|
9608
|
-
defaultValues: {
|
|
9609
|
-
email: order.email ?? ""
|
|
9610
|
-
},
|
|
9611
|
-
resolver: zodResolver(schema$4)
|
|
9612
|
-
});
|
|
9613
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9614
|
-
const { handleSuccess } = useRouteModal();
|
|
9615
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
9616
|
-
await mutateAsync(
|
|
9617
|
-
{ email: data.email },
|
|
9618
|
-
{
|
|
9619
|
-
onSuccess: () => {
|
|
9620
|
-
handleSuccess();
|
|
9621
|
-
},
|
|
9622
|
-
onError: (error) => {
|
|
9623
|
-
toast.error(error.message);
|
|
9624
|
-
}
|
|
9625
|
-
}
|
|
9626
|
-
);
|
|
9627
|
-
});
|
|
9628
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
9629
|
-
KeyboundForm,
|
|
9630
|
-
{
|
|
9631
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
9632
|
-
onSubmit,
|
|
9633
|
-
children: [
|
|
9634
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
9635
|
-
Form$2.Field,
|
|
9636
|
-
{
|
|
9637
|
-
control: form.control,
|
|
9638
|
-
name: "email",
|
|
9639
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9640
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
|
|
9641
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9642
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9643
|
-
] })
|
|
9644
|
-
}
|
|
9645
|
-
) }),
|
|
9646
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9647
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9648
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9649
|
-
] }) })
|
|
9650
|
-
]
|
|
9651
|
-
}
|
|
9652
|
-
) });
|
|
9653
|
-
};
|
|
9654
|
-
const schema$4 = objectType({
|
|
9655
|
-
email: stringType().email()
|
|
9656
|
-
});
|
|
9657
9589
|
const NumberInput = forwardRef(
|
|
9658
9590
|
({
|
|
9659
9591
|
value,
|
|
@@ -10628,10 +10560,54 @@ const customItemSchema = objectType({
|
|
|
10628
10560
|
quantity: numberType(),
|
|
10629
10561
|
unit_price: unionType([numberType(), stringType()])
|
|
10630
10562
|
});
|
|
10631
|
-
const
|
|
10563
|
+
const InlineTip = forwardRef(
|
|
10564
|
+
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
10565
|
+
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
10566
|
+
return /* @__PURE__ */ jsxs(
|
|
10567
|
+
"div",
|
|
10568
|
+
{
|
|
10569
|
+
ref,
|
|
10570
|
+
className: clx(
|
|
10571
|
+
"bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
|
|
10572
|
+
className
|
|
10573
|
+
),
|
|
10574
|
+
...props,
|
|
10575
|
+
children: [
|
|
10576
|
+
/* @__PURE__ */ jsx(
|
|
10577
|
+
"div",
|
|
10578
|
+
{
|
|
10579
|
+
role: "presentation",
|
|
10580
|
+
className: clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
|
|
10581
|
+
"bg-ui-tag-orange-icon": variant === "warning"
|
|
10582
|
+
})
|
|
10583
|
+
}
|
|
10584
|
+
),
|
|
10585
|
+
/* @__PURE__ */ jsxs("div", { className: "text-pretty", children: [
|
|
10586
|
+
/* @__PURE__ */ jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
|
|
10587
|
+
labelValue,
|
|
10588
|
+
":"
|
|
10589
|
+
] }),
|
|
10590
|
+
" ",
|
|
10591
|
+
children
|
|
10592
|
+
] })
|
|
10593
|
+
]
|
|
10594
|
+
}
|
|
10595
|
+
);
|
|
10596
|
+
}
|
|
10597
|
+
);
|
|
10598
|
+
InlineTip.displayName = "InlineTip";
|
|
10599
|
+
const MetadataFieldSchema = objectType({
|
|
10600
|
+
key: stringType(),
|
|
10601
|
+
disabled: booleanType().optional(),
|
|
10602
|
+
value: anyType()
|
|
10603
|
+
});
|
|
10604
|
+
const MetadataSchema = objectType({
|
|
10605
|
+
metadata: arrayType(MetadataFieldSchema)
|
|
10606
|
+
});
|
|
10607
|
+
const Metadata = () => {
|
|
10632
10608
|
const { id } = useParams();
|
|
10633
10609
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
10634
|
-
fields: "
|
|
10610
|
+
fields: "metadata"
|
|
10635
10611
|
});
|
|
10636
10612
|
if (isError) {
|
|
10637
10613
|
throw error;
|
|
@@ -10639,36 +10615,33 @@ const BillingAddress = () => {
|
|
|
10639
10615
|
const isReady = !isPending && !!order;
|
|
10640
10616
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
10641
10617
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
10642
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "
|
|
10643
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "
|
|
10618
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Metadata" }) }),
|
|
10619
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
|
|
10644
10620
|
] }),
|
|
10645
|
-
isReady
|
|
10621
|
+
!isReady ? /* @__PURE__ */ jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
|
|
10646
10622
|
] });
|
|
10647
10623
|
};
|
|
10648
|
-
const
|
|
10649
|
-
|
|
10624
|
+
const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
|
|
10625
|
+
const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
|
|
10626
|
+
const MetadataForm = ({ orderId, metadata }) => {
|
|
10627
|
+
const { handleSuccess } = useRouteModal();
|
|
10628
|
+
const hasUneditableRows = getHasUneditableRows(metadata);
|
|
10629
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
|
|
10650
10630
|
const form = useForm({
|
|
10651
10631
|
defaultValues: {
|
|
10652
|
-
|
|
10653
|
-
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
10654
|
-
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
10655
|
-
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
10656
|
-
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
10657
|
-
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
10658
|
-
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
10659
|
-
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
10660
|
-
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
10661
|
-
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
10632
|
+
metadata: getDefaultValues(metadata)
|
|
10662
10633
|
},
|
|
10663
|
-
resolver: zodResolver(
|
|
10634
|
+
resolver: zodResolver(MetadataSchema)
|
|
10664
10635
|
});
|
|
10665
|
-
const
|
|
10666
|
-
|
|
10667
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
10636
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
10637
|
+
const parsedData = parseValues(data);
|
|
10668
10638
|
await mutateAsync(
|
|
10669
|
-
{
|
|
10639
|
+
{
|
|
10640
|
+
metadata: parsedData
|
|
10641
|
+
},
|
|
10670
10642
|
{
|
|
10671
10643
|
onSuccess: () => {
|
|
10644
|
+
toast.success("Metadata updated");
|
|
10672
10645
|
handleSuccess();
|
|
10673
10646
|
},
|
|
10674
10647
|
onError: (error) => {
|
|
@@ -10677,278 +10650,47 @@ const BillingAddressForm = ({ order }) => {
|
|
|
10677
10650
|
}
|
|
10678
10651
|
);
|
|
10679
10652
|
});
|
|
10653
|
+
const { fields, insert, remove } = useFieldArray({
|
|
10654
|
+
control: form.control,
|
|
10655
|
+
name: "metadata"
|
|
10656
|
+
});
|
|
10657
|
+
function deleteRow(index) {
|
|
10658
|
+
remove(index);
|
|
10659
|
+
if (fields.length === 1) {
|
|
10660
|
+
insert(0, {
|
|
10661
|
+
key: "",
|
|
10662
|
+
value: "",
|
|
10663
|
+
disabled: false
|
|
10664
|
+
});
|
|
10665
|
+
}
|
|
10666
|
+
}
|
|
10667
|
+
function insertRow(index, position) {
|
|
10668
|
+
insert(index + (position === "above" ? 0 : 1), {
|
|
10669
|
+
key: "",
|
|
10670
|
+
value: "",
|
|
10671
|
+
disabled: false
|
|
10672
|
+
});
|
|
10673
|
+
}
|
|
10680
10674
|
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
10681
10675
|
KeyboundForm,
|
|
10682
10676
|
{
|
|
10677
|
+
onSubmit: handleSubmit,
|
|
10683
10678
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
10684
|
-
onSubmit,
|
|
10685
10679
|
children: [
|
|
10686
|
-
/* @__PURE__ */
|
|
10687
|
-
/* @__PURE__ */
|
|
10688
|
-
|
|
10689
|
-
|
|
10690
|
-
|
|
10691
|
-
|
|
10692
|
-
|
|
10693
|
-
|
|
10694
|
-
|
|
10695
|
-
|
|
10696
|
-
|
|
10697
|
-
}
|
|
10698
|
-
),
|
|
10699
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
10700
|
-
/* @__PURE__ */ jsx(
|
|
10701
|
-
Form$2.Field,
|
|
10702
|
-
{
|
|
10703
|
-
control: form.control,
|
|
10704
|
-
name: "first_name",
|
|
10705
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
10706
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
10707
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
10708
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10709
|
-
] })
|
|
10680
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: [
|
|
10681
|
+
/* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-1 divide-y rounded-lg", children: [
|
|
10682
|
+
/* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle grid grid-cols-2 divide-x rounded-t-lg", children: [
|
|
10683
|
+
/* @__PURE__ */ jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsx("label", { id: METADATA_KEY_LABEL_ID, children: "Key" }) }),
|
|
10684
|
+
/* @__PURE__ */ jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsx("label", { id: METADATA_VALUE_LABEL_ID, children: "Value" }) })
|
|
10685
|
+
] }),
|
|
10686
|
+
fields.map((field, index) => {
|
|
10687
|
+
const isDisabled = field.disabled || false;
|
|
10688
|
+
let placeholder = "-";
|
|
10689
|
+
if (typeof field.value === "object") {
|
|
10690
|
+
placeholder = "{ ... }";
|
|
10710
10691
|
}
|
|
10711
|
-
|
|
10712
|
-
|
|
10713
|
-
Form$2.Field,
|
|
10714
|
-
{
|
|
10715
|
-
control: form.control,
|
|
10716
|
-
name: "last_name",
|
|
10717
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
10718
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
10719
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
10720
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10721
|
-
] })
|
|
10722
|
-
}
|
|
10723
|
-
)
|
|
10724
|
-
] }),
|
|
10725
|
-
/* @__PURE__ */ jsx(
|
|
10726
|
-
Form$2.Field,
|
|
10727
|
-
{
|
|
10728
|
-
control: form.control,
|
|
10729
|
-
name: "company",
|
|
10730
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
10731
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
10732
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
10733
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10734
|
-
] })
|
|
10735
|
-
}
|
|
10736
|
-
),
|
|
10737
|
-
/* @__PURE__ */ jsx(
|
|
10738
|
-
Form$2.Field,
|
|
10739
|
-
{
|
|
10740
|
-
control: form.control,
|
|
10741
|
-
name: "address_1",
|
|
10742
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
10743
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
10744
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
10745
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10746
|
-
] })
|
|
10747
|
-
}
|
|
10748
|
-
),
|
|
10749
|
-
/* @__PURE__ */ jsx(
|
|
10750
|
-
Form$2.Field,
|
|
10751
|
-
{
|
|
10752
|
-
control: form.control,
|
|
10753
|
-
name: "address_2",
|
|
10754
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
10755
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
10756
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
10757
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10758
|
-
] })
|
|
10759
|
-
}
|
|
10760
|
-
),
|
|
10761
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
10762
|
-
/* @__PURE__ */ jsx(
|
|
10763
|
-
Form$2.Field,
|
|
10764
|
-
{
|
|
10765
|
-
control: form.control,
|
|
10766
|
-
name: "postal_code",
|
|
10767
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
10768
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
10769
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
10770
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10771
|
-
] })
|
|
10772
|
-
}
|
|
10773
|
-
),
|
|
10774
|
-
/* @__PURE__ */ jsx(
|
|
10775
|
-
Form$2.Field,
|
|
10776
|
-
{
|
|
10777
|
-
control: form.control,
|
|
10778
|
-
name: "city",
|
|
10779
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
10780
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
10781
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
10782
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10783
|
-
] })
|
|
10784
|
-
}
|
|
10785
|
-
)
|
|
10786
|
-
] }),
|
|
10787
|
-
/* @__PURE__ */ jsx(
|
|
10788
|
-
Form$2.Field,
|
|
10789
|
-
{
|
|
10790
|
-
control: form.control,
|
|
10791
|
-
name: "province",
|
|
10792
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
10793
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
10794
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
10795
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10796
|
-
] })
|
|
10797
|
-
}
|
|
10798
|
-
),
|
|
10799
|
-
/* @__PURE__ */ jsx(
|
|
10800
|
-
Form$2.Field,
|
|
10801
|
-
{
|
|
10802
|
-
control: form.control,
|
|
10803
|
-
name: "phone",
|
|
10804
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
10805
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
10806
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
10807
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10808
|
-
] })
|
|
10809
|
-
}
|
|
10810
|
-
)
|
|
10811
|
-
] }) }),
|
|
10812
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
10813
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
10814
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
10815
|
-
] }) })
|
|
10816
|
-
]
|
|
10817
|
-
}
|
|
10818
|
-
) });
|
|
10819
|
-
};
|
|
10820
|
-
const schema$3 = addressSchema;
|
|
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." }) })
|
|
10878
|
-
] }),
|
|
10879
|
-
!isReady ? /* @__PURE__ */ jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
|
|
10880
|
-
] });
|
|
10881
|
-
};
|
|
10882
|
-
const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
|
|
10883
|
-
const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
|
|
10884
|
-
const MetadataForm = ({ orderId, metadata }) => {
|
|
10885
|
-
const { handleSuccess } = useRouteModal();
|
|
10886
|
-
const hasUneditableRows = getHasUneditableRows(metadata);
|
|
10887
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
|
|
10888
|
-
const form = useForm({
|
|
10889
|
-
defaultValues: {
|
|
10890
|
-
metadata: getDefaultValues(metadata)
|
|
10891
|
-
},
|
|
10892
|
-
resolver: zodResolver(MetadataSchema)
|
|
10893
|
-
});
|
|
10894
|
-
const handleSubmit = form.handleSubmit(async (data) => {
|
|
10895
|
-
const parsedData = parseValues(data);
|
|
10896
|
-
await mutateAsync(
|
|
10897
|
-
{
|
|
10898
|
-
metadata: parsedData
|
|
10899
|
-
},
|
|
10900
|
-
{
|
|
10901
|
-
onSuccess: () => {
|
|
10902
|
-
toast.success("Metadata updated");
|
|
10903
|
-
handleSuccess();
|
|
10904
|
-
},
|
|
10905
|
-
onError: (error) => {
|
|
10906
|
-
toast.error(error.message);
|
|
10907
|
-
}
|
|
10908
|
-
}
|
|
10909
|
-
);
|
|
10910
|
-
});
|
|
10911
|
-
const { fields, insert, remove } = useFieldArray({
|
|
10912
|
-
control: form.control,
|
|
10913
|
-
name: "metadata"
|
|
10914
|
-
});
|
|
10915
|
-
function deleteRow(index) {
|
|
10916
|
-
remove(index);
|
|
10917
|
-
if (fields.length === 1) {
|
|
10918
|
-
insert(0, {
|
|
10919
|
-
key: "",
|
|
10920
|
-
value: "",
|
|
10921
|
-
disabled: false
|
|
10922
|
-
});
|
|
10923
|
-
}
|
|
10924
|
-
}
|
|
10925
|
-
function insertRow(index, position) {
|
|
10926
|
-
insert(index + (position === "above" ? 0 : 1), {
|
|
10927
|
-
key: "",
|
|
10928
|
-
value: "",
|
|
10929
|
-
disabled: false
|
|
10930
|
-
});
|
|
10931
|
-
}
|
|
10932
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
10933
|
-
KeyboundForm,
|
|
10934
|
-
{
|
|
10935
|
-
onSubmit: handleSubmit,
|
|
10936
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
10937
|
-
children: [
|
|
10938
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: [
|
|
10939
|
-
/* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-1 divide-y rounded-lg", children: [
|
|
10940
|
-
/* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle grid grid-cols-2 divide-x rounded-t-lg", children: [
|
|
10941
|
-
/* @__PURE__ */ jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsx("label", { id: METADATA_KEY_LABEL_ID, children: "Key" }) }),
|
|
10942
|
-
/* @__PURE__ */ jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsx("label", { id: METADATA_VALUE_LABEL_ID, children: "Value" }) })
|
|
10943
|
-
] }),
|
|
10944
|
-
fields.map((field, index) => {
|
|
10945
|
-
const isDisabled = field.disabled || false;
|
|
10946
|
-
let placeholder = "-";
|
|
10947
|
-
if (typeof field.value === "object") {
|
|
10948
|
-
placeholder = "{ ... }";
|
|
10949
|
-
}
|
|
10950
|
-
if (Array.isArray(field.value)) {
|
|
10951
|
-
placeholder = "[ ... ]";
|
|
10692
|
+
if (Array.isArray(field.value)) {
|
|
10693
|
+
placeholder = "[ ... ]";
|
|
10952
10694
|
}
|
|
10953
10695
|
return /* @__PURE__ */ jsx(
|
|
10954
10696
|
ConditionalTooltip,
|
|
@@ -11445,46 +11187,37 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11445
11187
|
}
|
|
11446
11188
|
return Array.from(promotionIds);
|
|
11447
11189
|
}
|
|
11448
|
-
const
|
|
11190
|
+
const Email = () => {
|
|
11449
11191
|
const { id } = useParams();
|
|
11450
|
-
const {
|
|
11451
|
-
|
|
11452
|
-
|
|
11453
|
-
fields: "+sales_channel_id"
|
|
11454
|
-
},
|
|
11455
|
-
{
|
|
11456
|
-
enabled: !!id
|
|
11457
|
-
}
|
|
11458
|
-
);
|
|
11192
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
11193
|
+
fields: "+email"
|
|
11194
|
+
});
|
|
11459
11195
|
if (isError) {
|
|
11460
11196
|
throw error;
|
|
11461
11197
|
}
|
|
11462
|
-
const
|
|
11198
|
+
const isReady = !isPending && !!order;
|
|
11463
11199
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11464
11200
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11465
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit
|
|
11466
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "
|
|
11201
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Email" }) }),
|
|
11202
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
11467
11203
|
] }),
|
|
11468
|
-
|
|
11204
|
+
isReady && /* @__PURE__ */ jsx(EmailForm, { order })
|
|
11469
11205
|
] });
|
|
11470
11206
|
};
|
|
11471
|
-
const
|
|
11207
|
+
const EmailForm = ({ order }) => {
|
|
11472
11208
|
const form = useForm({
|
|
11473
11209
|
defaultValues: {
|
|
11474
|
-
|
|
11210
|
+
email: order.email ?? ""
|
|
11475
11211
|
},
|
|
11476
|
-
resolver: zodResolver(schema$
|
|
11212
|
+
resolver: zodResolver(schema$4)
|
|
11477
11213
|
});
|
|
11478
11214
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11479
11215
|
const { handleSuccess } = useRouteModal();
|
|
11480
11216
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
11481
11217
|
await mutateAsync(
|
|
11482
|
-
{
|
|
11483
|
-
sales_channel_id: data.sales_channel_id
|
|
11484
|
-
},
|
|
11218
|
+
{ email: data.email },
|
|
11485
11219
|
{
|
|
11486
11220
|
onSuccess: () => {
|
|
11487
|
-
toast.success("Sales channel updated");
|
|
11488
11221
|
handleSuccess();
|
|
11489
11222
|
},
|
|
11490
11223
|
onError: (error) => {
|
|
@@ -11499,7 +11232,18 @@ const SalesChannelForm = ({ order }) => {
|
|
|
11499
11232
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
11500
11233
|
onSubmit,
|
|
11501
11234
|
children: [
|
|
11502
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
11235
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
11236
|
+
Form$2.Field,
|
|
11237
|
+
{
|
|
11238
|
+
control: form.control,
|
|
11239
|
+
name: "email",
|
|
11240
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11241
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
|
|
11242
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11243
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11244
|
+
] })
|
|
11245
|
+
}
|
|
11246
|
+
) }),
|
|
11503
11247
|
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11504
11248
|
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11505
11249
|
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
@@ -11508,103 +11252,49 @@ const SalesChannelForm = ({ order }) => {
|
|
|
11508
11252
|
}
|
|
11509
11253
|
) });
|
|
11510
11254
|
};
|
|
11511
|
-
const
|
|
11512
|
-
|
|
11513
|
-
|
|
11514
|
-
|
|
11255
|
+
const schema$4 = objectType({
|
|
11256
|
+
email: stringType().email()
|
|
11257
|
+
});
|
|
11258
|
+
const SalesChannel = () => {
|
|
11259
|
+
const { id } = useParams();
|
|
11260
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11261
|
+
id,
|
|
11262
|
+
{
|
|
11263
|
+
fields: "+sales_channel_id"
|
|
11515
11264
|
},
|
|
11516
|
-
queryKey: ["sales-channels"],
|
|
11517
|
-
getOptions: (data) => {
|
|
11518
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
11519
|
-
label: salesChannel.name,
|
|
11520
|
-
value: salesChannel.id
|
|
11521
|
-
}));
|
|
11522
|
-
},
|
|
11523
|
-
defaultValue: order.sales_channel_id || void 0
|
|
11524
|
-
});
|
|
11525
|
-
return /* @__PURE__ */ jsx(
|
|
11526
|
-
Form$2.Field,
|
|
11527
11265
|
{
|
|
11528
|
-
|
|
11529
|
-
name: "sales_channel_id",
|
|
11530
|
-
render: ({ field }) => {
|
|
11531
|
-
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11532
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11533
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
11534
|
-
Combobox,
|
|
11535
|
-
{
|
|
11536
|
-
options: salesChannels.options,
|
|
11537
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
11538
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11539
|
-
searchValue: salesChannels.searchValue,
|
|
11540
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11541
|
-
placeholder: "Select sales channel",
|
|
11542
|
-
...field
|
|
11543
|
-
}
|
|
11544
|
-
) }),
|
|
11545
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11546
|
-
] });
|
|
11547
|
-
}
|
|
11266
|
+
enabled: !!id
|
|
11548
11267
|
}
|
|
11549
11268
|
);
|
|
11550
|
-
};
|
|
11551
|
-
const schema$2 = objectType({
|
|
11552
|
-
sales_channel_id: stringType().min(1)
|
|
11553
|
-
});
|
|
11554
|
-
const ShippingAddress = () => {
|
|
11555
|
-
const { id } = useParams();
|
|
11556
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
11557
|
-
fields: "+shipping_address"
|
|
11558
|
-
});
|
|
11559
11269
|
if (isError) {
|
|
11560
11270
|
throw error;
|
|
11561
11271
|
}
|
|
11562
|
-
const
|
|
11272
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
11563
11273
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11564
11274
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11565
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit
|
|
11566
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", 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" }) })
|
|
11567
11277
|
] }),
|
|
11568
|
-
|
|
11278
|
+
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
11569
11279
|
] });
|
|
11570
11280
|
};
|
|
11571
|
-
const
|
|
11572
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
11281
|
+
const SalesChannelForm = ({ order }) => {
|
|
11573
11282
|
const form = useForm({
|
|
11574
11283
|
defaultValues: {
|
|
11575
|
-
|
|
11576
|
-
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
11577
|
-
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
11578
|
-
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
11579
|
-
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
11580
|
-
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
11581
|
-
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
11582
|
-
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
11583
|
-
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
11584
|
-
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
11284
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
11585
11285
|
},
|
|
11586
|
-
resolver: zodResolver(schema$
|
|
11286
|
+
resolver: zodResolver(schema$3)
|
|
11587
11287
|
});
|
|
11588
11288
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11589
11289
|
const { handleSuccess } = useRouteModal();
|
|
11590
11290
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
11591
11291
|
await mutateAsync(
|
|
11592
11292
|
{
|
|
11593
|
-
|
|
11594
|
-
first_name: data.first_name,
|
|
11595
|
-
last_name: data.last_name,
|
|
11596
|
-
company: data.company,
|
|
11597
|
-
address_1: data.address_1,
|
|
11598
|
-
address_2: data.address_2,
|
|
11599
|
-
city: data.city,
|
|
11600
|
-
province: data.province,
|
|
11601
|
-
country_code: data.country_code,
|
|
11602
|
-
postal_code: data.postal_code,
|
|
11603
|
-
phone: data.phone
|
|
11604
|
-
}
|
|
11293
|
+
sales_channel_id: data.sales_channel_id
|
|
11605
11294
|
},
|
|
11606
11295
|
{
|
|
11607
11296
|
onSuccess: () => {
|
|
11297
|
+
toast.success("Sales channel updated");
|
|
11608
11298
|
handleSuccess();
|
|
11609
11299
|
},
|
|
11610
11300
|
onError: (error) => {
|
|
@@ -11619,132 +11309,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
11619
11309
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
11620
11310
|
onSubmit,
|
|
11621
11311
|
children: [
|
|
11622
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */
|
|
11623
|
-
/* @__PURE__ */ jsx(
|
|
11624
|
-
Form$2.Field,
|
|
11625
|
-
{
|
|
11626
|
-
control: form.control,
|
|
11627
|
-
name: "country_code",
|
|
11628
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11629
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
11630
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
11631
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11632
|
-
] })
|
|
11633
|
-
}
|
|
11634
|
-
),
|
|
11635
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11636
|
-
/* @__PURE__ */ jsx(
|
|
11637
|
-
Form$2.Field,
|
|
11638
|
-
{
|
|
11639
|
-
control: form.control,
|
|
11640
|
-
name: "first_name",
|
|
11641
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11642
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
11643
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11644
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11645
|
-
] })
|
|
11646
|
-
}
|
|
11647
|
-
),
|
|
11648
|
-
/* @__PURE__ */ jsx(
|
|
11649
|
-
Form$2.Field,
|
|
11650
|
-
{
|
|
11651
|
-
control: form.control,
|
|
11652
|
-
name: "last_name",
|
|
11653
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11654
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
11655
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11656
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11657
|
-
] })
|
|
11658
|
-
}
|
|
11659
|
-
)
|
|
11660
|
-
] }),
|
|
11661
|
-
/* @__PURE__ */ jsx(
|
|
11662
|
-
Form$2.Field,
|
|
11663
|
-
{
|
|
11664
|
-
control: form.control,
|
|
11665
|
-
name: "company",
|
|
11666
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11667
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
11668
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11669
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11670
|
-
] })
|
|
11671
|
-
}
|
|
11672
|
-
),
|
|
11673
|
-
/* @__PURE__ */ jsx(
|
|
11674
|
-
Form$2.Field,
|
|
11675
|
-
{
|
|
11676
|
-
control: form.control,
|
|
11677
|
-
name: "address_1",
|
|
11678
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11679
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
11680
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11681
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11682
|
-
] })
|
|
11683
|
-
}
|
|
11684
|
-
),
|
|
11685
|
-
/* @__PURE__ */ jsx(
|
|
11686
|
-
Form$2.Field,
|
|
11687
|
-
{
|
|
11688
|
-
control: form.control,
|
|
11689
|
-
name: "address_2",
|
|
11690
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11691
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
11692
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11693
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11694
|
-
] })
|
|
11695
|
-
}
|
|
11696
|
-
),
|
|
11697
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11698
|
-
/* @__PURE__ */ jsx(
|
|
11699
|
-
Form$2.Field,
|
|
11700
|
-
{
|
|
11701
|
-
control: form.control,
|
|
11702
|
-
name: "postal_code",
|
|
11703
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11704
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
11705
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11706
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11707
|
-
] })
|
|
11708
|
-
}
|
|
11709
|
-
),
|
|
11710
|
-
/* @__PURE__ */ jsx(
|
|
11711
|
-
Form$2.Field,
|
|
11712
|
-
{
|
|
11713
|
-
control: form.control,
|
|
11714
|
-
name: "city",
|
|
11715
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11716
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
11717
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11718
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11719
|
-
] })
|
|
11720
|
-
}
|
|
11721
|
-
)
|
|
11722
|
-
] }),
|
|
11723
|
-
/* @__PURE__ */ jsx(
|
|
11724
|
-
Form$2.Field,
|
|
11725
|
-
{
|
|
11726
|
-
control: form.control,
|
|
11727
|
-
name: "province",
|
|
11728
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11729
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
11730
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11731
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11732
|
-
] })
|
|
11733
|
-
}
|
|
11734
|
-
),
|
|
11735
|
-
/* @__PURE__ */ jsx(
|
|
11736
|
-
Form$2.Field,
|
|
11737
|
-
{
|
|
11738
|
-
control: form.control,
|
|
11739
|
-
name: "phone",
|
|
11740
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11741
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
11742
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11743
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11744
|
-
] })
|
|
11745
|
-
}
|
|
11746
|
-
)
|
|
11747
|
-
] }) }),
|
|
11312
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11748
11313
|
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11749
11314
|
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11750
11315
|
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
@@ -11753,7 +11318,49 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
11753
11318
|
}
|
|
11754
11319
|
) });
|
|
11755
11320
|
};
|
|
11756
|
-
const
|
|
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
|
+
});
|
|
11757
11364
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11758
11365
|
const Shipping = () => {
|
|
11759
11366
|
var _a;
|
|
@@ -12561,18 +12168,221 @@ const CustomAmountField = ({
|
|
|
12561
12168
|
}
|
|
12562
12169
|
);
|
|
12563
12170
|
};
|
|
12564
|
-
const
|
|
12171
|
+
const ShippingAddress = () => {
|
|
12565
12172
|
const { id } = useParams();
|
|
12566
|
-
const {
|
|
12567
|
-
fields: "
|
|
12173
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
12174
|
+
fields: "+shipping_address"
|
|
12568
12175
|
});
|
|
12569
12176
|
if (isError) {
|
|
12570
12177
|
throw error;
|
|
12571
12178
|
}
|
|
12572
|
-
const isReady = !isPending && !!
|
|
12179
|
+
const isReady = !isPending && !!order;
|
|
12573
12180
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12574
12181
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12575
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "
|
|
12182
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
|
|
12183
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
12184
|
+
] }),
|
|
12185
|
+
isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
|
|
12186
|
+
] });
|
|
12187
|
+
};
|
|
12188
|
+
const ShippingAddressForm = ({ order }) => {
|
|
12189
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12190
|
+
const form = useForm({
|
|
12191
|
+
defaultValues: {
|
|
12192
|
+
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
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) ?? ""
|
|
12202
|
+
},
|
|
12203
|
+
resolver: zodResolver(schema$2)
|
|
12204
|
+
});
|
|
12205
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12206
|
+
const { handleSuccess } = useRouteModal();
|
|
12207
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12208
|
+
await mutateAsync(
|
|
12209
|
+
{
|
|
12210
|
+
shipping_address: {
|
|
12211
|
+
first_name: data.first_name,
|
|
12212
|
+
last_name: data.last_name,
|
|
12213
|
+
company: data.company,
|
|
12214
|
+
address_1: data.address_1,
|
|
12215
|
+
address_2: data.address_2,
|
|
12216
|
+
city: data.city,
|
|
12217
|
+
province: data.province,
|
|
12218
|
+
country_code: data.country_code,
|
|
12219
|
+
postal_code: data.postal_code,
|
|
12220
|
+
phone: data.phone
|
|
12221
|
+
}
|
|
12222
|
+
},
|
|
12223
|
+
{
|
|
12224
|
+
onSuccess: () => {
|
|
12225
|
+
handleSuccess();
|
|
12226
|
+
},
|
|
12227
|
+
onError: (error) => {
|
|
12228
|
+
toast.error(error.message);
|
|
12229
|
+
}
|
|
12230
|
+
}
|
|
12231
|
+
);
|
|
12232
|
+
});
|
|
12233
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12234
|
+
KeyboundForm,
|
|
12235
|
+
{
|
|
12236
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12237
|
+
onSubmit,
|
|
12238
|
+
children: [
|
|
12239
|
+
/* @__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: [
|
|
12240
|
+
/* @__PURE__ */ jsx(
|
|
12241
|
+
Form$2.Field,
|
|
12242
|
+
{
|
|
12243
|
+
control: form.control,
|
|
12244
|
+
name: "country_code",
|
|
12245
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12246
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
12247
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
12248
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12249
|
+
] })
|
|
12250
|
+
}
|
|
12251
|
+
),
|
|
12252
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12253
|
+
/* @__PURE__ */ jsx(
|
|
12254
|
+
Form$2.Field,
|
|
12255
|
+
{
|
|
12256
|
+
control: form.control,
|
|
12257
|
+
name: "first_name",
|
|
12258
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12259
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
12260
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12261
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12262
|
+
] })
|
|
12263
|
+
}
|
|
12264
|
+
),
|
|
12265
|
+
/* @__PURE__ */ jsx(
|
|
12266
|
+
Form$2.Field,
|
|
12267
|
+
{
|
|
12268
|
+
control: form.control,
|
|
12269
|
+
name: "last_name",
|
|
12270
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12271
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
12272
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12273
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12274
|
+
] })
|
|
12275
|
+
}
|
|
12276
|
+
)
|
|
12277
|
+
] }),
|
|
12278
|
+
/* @__PURE__ */ jsx(
|
|
12279
|
+
Form$2.Field,
|
|
12280
|
+
{
|
|
12281
|
+
control: form.control,
|
|
12282
|
+
name: "company",
|
|
12283
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12284
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12285
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12286
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12287
|
+
] })
|
|
12288
|
+
}
|
|
12289
|
+
),
|
|
12290
|
+
/* @__PURE__ */ jsx(
|
|
12291
|
+
Form$2.Field,
|
|
12292
|
+
{
|
|
12293
|
+
control: form.control,
|
|
12294
|
+
name: "address_1",
|
|
12295
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12296
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
12297
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12298
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12299
|
+
] })
|
|
12300
|
+
}
|
|
12301
|
+
),
|
|
12302
|
+
/* @__PURE__ */ jsx(
|
|
12303
|
+
Form$2.Field,
|
|
12304
|
+
{
|
|
12305
|
+
control: form.control,
|
|
12306
|
+
name: "address_2",
|
|
12307
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12308
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12309
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12310
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12311
|
+
] })
|
|
12312
|
+
}
|
|
12313
|
+
),
|
|
12314
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12315
|
+
/* @__PURE__ */ jsx(
|
|
12316
|
+
Form$2.Field,
|
|
12317
|
+
{
|
|
12318
|
+
control: form.control,
|
|
12319
|
+
name: "postal_code",
|
|
12320
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12321
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
12322
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12323
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12324
|
+
] })
|
|
12325
|
+
}
|
|
12326
|
+
),
|
|
12327
|
+
/* @__PURE__ */ jsx(
|
|
12328
|
+
Form$2.Field,
|
|
12329
|
+
{
|
|
12330
|
+
control: form.control,
|
|
12331
|
+
name: "city",
|
|
12332
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12333
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
12334
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12335
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12336
|
+
] })
|
|
12337
|
+
}
|
|
12338
|
+
)
|
|
12339
|
+
] }),
|
|
12340
|
+
/* @__PURE__ */ jsx(
|
|
12341
|
+
Form$2.Field,
|
|
12342
|
+
{
|
|
12343
|
+
control: form.control,
|
|
12344
|
+
name: "province",
|
|
12345
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12346
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
12347
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12348
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12349
|
+
] })
|
|
12350
|
+
}
|
|
12351
|
+
),
|
|
12352
|
+
/* @__PURE__ */ jsx(
|
|
12353
|
+
Form$2.Field,
|
|
12354
|
+
{
|
|
12355
|
+
control: form.control,
|
|
12356
|
+
name: "phone",
|
|
12357
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12358
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
12359
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12360
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12361
|
+
] })
|
|
12362
|
+
}
|
|
12363
|
+
)
|
|
12364
|
+
] }) }),
|
|
12365
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12366
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12367
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12368
|
+
] }) })
|
|
12369
|
+
]
|
|
12370
|
+
}
|
|
12371
|
+
) });
|
|
12372
|
+
};
|
|
12373
|
+
const schema$2 = addressSchema;
|
|
12374
|
+
const TransferOwnership = () => {
|
|
12375
|
+
const { id } = useParams();
|
|
12376
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
12377
|
+
fields: "id,customer_id,customer.*"
|
|
12378
|
+
});
|
|
12379
|
+
if (isError) {
|
|
12380
|
+
throw error;
|
|
12381
|
+
}
|
|
12382
|
+
const isReady = !isPending && !!draft_order;
|
|
12383
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12384
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12385
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Ownership" }) }),
|
|
12576
12386
|
/* @__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" }) })
|
|
12577
12387
|
] }),
|
|
12578
12388
|
isReady && /* @__PURE__ */ jsx(TransferOwnershipForm, { order: draft_order })
|
|
@@ -12584,7 +12394,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12584
12394
|
defaultValues: {
|
|
12585
12395
|
customer_id: order.customer_id || ""
|
|
12586
12396
|
},
|
|
12587
|
-
resolver: zodResolver(schema)
|
|
12397
|
+
resolver: zodResolver(schema$1)
|
|
12588
12398
|
});
|
|
12589
12399
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12590
12400
|
const { handleSuccess } = useRouteModal();
|
|
@@ -13034,9 +12844,199 @@ const Illustration = () => {
|
|
|
13034
12844
|
}
|
|
13035
12845
|
);
|
|
13036
12846
|
};
|
|
13037
|
-
const schema = objectType({
|
|
12847
|
+
const schema$1 = objectType({
|
|
13038
12848
|
customer_id: stringType().min(1)
|
|
13039
12849
|
});
|
|
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: [
|
|
@@ -13061,18 +13061,10 @@ const routeModule = {
|
|
|
13061
13061
|
Component: CustomItems,
|
|
13062
13062
|
path: "/draft-orders/:id/custom-items"
|
|
13063
13063
|
},
|
|
13064
|
-
{
|
|
13065
|
-
Component: Email,
|
|
13066
|
-
path: "/draft-orders/:id/email"
|
|
13067
|
-
},
|
|
13068
13064
|
{
|
|
13069
13065
|
Component: Items,
|
|
13070
13066
|
path: "/draft-orders/:id/items"
|
|
13071
13067
|
},
|
|
13072
|
-
{
|
|
13073
|
-
Component: BillingAddress,
|
|
13074
|
-
path: "/draft-orders/:id/billing-address"
|
|
13075
|
-
},
|
|
13076
13068
|
{
|
|
13077
13069
|
Component: Metadata,
|
|
13078
13070
|
path: "/draft-orders/:id/metadata"
|
|
@@ -13082,20 +13074,28 @@ const routeModule = {
|
|
|
13082
13074
|
path: "/draft-orders/:id/promotions"
|
|
13083
13075
|
},
|
|
13084
13076
|
{
|
|
13085
|
-
Component:
|
|
13086
|
-
path: "/draft-orders/:id/
|
|
13077
|
+
Component: Email,
|
|
13078
|
+
path: "/draft-orders/:id/email"
|
|
13087
13079
|
},
|
|
13088
13080
|
{
|
|
13089
|
-
Component:
|
|
13090
|
-
path: "/draft-orders/:id/
|
|
13081
|
+
Component: SalesChannel,
|
|
13082
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13091
13083
|
},
|
|
13092
13084
|
{
|
|
13093
13085
|
Component: Shipping,
|
|
13094
13086
|
path: "/draft-orders/:id/shipping"
|
|
13095
13087
|
},
|
|
13088
|
+
{
|
|
13089
|
+
Component: ShippingAddress,
|
|
13090
|
+
path: "/draft-orders/:id/shipping-address"
|
|
13091
|
+
},
|
|
13096
13092
|
{
|
|
13097
13093
|
Component: TransferOwnership,
|
|
13098
13094
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13095
|
+
},
|
|
13096
|
+
{
|
|
13097
|
+
Component: BillingAddress,
|
|
13098
|
+
path: "/draft-orders/:id/billing-address"
|
|
13099
13099
|
}
|
|
13100
13100
|
]
|
|
13101
13101
|
}
|