@medusajs/draft-order 2.10.4-preview-20250925031439 → 2.10.4-preview-20250925060158
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 +664 -664
- package/.medusa/server/src/admin/index.mjs +664 -664
- package/package.json +16 -16
|
@@ -9567,196 +9567,27 @@ const ID = () => {
|
|
|
9567
9567
|
/* @__PURE__ */ jsx(Outlet, {})
|
|
9568
9568
|
] });
|
|
9569
9569
|
};
|
|
9570
|
-
const
|
|
9571
|
-
const { id } = useParams();
|
|
9572
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
9573
|
-
fields: "+billing_address"
|
|
9574
|
-
});
|
|
9575
|
-
if (isError) {
|
|
9576
|
-
throw error;
|
|
9577
|
-
}
|
|
9578
|
-
const isReady = !isPending && !!order;
|
|
9570
|
+
const CustomItems = () => {
|
|
9579
9571
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9580
|
-
/* @__PURE__ */
|
|
9581
|
-
|
|
9582
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
9583
|
-
] }),
|
|
9584
|
-
isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
|
|
9572
|
+
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
9573
|
+
/* @__PURE__ */ jsx(CustomItemsForm, {})
|
|
9585
9574
|
] });
|
|
9586
9575
|
};
|
|
9587
|
-
const
|
|
9588
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
9576
|
+
const CustomItemsForm = () => {
|
|
9589
9577
|
const form = useForm({
|
|
9590
|
-
defaultValues: {
|
|
9591
|
-
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
9592
|
-
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
9593
|
-
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
9594
|
-
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
9595
|
-
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
9596
|
-
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
9597
|
-
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
9598
|
-
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
9599
|
-
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9600
|
-
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9601
|
-
},
|
|
9602
9578
|
resolver: zodResolver(schema$5)
|
|
9603
9579
|
});
|
|
9604
|
-
|
|
9605
|
-
|
|
9606
|
-
|
|
9607
|
-
|
|
9608
|
-
{
|
|
9609
|
-
|
|
9610
|
-
|
|
9611
|
-
handleSuccess();
|
|
9612
|
-
},
|
|
9613
|
-
onError: (error) => {
|
|
9614
|
-
toast.error(error.message);
|
|
9615
|
-
}
|
|
9616
|
-
}
|
|
9617
|
-
);
|
|
9618
|
-
});
|
|
9619
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
9620
|
-
KeyboundForm,
|
|
9621
|
-
{
|
|
9622
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
9623
|
-
onSubmit,
|
|
9624
|
-
children: [
|
|
9625
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
|
|
9626
|
-
/* @__PURE__ */ jsx(
|
|
9627
|
-
Form$2.Field,
|
|
9628
|
-
{
|
|
9629
|
-
control: form.control,
|
|
9630
|
-
name: "country_code",
|
|
9631
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9632
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
9633
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
9634
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9635
|
-
] })
|
|
9636
|
-
}
|
|
9637
|
-
),
|
|
9638
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9639
|
-
/* @__PURE__ */ jsx(
|
|
9640
|
-
Form$2.Field,
|
|
9641
|
-
{
|
|
9642
|
-
control: form.control,
|
|
9643
|
-
name: "first_name",
|
|
9644
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9645
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
9646
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9647
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9648
|
-
] })
|
|
9649
|
-
}
|
|
9650
|
-
),
|
|
9651
|
-
/* @__PURE__ */ jsx(
|
|
9652
|
-
Form$2.Field,
|
|
9653
|
-
{
|
|
9654
|
-
control: form.control,
|
|
9655
|
-
name: "last_name",
|
|
9656
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9657
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
9658
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9659
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9660
|
-
] })
|
|
9661
|
-
}
|
|
9662
|
-
)
|
|
9663
|
-
] }),
|
|
9664
|
-
/* @__PURE__ */ jsx(
|
|
9665
|
-
Form$2.Field,
|
|
9666
|
-
{
|
|
9667
|
-
control: form.control,
|
|
9668
|
-
name: "company",
|
|
9669
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9670
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
9671
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9672
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9673
|
-
] })
|
|
9674
|
-
}
|
|
9675
|
-
),
|
|
9676
|
-
/* @__PURE__ */ jsx(
|
|
9677
|
-
Form$2.Field,
|
|
9678
|
-
{
|
|
9679
|
-
control: form.control,
|
|
9680
|
-
name: "address_1",
|
|
9681
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9682
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
9683
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9684
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9685
|
-
] })
|
|
9686
|
-
}
|
|
9687
|
-
),
|
|
9688
|
-
/* @__PURE__ */ jsx(
|
|
9689
|
-
Form$2.Field,
|
|
9690
|
-
{
|
|
9691
|
-
control: form.control,
|
|
9692
|
-
name: "address_2",
|
|
9693
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9694
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
9695
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9696
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9697
|
-
] })
|
|
9698
|
-
}
|
|
9699
|
-
),
|
|
9700
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9701
|
-
/* @__PURE__ */ jsx(
|
|
9702
|
-
Form$2.Field,
|
|
9703
|
-
{
|
|
9704
|
-
control: form.control,
|
|
9705
|
-
name: "postal_code",
|
|
9706
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9707
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
9708
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9709
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9710
|
-
] })
|
|
9711
|
-
}
|
|
9712
|
-
),
|
|
9713
|
-
/* @__PURE__ */ jsx(
|
|
9714
|
-
Form$2.Field,
|
|
9715
|
-
{
|
|
9716
|
-
control: form.control,
|
|
9717
|
-
name: "city",
|
|
9718
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9719
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
9720
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9721
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9722
|
-
] })
|
|
9723
|
-
}
|
|
9724
|
-
)
|
|
9725
|
-
] }),
|
|
9726
|
-
/* @__PURE__ */ jsx(
|
|
9727
|
-
Form$2.Field,
|
|
9728
|
-
{
|
|
9729
|
-
control: form.control,
|
|
9730
|
-
name: "province",
|
|
9731
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9732
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
9733
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9734
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9735
|
-
] })
|
|
9736
|
-
}
|
|
9737
|
-
),
|
|
9738
|
-
/* @__PURE__ */ jsx(
|
|
9739
|
-
Form$2.Field,
|
|
9740
|
-
{
|
|
9741
|
-
control: form.control,
|
|
9742
|
-
name: "phone",
|
|
9743
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9744
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
9745
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9746
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9747
|
-
] })
|
|
9748
|
-
}
|
|
9749
|
-
)
|
|
9750
|
-
] }) }),
|
|
9751
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9752
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9753
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9754
|
-
] }) })
|
|
9755
|
-
]
|
|
9756
|
-
}
|
|
9757
|
-
) });
|
|
9580
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9581
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
9582
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9583
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9584
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
|
|
9585
|
+
] }) })
|
|
9586
|
+
] }) });
|
|
9758
9587
|
};
|
|
9759
|
-
const schema$5 =
|
|
9588
|
+
const schema$5 = objectType({
|
|
9589
|
+
email: stringType().email()
|
|
9590
|
+
});
|
|
9760
9591
|
const Email = () => {
|
|
9761
9592
|
const { id } = useParams();
|
|
9762
9593
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -10799,54 +10630,10 @@ const customItemSchema = objectType({
|
|
|
10799
10630
|
quantity: numberType(),
|
|
10800
10631
|
unit_price: unionType([numberType(), stringType()])
|
|
10801
10632
|
});
|
|
10802
|
-
const
|
|
10803
|
-
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
10804
|
-
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
10805
|
-
return /* @__PURE__ */ jsxs(
|
|
10806
|
-
"div",
|
|
10807
|
-
{
|
|
10808
|
-
ref,
|
|
10809
|
-
className: clx(
|
|
10810
|
-
"bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
|
|
10811
|
-
className
|
|
10812
|
-
),
|
|
10813
|
-
...props,
|
|
10814
|
-
children: [
|
|
10815
|
-
/* @__PURE__ */ jsx(
|
|
10816
|
-
"div",
|
|
10817
|
-
{
|
|
10818
|
-
role: "presentation",
|
|
10819
|
-
className: clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
|
|
10820
|
-
"bg-ui-tag-orange-icon": variant === "warning"
|
|
10821
|
-
})
|
|
10822
|
-
}
|
|
10823
|
-
),
|
|
10824
|
-
/* @__PURE__ */ jsxs("div", { className: "text-pretty", children: [
|
|
10825
|
-
/* @__PURE__ */ jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
|
|
10826
|
-
labelValue,
|
|
10827
|
-
":"
|
|
10828
|
-
] }),
|
|
10829
|
-
" ",
|
|
10830
|
-
children
|
|
10831
|
-
] })
|
|
10832
|
-
]
|
|
10833
|
-
}
|
|
10834
|
-
);
|
|
10835
|
-
}
|
|
10836
|
-
);
|
|
10837
|
-
InlineTip.displayName = "InlineTip";
|
|
10838
|
-
const MetadataFieldSchema = objectType({
|
|
10839
|
-
key: stringType(),
|
|
10840
|
-
disabled: booleanType().optional(),
|
|
10841
|
-
value: anyType()
|
|
10842
|
-
});
|
|
10843
|
-
const MetadataSchema = objectType({
|
|
10844
|
-
metadata: arrayType(MetadataFieldSchema)
|
|
10845
|
-
});
|
|
10846
|
-
const Metadata = () => {
|
|
10633
|
+
const BillingAddress = () => {
|
|
10847
10634
|
const { id } = useParams();
|
|
10848
10635
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
10849
|
-
fields: "
|
|
10636
|
+
fields: "+billing_address"
|
|
10850
10637
|
});
|
|
10851
10638
|
if (isError) {
|
|
10852
10639
|
throw error;
|
|
@@ -10854,19 +10641,253 @@ const Metadata = () => {
|
|
|
10854
10641
|
const isReady = !isPending && !!order;
|
|
10855
10642
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
10856
10643
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
10857
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "
|
|
10858
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "
|
|
10644
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
|
|
10645
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
10859
10646
|
] }),
|
|
10860
|
-
|
|
10647
|
+
isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
|
|
10861
10648
|
] });
|
|
10862
10649
|
};
|
|
10863
|
-
const
|
|
10864
|
-
|
|
10865
|
-
const
|
|
10866
|
-
|
|
10867
|
-
|
|
10868
|
-
|
|
10869
|
-
|
|
10650
|
+
const BillingAddressForm = ({ order }) => {
|
|
10651
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
10652
|
+
const form = useForm({
|
|
10653
|
+
defaultValues: {
|
|
10654
|
+
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
10655
|
+
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
10656
|
+
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
10657
|
+
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
10658
|
+
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
10659
|
+
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
10660
|
+
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
10661
|
+
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
10662
|
+
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
10663
|
+
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
10664
|
+
},
|
|
10665
|
+
resolver: zodResolver(schema$3)
|
|
10666
|
+
});
|
|
10667
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
10668
|
+
const { handleSuccess } = useRouteModal();
|
|
10669
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
10670
|
+
await mutateAsync(
|
|
10671
|
+
{ billing_address: data },
|
|
10672
|
+
{
|
|
10673
|
+
onSuccess: () => {
|
|
10674
|
+
handleSuccess();
|
|
10675
|
+
},
|
|
10676
|
+
onError: (error) => {
|
|
10677
|
+
toast.error(error.message);
|
|
10678
|
+
}
|
|
10679
|
+
}
|
|
10680
|
+
);
|
|
10681
|
+
});
|
|
10682
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
10683
|
+
KeyboundForm,
|
|
10684
|
+
{
|
|
10685
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
10686
|
+
onSubmit,
|
|
10687
|
+
children: [
|
|
10688
|
+
/* @__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: [
|
|
10689
|
+
/* @__PURE__ */ jsx(
|
|
10690
|
+
Form$2.Field,
|
|
10691
|
+
{
|
|
10692
|
+
control: form.control,
|
|
10693
|
+
name: "country_code",
|
|
10694
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
10695
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
10696
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
10697
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10698
|
+
] })
|
|
10699
|
+
}
|
|
10700
|
+
),
|
|
10701
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
10702
|
+
/* @__PURE__ */ jsx(
|
|
10703
|
+
Form$2.Field,
|
|
10704
|
+
{
|
|
10705
|
+
control: form.control,
|
|
10706
|
+
name: "first_name",
|
|
10707
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
10708
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
10709
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
10710
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10711
|
+
] })
|
|
10712
|
+
}
|
|
10713
|
+
),
|
|
10714
|
+
/* @__PURE__ */ jsx(
|
|
10715
|
+
Form$2.Field,
|
|
10716
|
+
{
|
|
10717
|
+
control: form.control,
|
|
10718
|
+
name: "last_name",
|
|
10719
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
10720
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
10721
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
10722
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10723
|
+
] })
|
|
10724
|
+
}
|
|
10725
|
+
)
|
|
10726
|
+
] }),
|
|
10727
|
+
/* @__PURE__ */ jsx(
|
|
10728
|
+
Form$2.Field,
|
|
10729
|
+
{
|
|
10730
|
+
control: form.control,
|
|
10731
|
+
name: "company",
|
|
10732
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
10733
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
10734
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
10735
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10736
|
+
] })
|
|
10737
|
+
}
|
|
10738
|
+
),
|
|
10739
|
+
/* @__PURE__ */ jsx(
|
|
10740
|
+
Form$2.Field,
|
|
10741
|
+
{
|
|
10742
|
+
control: form.control,
|
|
10743
|
+
name: "address_1",
|
|
10744
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
10745
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
10746
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
10747
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10748
|
+
] })
|
|
10749
|
+
}
|
|
10750
|
+
),
|
|
10751
|
+
/* @__PURE__ */ jsx(
|
|
10752
|
+
Form$2.Field,
|
|
10753
|
+
{
|
|
10754
|
+
control: form.control,
|
|
10755
|
+
name: "address_2",
|
|
10756
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
10757
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
10758
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
10759
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10760
|
+
] })
|
|
10761
|
+
}
|
|
10762
|
+
),
|
|
10763
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
10764
|
+
/* @__PURE__ */ jsx(
|
|
10765
|
+
Form$2.Field,
|
|
10766
|
+
{
|
|
10767
|
+
control: form.control,
|
|
10768
|
+
name: "postal_code",
|
|
10769
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
10770
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
10771
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
10772
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10773
|
+
] })
|
|
10774
|
+
}
|
|
10775
|
+
),
|
|
10776
|
+
/* @__PURE__ */ jsx(
|
|
10777
|
+
Form$2.Field,
|
|
10778
|
+
{
|
|
10779
|
+
control: form.control,
|
|
10780
|
+
name: "city",
|
|
10781
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
10782
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
10783
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
10784
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10785
|
+
] })
|
|
10786
|
+
}
|
|
10787
|
+
)
|
|
10788
|
+
] }),
|
|
10789
|
+
/* @__PURE__ */ jsx(
|
|
10790
|
+
Form$2.Field,
|
|
10791
|
+
{
|
|
10792
|
+
control: form.control,
|
|
10793
|
+
name: "province",
|
|
10794
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
10795
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
10796
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
10797
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10798
|
+
] })
|
|
10799
|
+
}
|
|
10800
|
+
),
|
|
10801
|
+
/* @__PURE__ */ jsx(
|
|
10802
|
+
Form$2.Field,
|
|
10803
|
+
{
|
|
10804
|
+
control: form.control,
|
|
10805
|
+
name: "phone",
|
|
10806
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
10807
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
10808
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
10809
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10810
|
+
] })
|
|
10811
|
+
}
|
|
10812
|
+
)
|
|
10813
|
+
] }) }),
|
|
10814
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
10815
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
10816
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
10817
|
+
] }) })
|
|
10818
|
+
]
|
|
10819
|
+
}
|
|
10820
|
+
) });
|
|
10821
|
+
};
|
|
10822
|
+
const schema$3 = addressSchema;
|
|
10823
|
+
const InlineTip = forwardRef(
|
|
10824
|
+
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
10825
|
+
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
10826
|
+
return /* @__PURE__ */ jsxs(
|
|
10827
|
+
"div",
|
|
10828
|
+
{
|
|
10829
|
+
ref,
|
|
10830
|
+
className: clx(
|
|
10831
|
+
"bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
|
|
10832
|
+
className
|
|
10833
|
+
),
|
|
10834
|
+
...props,
|
|
10835
|
+
children: [
|
|
10836
|
+
/* @__PURE__ */ jsx(
|
|
10837
|
+
"div",
|
|
10838
|
+
{
|
|
10839
|
+
role: "presentation",
|
|
10840
|
+
className: clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
|
|
10841
|
+
"bg-ui-tag-orange-icon": variant === "warning"
|
|
10842
|
+
})
|
|
10843
|
+
}
|
|
10844
|
+
),
|
|
10845
|
+
/* @__PURE__ */ jsxs("div", { className: "text-pretty", children: [
|
|
10846
|
+
/* @__PURE__ */ jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
|
|
10847
|
+
labelValue,
|
|
10848
|
+
":"
|
|
10849
|
+
] }),
|
|
10850
|
+
" ",
|
|
10851
|
+
children
|
|
10852
|
+
] })
|
|
10853
|
+
]
|
|
10854
|
+
}
|
|
10855
|
+
);
|
|
10856
|
+
}
|
|
10857
|
+
);
|
|
10858
|
+
InlineTip.displayName = "InlineTip";
|
|
10859
|
+
const MetadataFieldSchema = objectType({
|
|
10860
|
+
key: stringType(),
|
|
10861
|
+
disabled: booleanType().optional(),
|
|
10862
|
+
value: anyType()
|
|
10863
|
+
});
|
|
10864
|
+
const MetadataSchema = objectType({
|
|
10865
|
+
metadata: arrayType(MetadataFieldSchema)
|
|
10866
|
+
});
|
|
10867
|
+
const Metadata = () => {
|
|
10868
|
+
const { id } = useParams();
|
|
10869
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
10870
|
+
fields: "metadata"
|
|
10871
|
+
});
|
|
10872
|
+
if (isError) {
|
|
10873
|
+
throw error;
|
|
10874
|
+
}
|
|
10875
|
+
const isReady = !isPending && !!order;
|
|
10876
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
10877
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
10878
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Metadata" }) }),
|
|
10879
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
|
|
10880
|
+
] }),
|
|
10881
|
+
!isReady ? /* @__PURE__ */ jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
|
|
10882
|
+
] });
|
|
10883
|
+
};
|
|
10884
|
+
const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
|
|
10885
|
+
const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
|
|
10886
|
+
const MetadataForm = ({ orderId, metadata }) => {
|
|
10887
|
+
const { handleSuccess } = useRouteModal();
|
|
10888
|
+
const hasUneditableRows = getHasUneditableRows(metadata);
|
|
10889
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
|
|
10890
|
+
const form = useForm({
|
|
10870
10891
|
defaultValues: {
|
|
10871
10892
|
metadata: getDefaultValues(metadata)
|
|
10872
10893
|
},
|
|
@@ -11426,22 +11447,128 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11426
11447
|
}
|
|
11427
11448
|
return Array.from(promotionIds);
|
|
11428
11449
|
}
|
|
11429
|
-
const
|
|
11430
|
-
const Shipping = () => {
|
|
11431
|
-
var _a;
|
|
11450
|
+
const SalesChannel = () => {
|
|
11432
11451
|
const { id } = useParams();
|
|
11433
|
-
const {
|
|
11434
|
-
|
|
11435
|
-
|
|
11436
|
-
|
|
11437
|
-
|
|
11438
|
-
|
|
11439
|
-
|
|
11440
|
-
|
|
11441
|
-
|
|
11442
|
-
|
|
11443
|
-
|
|
11444
|
-
|
|
11452
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11453
|
+
id,
|
|
11454
|
+
{
|
|
11455
|
+
fields: "+sales_channel_id"
|
|
11456
|
+
},
|
|
11457
|
+
{
|
|
11458
|
+
enabled: !!id
|
|
11459
|
+
}
|
|
11460
|
+
);
|
|
11461
|
+
if (isError) {
|
|
11462
|
+
throw error;
|
|
11463
|
+
}
|
|
11464
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
11465
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11466
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11467
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
11468
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
11469
|
+
] }),
|
|
11470
|
+
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
11471
|
+
] });
|
|
11472
|
+
};
|
|
11473
|
+
const SalesChannelForm = ({ order }) => {
|
|
11474
|
+
const form = useForm({
|
|
11475
|
+
defaultValues: {
|
|
11476
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
11477
|
+
},
|
|
11478
|
+
resolver: zodResolver(schema$2)
|
|
11479
|
+
});
|
|
11480
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11481
|
+
const { handleSuccess } = useRouteModal();
|
|
11482
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11483
|
+
await mutateAsync(
|
|
11484
|
+
{
|
|
11485
|
+
sales_channel_id: data.sales_channel_id
|
|
11486
|
+
},
|
|
11487
|
+
{
|
|
11488
|
+
onSuccess: () => {
|
|
11489
|
+
toast.success("Sales channel updated");
|
|
11490
|
+
handleSuccess();
|
|
11491
|
+
},
|
|
11492
|
+
onError: (error) => {
|
|
11493
|
+
toast.error(error.message);
|
|
11494
|
+
}
|
|
11495
|
+
}
|
|
11496
|
+
);
|
|
11497
|
+
});
|
|
11498
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11499
|
+
KeyboundForm,
|
|
11500
|
+
{
|
|
11501
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11502
|
+
onSubmit,
|
|
11503
|
+
children: [
|
|
11504
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11505
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11506
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11507
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11508
|
+
] }) })
|
|
11509
|
+
]
|
|
11510
|
+
}
|
|
11511
|
+
) });
|
|
11512
|
+
};
|
|
11513
|
+
const SalesChannelField = ({ control, order }) => {
|
|
11514
|
+
const salesChannels = useComboboxData({
|
|
11515
|
+
queryFn: async (params) => {
|
|
11516
|
+
return await sdk.admin.salesChannel.list(params);
|
|
11517
|
+
},
|
|
11518
|
+
queryKey: ["sales-channels"],
|
|
11519
|
+
getOptions: (data) => {
|
|
11520
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
11521
|
+
label: salesChannel.name,
|
|
11522
|
+
value: salesChannel.id
|
|
11523
|
+
}));
|
|
11524
|
+
},
|
|
11525
|
+
defaultValue: order.sales_channel_id || void 0
|
|
11526
|
+
});
|
|
11527
|
+
return /* @__PURE__ */ jsx(
|
|
11528
|
+
Form$2.Field,
|
|
11529
|
+
{
|
|
11530
|
+
control,
|
|
11531
|
+
name: "sales_channel_id",
|
|
11532
|
+
render: ({ field }) => {
|
|
11533
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11534
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11535
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
11536
|
+
Combobox,
|
|
11537
|
+
{
|
|
11538
|
+
options: salesChannels.options,
|
|
11539
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
11540
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11541
|
+
searchValue: salesChannels.searchValue,
|
|
11542
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11543
|
+
placeholder: "Select sales channel",
|
|
11544
|
+
...field
|
|
11545
|
+
}
|
|
11546
|
+
) }),
|
|
11547
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11548
|
+
] });
|
|
11549
|
+
}
|
|
11550
|
+
}
|
|
11551
|
+
);
|
|
11552
|
+
};
|
|
11553
|
+
const schema$2 = objectType({
|
|
11554
|
+
sales_channel_id: stringType().min(1)
|
|
11555
|
+
});
|
|
11556
|
+
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11557
|
+
const Shipping = () => {
|
|
11558
|
+
var _a;
|
|
11559
|
+
const { id } = useParams();
|
|
11560
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
11561
|
+
fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
|
|
11562
|
+
});
|
|
11563
|
+
const {
|
|
11564
|
+
order: preview,
|
|
11565
|
+
isPending: isPreviewPending,
|
|
11566
|
+
isError: isPreviewError,
|
|
11567
|
+
error: previewError
|
|
11568
|
+
} = useOrderPreview(id);
|
|
11569
|
+
useInitiateOrderEdit({ preview });
|
|
11570
|
+
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11571
|
+
if (isError) {
|
|
11445
11572
|
throw error;
|
|
11446
11573
|
}
|
|
11447
11574
|
if (isPreviewError) {
|
|
@@ -12233,44 +12360,60 @@ const CustomAmountField = ({
|
|
|
12233
12360
|
}
|
|
12234
12361
|
);
|
|
12235
12362
|
};
|
|
12236
|
-
const
|
|
12363
|
+
const ShippingAddress = () => {
|
|
12237
12364
|
const { id } = useParams();
|
|
12238
|
-
const {
|
|
12239
|
-
fields: "
|
|
12365
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
12366
|
+
fields: "+shipping_address"
|
|
12240
12367
|
});
|
|
12241
12368
|
if (isError) {
|
|
12242
12369
|
throw error;
|
|
12243
12370
|
}
|
|
12244
|
-
const isReady = !isPending && !!
|
|
12371
|
+
const isReady = !isPending && !!order;
|
|
12245
12372
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12246
12373
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12247
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "
|
|
12248
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "
|
|
12374
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
|
|
12375
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
12249
12376
|
] }),
|
|
12250
|
-
isReady && /* @__PURE__ */ jsx(
|
|
12377
|
+
isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
|
|
12251
12378
|
] });
|
|
12252
12379
|
};
|
|
12253
|
-
const
|
|
12254
|
-
var _a, _b;
|
|
12380
|
+
const ShippingAddressForm = ({ order }) => {
|
|
12381
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12255
12382
|
const form = useForm({
|
|
12256
12383
|
defaultValues: {
|
|
12257
|
-
|
|
12384
|
+
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12385
|
+
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12386
|
+
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12387
|
+
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12388
|
+
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12389
|
+
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12390
|
+
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12391
|
+
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12392
|
+
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12393
|
+
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12258
12394
|
},
|
|
12259
|
-
resolver: zodResolver(schema$
|
|
12395
|
+
resolver: zodResolver(schema$1)
|
|
12260
12396
|
});
|
|
12261
12397
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12262
12398
|
const { handleSuccess } = useRouteModal();
|
|
12263
|
-
const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
|
|
12264
|
-
const currentCustomer = order.customer ? {
|
|
12265
|
-
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
12266
|
-
value: order.customer.id
|
|
12267
|
-
} : null;
|
|
12268
12399
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
12269
12400
|
await mutateAsync(
|
|
12270
|
-
{
|
|
12401
|
+
{
|
|
12402
|
+
shipping_address: {
|
|
12403
|
+
first_name: data.first_name,
|
|
12404
|
+
last_name: data.last_name,
|
|
12405
|
+
company: data.company,
|
|
12406
|
+
address_1: data.address_1,
|
|
12407
|
+
address_2: data.address_2,
|
|
12408
|
+
city: data.city,
|
|
12409
|
+
province: data.province,
|
|
12410
|
+
country_code: data.country_code,
|
|
12411
|
+
postal_code: data.postal_code,
|
|
12412
|
+
phone: data.phone
|
|
12413
|
+
}
|
|
12414
|
+
},
|
|
12271
12415
|
{
|
|
12272
12416
|
onSuccess: () => {
|
|
12273
|
-
toast.success("Customer updated");
|
|
12274
12417
|
handleSuccess();
|
|
12275
12418
|
},
|
|
12276
12419
|
onError: (error) => {
|
|
@@ -12285,50 +12428,237 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12285
12428
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
12286
12429
|
onSubmit,
|
|
12287
12430
|
children: [
|
|
12288
|
-
/* @__PURE__ */
|
|
12289
|
-
/* @__PURE__ */ jsx(
|
|
12290
|
-
|
|
12291
|
-
|
|
12292
|
-
|
|
12293
|
-
|
|
12294
|
-
|
|
12295
|
-
|
|
12296
|
-
|
|
12297
|
-
|
|
12298
|
-
|
|
12431
|
+
/* @__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: [
|
|
12432
|
+
/* @__PURE__ */ jsx(
|
|
12433
|
+
Form$2.Field,
|
|
12434
|
+
{
|
|
12435
|
+
control: form.control,
|
|
12436
|
+
name: "country_code",
|
|
12437
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12438
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
12439
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
12440
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12441
|
+
] })
|
|
12442
|
+
}
|
|
12443
|
+
),
|
|
12444
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12445
|
+
/* @__PURE__ */ jsx(
|
|
12446
|
+
Form$2.Field,
|
|
12447
|
+
{
|
|
12448
|
+
control: form.control,
|
|
12449
|
+
name: "first_name",
|
|
12450
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12451
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
12452
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12453
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12454
|
+
] })
|
|
12455
|
+
}
|
|
12456
|
+
),
|
|
12457
|
+
/* @__PURE__ */ jsx(
|
|
12458
|
+
Form$2.Field,
|
|
12459
|
+
{
|
|
12460
|
+
control: form.control,
|
|
12461
|
+
name: "last_name",
|
|
12462
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12463
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
12464
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12465
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12466
|
+
] })
|
|
12467
|
+
}
|
|
12468
|
+
)
|
|
12299
12469
|
] }),
|
|
12300
12470
|
/* @__PURE__ */ jsx(
|
|
12301
|
-
|
|
12471
|
+
Form$2.Field,
|
|
12302
12472
|
{
|
|
12303
12473
|
control: form.control,
|
|
12304
|
-
|
|
12474
|
+
name: "company",
|
|
12475
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12476
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12477
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12478
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12479
|
+
] })
|
|
12305
12480
|
}
|
|
12306
|
-
)
|
|
12307
|
-
|
|
12308
|
-
|
|
12309
|
-
|
|
12310
|
-
|
|
12311
|
-
|
|
12312
|
-
|
|
12313
|
-
|
|
12314
|
-
|
|
12315
|
-
}
|
|
12316
|
-
|
|
12317
|
-
|
|
12318
|
-
|
|
12319
|
-
|
|
12320
|
-
|
|
12321
|
-
|
|
12322
|
-
|
|
12323
|
-
|
|
12324
|
-
|
|
12325
|
-
|
|
12326
|
-
|
|
12327
|
-
|
|
12328
|
-
|
|
12329
|
-
|
|
12330
|
-
|
|
12331
|
-
|
|
12481
|
+
),
|
|
12482
|
+
/* @__PURE__ */ jsx(
|
|
12483
|
+
Form$2.Field,
|
|
12484
|
+
{
|
|
12485
|
+
control: form.control,
|
|
12486
|
+
name: "address_1",
|
|
12487
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12488
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
12489
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12490
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12491
|
+
] })
|
|
12492
|
+
}
|
|
12493
|
+
),
|
|
12494
|
+
/* @__PURE__ */ jsx(
|
|
12495
|
+
Form$2.Field,
|
|
12496
|
+
{
|
|
12497
|
+
control: form.control,
|
|
12498
|
+
name: "address_2",
|
|
12499
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12500
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12501
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12502
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12503
|
+
] })
|
|
12504
|
+
}
|
|
12505
|
+
),
|
|
12506
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12507
|
+
/* @__PURE__ */ jsx(
|
|
12508
|
+
Form$2.Field,
|
|
12509
|
+
{
|
|
12510
|
+
control: form.control,
|
|
12511
|
+
name: "postal_code",
|
|
12512
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12513
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
12514
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12515
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12516
|
+
] })
|
|
12517
|
+
}
|
|
12518
|
+
),
|
|
12519
|
+
/* @__PURE__ */ jsx(
|
|
12520
|
+
Form$2.Field,
|
|
12521
|
+
{
|
|
12522
|
+
control: form.control,
|
|
12523
|
+
name: "city",
|
|
12524
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12525
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
12526
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12527
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12528
|
+
] })
|
|
12529
|
+
}
|
|
12530
|
+
)
|
|
12531
|
+
] }),
|
|
12532
|
+
/* @__PURE__ */ jsx(
|
|
12533
|
+
Form$2.Field,
|
|
12534
|
+
{
|
|
12535
|
+
control: form.control,
|
|
12536
|
+
name: "province",
|
|
12537
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12538
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
12539
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12540
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12541
|
+
] })
|
|
12542
|
+
}
|
|
12543
|
+
),
|
|
12544
|
+
/* @__PURE__ */ jsx(
|
|
12545
|
+
Form$2.Field,
|
|
12546
|
+
{
|
|
12547
|
+
control: form.control,
|
|
12548
|
+
name: "phone",
|
|
12549
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12550
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
12551
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12552
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12553
|
+
] })
|
|
12554
|
+
}
|
|
12555
|
+
)
|
|
12556
|
+
] }) }),
|
|
12557
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12558
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12559
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12560
|
+
] }) })
|
|
12561
|
+
]
|
|
12562
|
+
}
|
|
12563
|
+
) });
|
|
12564
|
+
};
|
|
12565
|
+
const schema$1 = addressSchema;
|
|
12566
|
+
const TransferOwnership = () => {
|
|
12567
|
+
const { id } = useParams();
|
|
12568
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
12569
|
+
fields: "id,customer_id,customer.*"
|
|
12570
|
+
});
|
|
12571
|
+
if (isError) {
|
|
12572
|
+
throw error;
|
|
12573
|
+
}
|
|
12574
|
+
const isReady = !isPending && !!draft_order;
|
|
12575
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12576
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12577
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Ownership" }) }),
|
|
12578
|
+
/* @__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" }) })
|
|
12579
|
+
] }),
|
|
12580
|
+
isReady && /* @__PURE__ */ jsx(TransferOwnershipForm, { order: draft_order })
|
|
12581
|
+
] });
|
|
12582
|
+
};
|
|
12583
|
+
const TransferOwnershipForm = ({ order }) => {
|
|
12584
|
+
var _a, _b;
|
|
12585
|
+
const form = useForm({
|
|
12586
|
+
defaultValues: {
|
|
12587
|
+
customer_id: order.customer_id || ""
|
|
12588
|
+
},
|
|
12589
|
+
resolver: zodResolver(schema)
|
|
12590
|
+
});
|
|
12591
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12592
|
+
const { handleSuccess } = useRouteModal();
|
|
12593
|
+
const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
|
|
12594
|
+
const currentCustomer = order.customer ? {
|
|
12595
|
+
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
12596
|
+
value: order.customer.id
|
|
12597
|
+
} : null;
|
|
12598
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12599
|
+
await mutateAsync(
|
|
12600
|
+
{ customer_id: data.customer_id },
|
|
12601
|
+
{
|
|
12602
|
+
onSuccess: () => {
|
|
12603
|
+
toast.success("Customer updated");
|
|
12604
|
+
handleSuccess();
|
|
12605
|
+
},
|
|
12606
|
+
onError: (error) => {
|
|
12607
|
+
toast.error(error.message);
|
|
12608
|
+
}
|
|
12609
|
+
}
|
|
12610
|
+
);
|
|
12611
|
+
});
|
|
12612
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12613
|
+
KeyboundForm,
|
|
12614
|
+
{
|
|
12615
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12616
|
+
onSubmit,
|
|
12617
|
+
children: [
|
|
12618
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
12619
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsx(Illustration, {}) }),
|
|
12620
|
+
currentCustomer && /* @__PURE__ */ jsxs("div", { className: "flex flex-col space-y-3", children: [
|
|
12621
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
12622
|
+
/* @__PURE__ */ jsx(Label$1, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
|
|
12623
|
+
/* @__PURE__ */ jsx(Hint$1, { children: "The customer that is currently associated with this draft order." })
|
|
12624
|
+
] }),
|
|
12625
|
+
/* @__PURE__ */ jsxs(Select, { disabled: true, value: currentCustomer.value, children: [
|
|
12626
|
+
/* @__PURE__ */ jsx(Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsx(Select.Value, {}) }),
|
|
12627
|
+
/* @__PURE__ */ jsx(Select.Content, { children: /* @__PURE__ */ jsx(Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
|
|
12628
|
+
] })
|
|
12629
|
+
] }),
|
|
12630
|
+
/* @__PURE__ */ jsx(
|
|
12631
|
+
CustomerField,
|
|
12632
|
+
{
|
|
12633
|
+
control: form.control,
|
|
12634
|
+
currentCustomerId: order.customer_id
|
|
12635
|
+
}
|
|
12636
|
+
)
|
|
12637
|
+
] }),
|
|
12638
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
12639
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "secondary", size: "small", children: "Cancel" }) }),
|
|
12640
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12641
|
+
] }) })
|
|
12642
|
+
]
|
|
12643
|
+
}
|
|
12644
|
+
) });
|
|
12645
|
+
};
|
|
12646
|
+
const CustomerField = ({ control, currentCustomerId }) => {
|
|
12647
|
+
const customers = useComboboxData({
|
|
12648
|
+
queryFn: async (params) => {
|
|
12649
|
+
return await sdk.admin.customer.list({
|
|
12650
|
+
...params,
|
|
12651
|
+
id: currentCustomerId ? { $nin: [currentCustomerId] } : void 0
|
|
12652
|
+
});
|
|
12653
|
+
},
|
|
12654
|
+
queryKey: ["customers"],
|
|
12655
|
+
getOptions: (data) => {
|
|
12656
|
+
return data.customers.map((customer) => {
|
|
12657
|
+
const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
|
|
12658
|
+
return {
|
|
12659
|
+
label: name ? `${name} (${customer.email})` : customer.email,
|
|
12660
|
+
value: customer.id
|
|
12661
|
+
};
|
|
12332
12662
|
});
|
|
12333
12663
|
}
|
|
12334
12664
|
});
|
|
@@ -12706,351 +13036,21 @@ const Illustration = () => {
|
|
|
12706
13036
|
}
|
|
12707
13037
|
);
|
|
12708
13038
|
};
|
|
12709
|
-
const schema
|
|
13039
|
+
const schema = objectType({
|
|
12710
13040
|
customer_id: stringType().min(1)
|
|
12711
13041
|
});
|
|
12712
|
-
const
|
|
12713
|
-
|
|
12714
|
-
|
|
12715
|
-
id,
|
|
12716
|
-
{
|
|
12717
|
-
fields: "+sales_channel_id"
|
|
12718
|
-
},
|
|
12719
|
-
{
|
|
12720
|
-
enabled: !!id
|
|
12721
|
-
}
|
|
12722
|
-
);
|
|
12723
|
-
if (isError) {
|
|
12724
|
-
throw error;
|
|
12725
|
-
}
|
|
12726
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
12727
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12728
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12729
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
12730
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
12731
|
-
] }),
|
|
12732
|
-
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
12733
|
-
] });
|
|
12734
|
-
};
|
|
12735
|
-
const SalesChannelForm = ({ order }) => {
|
|
12736
|
-
const form = useForm({
|
|
12737
|
-
defaultValues: {
|
|
12738
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
12739
|
-
},
|
|
12740
|
-
resolver: zodResolver(schema$2)
|
|
12741
|
-
});
|
|
12742
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12743
|
-
const { handleSuccess } = useRouteModal();
|
|
12744
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12745
|
-
await mutateAsync(
|
|
12746
|
-
{
|
|
12747
|
-
sales_channel_id: data.sales_channel_id
|
|
12748
|
-
},
|
|
12749
|
-
{
|
|
12750
|
-
onSuccess: () => {
|
|
12751
|
-
toast.success("Sales channel updated");
|
|
12752
|
-
handleSuccess();
|
|
12753
|
-
},
|
|
12754
|
-
onError: (error) => {
|
|
12755
|
-
toast.error(error.message);
|
|
12756
|
-
}
|
|
12757
|
-
}
|
|
12758
|
-
);
|
|
12759
|
-
});
|
|
12760
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12761
|
-
KeyboundForm,
|
|
13042
|
+
const widgetModule = { widgets: [] };
|
|
13043
|
+
const routeModule = {
|
|
13044
|
+
routes: [
|
|
12762
13045
|
{
|
|
12763
|
-
|
|
12764
|
-
|
|
13046
|
+
Component: List,
|
|
13047
|
+
path: "/draft-orders",
|
|
13048
|
+
handle: handle$1,
|
|
12765
13049
|
children: [
|
|
12766
|
-
|
|
12767
|
-
|
|
12768
|
-
|
|
12769
|
-
|
|
12770
|
-
] }) })
|
|
12771
|
-
]
|
|
12772
|
-
}
|
|
12773
|
-
) });
|
|
12774
|
-
};
|
|
12775
|
-
const SalesChannelField = ({ control, order }) => {
|
|
12776
|
-
const salesChannels = useComboboxData({
|
|
12777
|
-
queryFn: async (params) => {
|
|
12778
|
-
return await sdk.admin.salesChannel.list(params);
|
|
12779
|
-
},
|
|
12780
|
-
queryKey: ["sales-channels"],
|
|
12781
|
-
getOptions: (data) => {
|
|
12782
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
12783
|
-
label: salesChannel.name,
|
|
12784
|
-
value: salesChannel.id
|
|
12785
|
-
}));
|
|
12786
|
-
},
|
|
12787
|
-
defaultValue: order.sales_channel_id || void 0
|
|
12788
|
-
});
|
|
12789
|
-
return /* @__PURE__ */ jsx(
|
|
12790
|
-
Form$2.Field,
|
|
12791
|
-
{
|
|
12792
|
-
control,
|
|
12793
|
-
name: "sales_channel_id",
|
|
12794
|
-
render: ({ field }) => {
|
|
12795
|
-
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12796
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
12797
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
12798
|
-
Combobox,
|
|
12799
|
-
{
|
|
12800
|
-
options: salesChannels.options,
|
|
12801
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
12802
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
12803
|
-
searchValue: salesChannels.searchValue,
|
|
12804
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
12805
|
-
placeholder: "Select sales channel",
|
|
12806
|
-
...field
|
|
12807
|
-
}
|
|
12808
|
-
) }),
|
|
12809
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12810
|
-
] });
|
|
12811
|
-
}
|
|
12812
|
-
}
|
|
12813
|
-
);
|
|
12814
|
-
};
|
|
12815
|
-
const schema$2 = objectType({
|
|
12816
|
-
sales_channel_id: stringType().min(1)
|
|
12817
|
-
});
|
|
12818
|
-
const ShippingAddress = () => {
|
|
12819
|
-
const { id } = useParams();
|
|
12820
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
12821
|
-
fields: "+shipping_address"
|
|
12822
|
-
});
|
|
12823
|
-
if (isError) {
|
|
12824
|
-
throw error;
|
|
12825
|
-
}
|
|
12826
|
-
const isReady = !isPending && !!order;
|
|
12827
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12828
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12829
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
|
|
12830
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
12831
|
-
] }),
|
|
12832
|
-
isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
|
|
12833
|
-
] });
|
|
12834
|
-
};
|
|
12835
|
-
const ShippingAddressForm = ({ order }) => {
|
|
12836
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12837
|
-
const form = useForm({
|
|
12838
|
-
defaultValues: {
|
|
12839
|
-
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12840
|
-
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12841
|
-
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12842
|
-
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12843
|
-
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12844
|
-
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12845
|
-
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12846
|
-
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12847
|
-
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12848
|
-
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12849
|
-
},
|
|
12850
|
-
resolver: zodResolver(schema$1)
|
|
12851
|
-
});
|
|
12852
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12853
|
-
const { handleSuccess } = useRouteModal();
|
|
12854
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12855
|
-
await mutateAsync(
|
|
12856
|
-
{
|
|
12857
|
-
shipping_address: {
|
|
12858
|
-
first_name: data.first_name,
|
|
12859
|
-
last_name: data.last_name,
|
|
12860
|
-
company: data.company,
|
|
12861
|
-
address_1: data.address_1,
|
|
12862
|
-
address_2: data.address_2,
|
|
12863
|
-
city: data.city,
|
|
12864
|
-
province: data.province,
|
|
12865
|
-
country_code: data.country_code,
|
|
12866
|
-
postal_code: data.postal_code,
|
|
12867
|
-
phone: data.phone
|
|
12868
|
-
}
|
|
12869
|
-
},
|
|
12870
|
-
{
|
|
12871
|
-
onSuccess: () => {
|
|
12872
|
-
handleSuccess();
|
|
12873
|
-
},
|
|
12874
|
-
onError: (error) => {
|
|
12875
|
-
toast.error(error.message);
|
|
12876
|
-
}
|
|
12877
|
-
}
|
|
12878
|
-
);
|
|
12879
|
-
});
|
|
12880
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12881
|
-
KeyboundForm,
|
|
12882
|
-
{
|
|
12883
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12884
|
-
onSubmit,
|
|
12885
|
-
children: [
|
|
12886
|
-
/* @__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: [
|
|
12887
|
-
/* @__PURE__ */ jsx(
|
|
12888
|
-
Form$2.Field,
|
|
12889
|
-
{
|
|
12890
|
-
control: form.control,
|
|
12891
|
-
name: "country_code",
|
|
12892
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12893
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
12894
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
12895
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12896
|
-
] })
|
|
12897
|
-
}
|
|
12898
|
-
),
|
|
12899
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12900
|
-
/* @__PURE__ */ jsx(
|
|
12901
|
-
Form$2.Field,
|
|
12902
|
-
{
|
|
12903
|
-
control: form.control,
|
|
12904
|
-
name: "first_name",
|
|
12905
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12906
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
12907
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12908
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12909
|
-
] })
|
|
12910
|
-
}
|
|
12911
|
-
),
|
|
12912
|
-
/* @__PURE__ */ jsx(
|
|
12913
|
-
Form$2.Field,
|
|
12914
|
-
{
|
|
12915
|
-
control: form.control,
|
|
12916
|
-
name: "last_name",
|
|
12917
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12918
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
12919
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12920
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12921
|
-
] })
|
|
12922
|
-
}
|
|
12923
|
-
)
|
|
12924
|
-
] }),
|
|
12925
|
-
/* @__PURE__ */ jsx(
|
|
12926
|
-
Form$2.Field,
|
|
12927
|
-
{
|
|
12928
|
-
control: form.control,
|
|
12929
|
-
name: "company",
|
|
12930
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12931
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12932
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12933
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12934
|
-
] })
|
|
12935
|
-
}
|
|
12936
|
-
),
|
|
12937
|
-
/* @__PURE__ */ jsx(
|
|
12938
|
-
Form$2.Field,
|
|
12939
|
-
{
|
|
12940
|
-
control: form.control,
|
|
12941
|
-
name: "address_1",
|
|
12942
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12943
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
12944
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12945
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12946
|
-
] })
|
|
12947
|
-
}
|
|
12948
|
-
),
|
|
12949
|
-
/* @__PURE__ */ jsx(
|
|
12950
|
-
Form$2.Field,
|
|
12951
|
-
{
|
|
12952
|
-
control: form.control,
|
|
12953
|
-
name: "address_2",
|
|
12954
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12955
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12956
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12957
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12958
|
-
] })
|
|
12959
|
-
}
|
|
12960
|
-
),
|
|
12961
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12962
|
-
/* @__PURE__ */ jsx(
|
|
12963
|
-
Form$2.Field,
|
|
12964
|
-
{
|
|
12965
|
-
control: form.control,
|
|
12966
|
-
name: "postal_code",
|
|
12967
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12968
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
12969
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12970
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12971
|
-
] })
|
|
12972
|
-
}
|
|
12973
|
-
),
|
|
12974
|
-
/* @__PURE__ */ jsx(
|
|
12975
|
-
Form$2.Field,
|
|
12976
|
-
{
|
|
12977
|
-
control: form.control,
|
|
12978
|
-
name: "city",
|
|
12979
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12980
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
12981
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12982
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12983
|
-
] })
|
|
12984
|
-
}
|
|
12985
|
-
)
|
|
12986
|
-
] }),
|
|
12987
|
-
/* @__PURE__ */ jsx(
|
|
12988
|
-
Form$2.Field,
|
|
12989
|
-
{
|
|
12990
|
-
control: form.control,
|
|
12991
|
-
name: "province",
|
|
12992
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12993
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
12994
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12995
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12996
|
-
] })
|
|
12997
|
-
}
|
|
12998
|
-
),
|
|
12999
|
-
/* @__PURE__ */ jsx(
|
|
13000
|
-
Form$2.Field,
|
|
13001
|
-
{
|
|
13002
|
-
control: form.control,
|
|
13003
|
-
name: "phone",
|
|
13004
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13005
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
13006
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13007
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13008
|
-
] })
|
|
13009
|
-
}
|
|
13010
|
-
)
|
|
13011
|
-
] }) }),
|
|
13012
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13013
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
13014
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
13015
|
-
] }) })
|
|
13016
|
-
]
|
|
13017
|
-
}
|
|
13018
|
-
) });
|
|
13019
|
-
};
|
|
13020
|
-
const schema$1 = addressSchema;
|
|
13021
|
-
const CustomItems = () => {
|
|
13022
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
13023
|
-
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
13024
|
-
/* @__PURE__ */ jsx(CustomItemsForm, {})
|
|
13025
|
-
] });
|
|
13026
|
-
};
|
|
13027
|
-
const CustomItemsForm = () => {
|
|
13028
|
-
const form = useForm({
|
|
13029
|
-
resolver: zodResolver(schema)
|
|
13030
|
-
});
|
|
13031
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
13032
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
13033
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13034
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
13035
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
|
|
13036
|
-
] }) })
|
|
13037
|
-
] }) });
|
|
13038
|
-
};
|
|
13039
|
-
const schema = objectType({
|
|
13040
|
-
email: stringType().email()
|
|
13041
|
-
});
|
|
13042
|
-
const widgetModule = { widgets: [] };
|
|
13043
|
-
const routeModule = {
|
|
13044
|
-
routes: [
|
|
13045
|
-
{
|
|
13046
|
-
Component: List,
|
|
13047
|
-
path: "/draft-orders",
|
|
13048
|
-
handle: handle$1,
|
|
13049
|
-
children: [
|
|
13050
|
-
{
|
|
13051
|
-
Component: Create,
|
|
13052
|
-
path: "/draft-orders/create"
|
|
13053
|
-
}
|
|
13050
|
+
{
|
|
13051
|
+
Component: Create,
|
|
13052
|
+
path: "/draft-orders/create"
|
|
13053
|
+
}
|
|
13054
13054
|
]
|
|
13055
13055
|
},
|
|
13056
13056
|
{
|
|
@@ -13060,8 +13060,8 @@ const routeModule = {
|
|
|
13060
13060
|
loader,
|
|
13061
13061
|
children: [
|
|
13062
13062
|
{
|
|
13063
|
-
Component:
|
|
13064
|
-
path: "/draft-orders/:id/
|
|
13063
|
+
Component: CustomItems,
|
|
13064
|
+
path: "/draft-orders/:id/custom-items"
|
|
13065
13065
|
},
|
|
13066
13066
|
{
|
|
13067
13067
|
Component: Email,
|
|
@@ -13071,6 +13071,10 @@ const routeModule = {
|
|
|
13071
13071
|
Component: Items,
|
|
13072
13072
|
path: "/draft-orders/:id/items"
|
|
13073
13073
|
},
|
|
13074
|
+
{
|
|
13075
|
+
Component: BillingAddress,
|
|
13076
|
+
path: "/draft-orders/:id/billing-address"
|
|
13077
|
+
},
|
|
13074
13078
|
{
|
|
13075
13079
|
Component: Metadata,
|
|
13076
13080
|
path: "/draft-orders/:id/metadata"
|
|
@@ -13079,25 +13083,21 @@ const routeModule = {
|
|
|
13079
13083
|
Component: Promotions,
|
|
13080
13084
|
path: "/draft-orders/:id/promotions"
|
|
13081
13085
|
},
|
|
13082
|
-
{
|
|
13083
|
-
Component: Shipping,
|
|
13084
|
-
path: "/draft-orders/:id/shipping"
|
|
13085
|
-
},
|
|
13086
|
-
{
|
|
13087
|
-
Component: TransferOwnership,
|
|
13088
|
-
path: "/draft-orders/:id/transfer-ownership"
|
|
13089
|
-
},
|
|
13090
13086
|
{
|
|
13091
13087
|
Component: SalesChannel,
|
|
13092
13088
|
path: "/draft-orders/:id/sales-channel"
|
|
13093
13089
|
},
|
|
13090
|
+
{
|
|
13091
|
+
Component: Shipping,
|
|
13092
|
+
path: "/draft-orders/:id/shipping"
|
|
13093
|
+
},
|
|
13094
13094
|
{
|
|
13095
13095
|
Component: ShippingAddress,
|
|
13096
13096
|
path: "/draft-orders/:id/shipping-address"
|
|
13097
13097
|
},
|
|
13098
13098
|
{
|
|
13099
|
-
Component:
|
|
13100
|
-
path: "/draft-orders/:id/
|
|
13099
|
+
Component: TransferOwnership,
|
|
13100
|
+
path: "/draft-orders/:id/transfer-ownership"
|
|
13101
13101
|
}
|
|
13102
13102
|
]
|
|
13103
13103
|
}
|