@medusajs/draft-order 2.11.0 → 2.11.1-snapshot-20251021080449
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 +609 -609
- package/.medusa/server/src/admin/index.mjs +609 -609
- package/package.json +24 -22
|
@@ -9586,10 +9586,10 @@ const CustomItemsForm = () => {
|
|
|
9586
9586
|
const schema$5 = objectType({
|
|
9587
9587
|
email: stringType().email()
|
|
9588
9588
|
});
|
|
9589
|
-
const
|
|
9589
|
+
const Email = () => {
|
|
9590
9590
|
const { id } = useParams();
|
|
9591
9591
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
9592
|
-
fields: "+
|
|
9592
|
+
fields: "+email"
|
|
9593
9593
|
});
|
|
9594
9594
|
if (isError) {
|
|
9595
9595
|
throw error;
|
|
@@ -9597,26 +9597,16 @@ const BillingAddress = () => {
|
|
|
9597
9597
|
const isReady = !isPending && !!order;
|
|
9598
9598
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9599
9599
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
9600
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit
|
|
9601
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the
|
|
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
9602
|
] }),
|
|
9603
|
-
isReady && /* @__PURE__ */ jsx(
|
|
9603
|
+
isReady && /* @__PURE__ */ jsx(EmailForm, { order })
|
|
9604
9604
|
] });
|
|
9605
9605
|
};
|
|
9606
|
-
const
|
|
9607
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
9606
|
+
const EmailForm = ({ order }) => {
|
|
9608
9607
|
const form = useForm({
|
|
9609
9608
|
defaultValues: {
|
|
9610
|
-
|
|
9611
|
-
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
9612
|
-
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
9613
|
-
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
9614
|
-
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
9615
|
-
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
9616
|
-
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
9617
|
-
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
9618
|
-
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9619
|
-
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9609
|
+
email: order.email ?? ""
|
|
9620
9610
|
},
|
|
9621
9611
|
resolver: zodResolver(schema$4)
|
|
9622
9612
|
});
|
|
@@ -9624,7 +9614,7 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9624
9614
|
const { handleSuccess } = useRouteModal();
|
|
9625
9615
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
9626
9616
|
await mutateAsync(
|
|
9627
|
-
{
|
|
9617
|
+
{ email: data.email },
|
|
9628
9618
|
{
|
|
9629
9619
|
onSuccess: () => {
|
|
9630
9620
|
handleSuccess();
|
|
@@ -9641,132 +9631,18 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9641
9631
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
9642
9632
|
onSubmit,
|
|
9643
9633
|
children: [
|
|
9644
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */
|
|
9645
|
-
|
|
9646
|
-
|
|
9647
|
-
|
|
9648
|
-
|
|
9649
|
-
|
|
9650
|
-
|
|
9651
|
-
|
|
9652
|
-
|
|
9653
|
-
|
|
9654
|
-
|
|
9655
|
-
|
|
9656
|
-
),
|
|
9657
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9658
|
-
/* @__PURE__ */ jsx(
|
|
9659
|
-
Form$2.Field,
|
|
9660
|
-
{
|
|
9661
|
-
control: form.control,
|
|
9662
|
-
name: "first_name",
|
|
9663
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9664
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
9665
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9666
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9667
|
-
] })
|
|
9668
|
-
}
|
|
9669
|
-
),
|
|
9670
|
-
/* @__PURE__ */ jsx(
|
|
9671
|
-
Form$2.Field,
|
|
9672
|
-
{
|
|
9673
|
-
control: form.control,
|
|
9674
|
-
name: "last_name",
|
|
9675
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9676
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
9677
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9678
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9679
|
-
] })
|
|
9680
|
-
}
|
|
9681
|
-
)
|
|
9682
|
-
] }),
|
|
9683
|
-
/* @__PURE__ */ jsx(
|
|
9684
|
-
Form$2.Field,
|
|
9685
|
-
{
|
|
9686
|
-
control: form.control,
|
|
9687
|
-
name: "company",
|
|
9688
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9689
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
9690
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9691
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9692
|
-
] })
|
|
9693
|
-
}
|
|
9694
|
-
),
|
|
9695
|
-
/* @__PURE__ */ jsx(
|
|
9696
|
-
Form$2.Field,
|
|
9697
|
-
{
|
|
9698
|
-
control: form.control,
|
|
9699
|
-
name: "address_1",
|
|
9700
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9701
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
9702
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9703
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9704
|
-
] })
|
|
9705
|
-
}
|
|
9706
|
-
),
|
|
9707
|
-
/* @__PURE__ */ jsx(
|
|
9708
|
-
Form$2.Field,
|
|
9709
|
-
{
|
|
9710
|
-
control: form.control,
|
|
9711
|
-
name: "address_2",
|
|
9712
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9713
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
9714
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9715
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9716
|
-
] })
|
|
9717
|
-
}
|
|
9718
|
-
),
|
|
9719
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9720
|
-
/* @__PURE__ */ jsx(
|
|
9721
|
-
Form$2.Field,
|
|
9722
|
-
{
|
|
9723
|
-
control: form.control,
|
|
9724
|
-
name: "postal_code",
|
|
9725
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9726
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
9727
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9728
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9729
|
-
] })
|
|
9730
|
-
}
|
|
9731
|
-
),
|
|
9732
|
-
/* @__PURE__ */ jsx(
|
|
9733
|
-
Form$2.Field,
|
|
9734
|
-
{
|
|
9735
|
-
control: form.control,
|
|
9736
|
-
name: "city",
|
|
9737
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9738
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
9739
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9740
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9741
|
-
] })
|
|
9742
|
-
}
|
|
9743
|
-
)
|
|
9744
|
-
] }),
|
|
9745
|
-
/* @__PURE__ */ jsx(
|
|
9746
|
-
Form$2.Field,
|
|
9747
|
-
{
|
|
9748
|
-
control: form.control,
|
|
9749
|
-
name: "province",
|
|
9750
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9751
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
9752
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9753
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9754
|
-
] })
|
|
9755
|
-
}
|
|
9756
|
-
),
|
|
9757
|
-
/* @__PURE__ */ jsx(
|
|
9758
|
-
Form$2.Field,
|
|
9759
|
-
{
|
|
9760
|
-
control: form.control,
|
|
9761
|
-
name: "phone",
|
|
9762
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9763
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
9764
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9765
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9766
|
-
] })
|
|
9767
|
-
}
|
|
9768
|
-
)
|
|
9769
|
-
] }) }),
|
|
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
|
+
) }),
|
|
9770
9646
|
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9771
9647
|
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9772
9648
|
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
@@ -9775,7 +9651,9 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9775
9651
|
}
|
|
9776
9652
|
) });
|
|
9777
9653
|
};
|
|
9778
|
-
const schema$4 =
|
|
9654
|
+
const schema$4 = objectType({
|
|
9655
|
+
email: stringType().email()
|
|
9656
|
+
});
|
|
9779
9657
|
const NumberInput = forwardRef(
|
|
9780
9658
|
({
|
|
9781
9659
|
value,
|
|
@@ -10750,10 +10628,54 @@ const customItemSchema = objectType({
|
|
|
10750
10628
|
quantity: numberType(),
|
|
10751
10629
|
unit_price: unionType([numberType(), stringType()])
|
|
10752
10630
|
});
|
|
10753
|
-
const
|
|
10631
|
+
const InlineTip = forwardRef(
|
|
10632
|
+
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
10633
|
+
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
10634
|
+
return /* @__PURE__ */ jsxs(
|
|
10635
|
+
"div",
|
|
10636
|
+
{
|
|
10637
|
+
ref,
|
|
10638
|
+
className: clx(
|
|
10639
|
+
"bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
|
|
10640
|
+
className
|
|
10641
|
+
),
|
|
10642
|
+
...props,
|
|
10643
|
+
children: [
|
|
10644
|
+
/* @__PURE__ */ jsx(
|
|
10645
|
+
"div",
|
|
10646
|
+
{
|
|
10647
|
+
role: "presentation",
|
|
10648
|
+
className: clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
|
|
10649
|
+
"bg-ui-tag-orange-icon": variant === "warning"
|
|
10650
|
+
})
|
|
10651
|
+
}
|
|
10652
|
+
),
|
|
10653
|
+
/* @__PURE__ */ jsxs("div", { className: "text-pretty", children: [
|
|
10654
|
+
/* @__PURE__ */ jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
|
|
10655
|
+
labelValue,
|
|
10656
|
+
":"
|
|
10657
|
+
] }),
|
|
10658
|
+
" ",
|
|
10659
|
+
children
|
|
10660
|
+
] })
|
|
10661
|
+
]
|
|
10662
|
+
}
|
|
10663
|
+
);
|
|
10664
|
+
}
|
|
10665
|
+
);
|
|
10666
|
+
InlineTip.displayName = "InlineTip";
|
|
10667
|
+
const MetadataFieldSchema = objectType({
|
|
10668
|
+
key: stringType(),
|
|
10669
|
+
disabled: booleanType().optional(),
|
|
10670
|
+
value: anyType()
|
|
10671
|
+
});
|
|
10672
|
+
const MetadataSchema = objectType({
|
|
10673
|
+
metadata: arrayType(MetadataFieldSchema)
|
|
10674
|
+
});
|
|
10675
|
+
const Metadata = () => {
|
|
10754
10676
|
const { id } = useParams();
|
|
10755
10677
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
10756
|
-
fields: "
|
|
10678
|
+
fields: "metadata"
|
|
10757
10679
|
});
|
|
10758
10680
|
if (isError) {
|
|
10759
10681
|
throw error;
|
|
@@ -10761,26 +10683,33 @@ const Email = () => {
|
|
|
10761
10683
|
const isReady = !isPending && !!order;
|
|
10762
10684
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
10763
10685
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
10764
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "
|
|
10765
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "
|
|
10686
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Metadata" }) }),
|
|
10687
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
|
|
10766
10688
|
] }),
|
|
10767
|
-
isReady
|
|
10689
|
+
!isReady ? /* @__PURE__ */ jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
|
|
10768
10690
|
] });
|
|
10769
10691
|
};
|
|
10770
|
-
const
|
|
10692
|
+
const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
|
|
10693
|
+
const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
|
|
10694
|
+
const MetadataForm = ({ orderId, metadata }) => {
|
|
10695
|
+
const { handleSuccess } = useRouteModal();
|
|
10696
|
+
const hasUneditableRows = getHasUneditableRows(metadata);
|
|
10697
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
|
|
10771
10698
|
const form = useForm({
|
|
10772
10699
|
defaultValues: {
|
|
10773
|
-
|
|
10700
|
+
metadata: getDefaultValues(metadata)
|
|
10774
10701
|
},
|
|
10775
|
-
resolver: zodResolver(
|
|
10702
|
+
resolver: zodResolver(MetadataSchema)
|
|
10776
10703
|
});
|
|
10777
|
-
const
|
|
10778
|
-
|
|
10779
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
10704
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
10705
|
+
const parsedData = parseValues(data);
|
|
10780
10706
|
await mutateAsync(
|
|
10781
|
-
{
|
|
10707
|
+
{
|
|
10708
|
+
metadata: parsedData
|
|
10709
|
+
},
|
|
10782
10710
|
{
|
|
10783
10711
|
onSuccess: () => {
|
|
10712
|
+
toast.success("Metadata updated");
|
|
10784
10713
|
handleSuccess();
|
|
10785
10714
|
},
|
|
10786
10715
|
onError: (error) => {
|
|
@@ -10789,141 +10718,266 @@ const EmailForm = ({ order }) => {
|
|
|
10789
10718
|
}
|
|
10790
10719
|
);
|
|
10791
10720
|
});
|
|
10792
|
-
|
|
10793
|
-
|
|
10794
|
-
|
|
10795
|
-
|
|
10796
|
-
|
|
10797
|
-
|
|
10798
|
-
|
|
10799
|
-
|
|
10800
|
-
|
|
10801
|
-
|
|
10802
|
-
|
|
10803
|
-
|
|
10804
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Email" }),
|
|
10805
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
10806
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10807
|
-
] })
|
|
10808
|
-
}
|
|
10809
|
-
) }),
|
|
10810
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
10811
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
10812
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
10813
|
-
] }) })
|
|
10814
|
-
]
|
|
10815
|
-
}
|
|
10816
|
-
) });
|
|
10817
|
-
};
|
|
10818
|
-
const schema$3 = objectType({
|
|
10819
|
-
email: stringType().email()
|
|
10820
|
-
});
|
|
10821
|
-
const SalesChannel = () => {
|
|
10822
|
-
const { id } = useParams();
|
|
10823
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
10824
|
-
id,
|
|
10825
|
-
{
|
|
10826
|
-
fields: "+sales_channel_id"
|
|
10827
|
-
},
|
|
10828
|
-
{
|
|
10829
|
-
enabled: !!id
|
|
10721
|
+
const { fields, insert, remove } = useFieldArray({
|
|
10722
|
+
control: form.control,
|
|
10723
|
+
name: "metadata"
|
|
10724
|
+
});
|
|
10725
|
+
function deleteRow(index) {
|
|
10726
|
+
remove(index);
|
|
10727
|
+
if (fields.length === 1) {
|
|
10728
|
+
insert(0, {
|
|
10729
|
+
key: "",
|
|
10730
|
+
value: "",
|
|
10731
|
+
disabled: false
|
|
10732
|
+
});
|
|
10830
10733
|
}
|
|
10831
|
-
);
|
|
10832
|
-
if (isError) {
|
|
10833
|
-
throw error;
|
|
10834
10734
|
}
|
|
10835
|
-
|
|
10836
|
-
|
|
10837
|
-
|
|
10838
|
-
|
|
10839
|
-
|
|
10840
|
-
|
|
10841
|
-
|
|
10842
|
-
] });
|
|
10843
|
-
};
|
|
10844
|
-
const SalesChannelForm = ({ order }) => {
|
|
10845
|
-
const form = useForm({
|
|
10846
|
-
defaultValues: {
|
|
10847
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
10848
|
-
},
|
|
10849
|
-
resolver: zodResolver(schema$2)
|
|
10850
|
-
});
|
|
10851
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
10852
|
-
const { handleSuccess } = useRouteModal();
|
|
10853
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
10854
|
-
await mutateAsync(
|
|
10855
|
-
{
|
|
10856
|
-
sales_channel_id: data.sales_channel_id
|
|
10857
|
-
},
|
|
10858
|
-
{
|
|
10859
|
-
onSuccess: () => {
|
|
10860
|
-
toast.success("Sales channel updated");
|
|
10861
|
-
handleSuccess();
|
|
10862
|
-
},
|
|
10863
|
-
onError: (error) => {
|
|
10864
|
-
toast.error(error.message);
|
|
10865
|
-
}
|
|
10866
|
-
}
|
|
10867
|
-
);
|
|
10868
|
-
});
|
|
10735
|
+
function insertRow(index, position) {
|
|
10736
|
+
insert(index + (position === "above" ? 0 : 1), {
|
|
10737
|
+
key: "",
|
|
10738
|
+
value: "",
|
|
10739
|
+
disabled: false
|
|
10740
|
+
});
|
|
10741
|
+
}
|
|
10869
10742
|
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
10870
10743
|
KeyboundForm,
|
|
10871
10744
|
{
|
|
10745
|
+
onSubmit: handleSubmit,
|
|
10872
10746
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
10873
|
-
onSubmit,
|
|
10874
10747
|
children: [
|
|
10875
|
-
/* @__PURE__ */
|
|
10876
|
-
|
|
10877
|
-
|
|
10748
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: [
|
|
10749
|
+
/* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-1 divide-y rounded-lg", children: [
|
|
10750
|
+
/* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle grid grid-cols-2 divide-x rounded-t-lg", children: [
|
|
10751
|
+
/* @__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" }) }),
|
|
10752
|
+
/* @__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" }) })
|
|
10753
|
+
] }),
|
|
10754
|
+
fields.map((field, index) => {
|
|
10755
|
+
const isDisabled = field.disabled || false;
|
|
10756
|
+
let placeholder = "-";
|
|
10757
|
+
if (typeof field.value === "object") {
|
|
10758
|
+
placeholder = "{ ... }";
|
|
10759
|
+
}
|
|
10760
|
+
if (Array.isArray(field.value)) {
|
|
10761
|
+
placeholder = "[ ... ]";
|
|
10762
|
+
}
|
|
10763
|
+
return /* @__PURE__ */ jsx(
|
|
10764
|
+
ConditionalTooltip,
|
|
10765
|
+
{
|
|
10766
|
+
showTooltip: isDisabled,
|
|
10767
|
+
content: "This row is disabled because it contains non-primitive data.",
|
|
10768
|
+
children: /* @__PURE__ */ jsxs("div", { className: "group/table relative", children: [
|
|
10769
|
+
/* @__PURE__ */ jsxs(
|
|
10770
|
+
"div",
|
|
10771
|
+
{
|
|
10772
|
+
className: clx("grid grid-cols-2 divide-x", {
|
|
10773
|
+
"overflow-hidden rounded-b-lg": index === fields.length - 1
|
|
10774
|
+
}),
|
|
10775
|
+
children: [
|
|
10776
|
+
/* @__PURE__ */ jsx(
|
|
10777
|
+
Form$2.Field,
|
|
10778
|
+
{
|
|
10779
|
+
control: form.control,
|
|
10780
|
+
name: `metadata.${index}.key`,
|
|
10781
|
+
render: ({ field: field2 }) => {
|
|
10782
|
+
return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
10783
|
+
GridInput,
|
|
10784
|
+
{
|
|
10785
|
+
"aria-labelledby": METADATA_KEY_LABEL_ID,
|
|
10786
|
+
...field2,
|
|
10787
|
+
disabled: isDisabled,
|
|
10788
|
+
placeholder: "Key"
|
|
10789
|
+
}
|
|
10790
|
+
) }) });
|
|
10791
|
+
}
|
|
10792
|
+
}
|
|
10793
|
+
),
|
|
10794
|
+
/* @__PURE__ */ jsx(
|
|
10795
|
+
Form$2.Field,
|
|
10796
|
+
{
|
|
10797
|
+
control: form.control,
|
|
10798
|
+
name: `metadata.${index}.value`,
|
|
10799
|
+
render: ({ field: { value, ...field2 } }) => {
|
|
10800
|
+
return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
10801
|
+
GridInput,
|
|
10802
|
+
{
|
|
10803
|
+
"aria-labelledby": METADATA_VALUE_LABEL_ID,
|
|
10804
|
+
...field2,
|
|
10805
|
+
value: isDisabled ? placeholder : value,
|
|
10806
|
+
disabled: isDisabled,
|
|
10807
|
+
placeholder: "Value"
|
|
10808
|
+
}
|
|
10809
|
+
) }) });
|
|
10810
|
+
}
|
|
10811
|
+
}
|
|
10812
|
+
)
|
|
10813
|
+
]
|
|
10814
|
+
}
|
|
10815
|
+
),
|
|
10816
|
+
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
10817
|
+
/* @__PURE__ */ jsx(
|
|
10818
|
+
DropdownMenu.Trigger,
|
|
10819
|
+
{
|
|
10820
|
+
className: clx(
|
|
10821
|
+
"invisible absolute inset-y-0 -right-2.5 my-auto group-hover/table:visible data-[state='open']:visible",
|
|
10822
|
+
{
|
|
10823
|
+
hidden: isDisabled
|
|
10824
|
+
}
|
|
10825
|
+
),
|
|
10826
|
+
disabled: isDisabled,
|
|
10827
|
+
asChild: true,
|
|
10828
|
+
children: /* @__PURE__ */ jsx(IconButton, { size: "2xsmall", children: /* @__PURE__ */ jsx(EllipsisVertical, {}) })
|
|
10829
|
+
}
|
|
10830
|
+
),
|
|
10831
|
+
/* @__PURE__ */ jsxs(DropdownMenu.Content, { children: [
|
|
10832
|
+
/* @__PURE__ */ jsxs(
|
|
10833
|
+
DropdownMenu.Item,
|
|
10834
|
+
{
|
|
10835
|
+
className: "gap-x-2",
|
|
10836
|
+
onClick: () => insertRow(index, "above"),
|
|
10837
|
+
children: [
|
|
10838
|
+
/* @__PURE__ */ jsx(ArrowUpMini, { className: "text-ui-fg-subtle" }),
|
|
10839
|
+
"Insert row above"
|
|
10840
|
+
]
|
|
10841
|
+
}
|
|
10842
|
+
),
|
|
10843
|
+
/* @__PURE__ */ jsxs(
|
|
10844
|
+
DropdownMenu.Item,
|
|
10845
|
+
{
|
|
10846
|
+
className: "gap-x-2",
|
|
10847
|
+
onClick: () => insertRow(index, "below"),
|
|
10848
|
+
children: [
|
|
10849
|
+
/* @__PURE__ */ jsx(ArrowDownMini, { className: "text-ui-fg-subtle" }),
|
|
10850
|
+
"Insert row below"
|
|
10851
|
+
]
|
|
10852
|
+
}
|
|
10853
|
+
),
|
|
10854
|
+
/* @__PURE__ */ jsx(DropdownMenu.Separator, {}),
|
|
10855
|
+
/* @__PURE__ */ jsxs(
|
|
10856
|
+
DropdownMenu.Item,
|
|
10857
|
+
{
|
|
10858
|
+
className: "gap-x-2",
|
|
10859
|
+
onClick: () => deleteRow(index),
|
|
10860
|
+
children: [
|
|
10861
|
+
/* @__PURE__ */ jsx(Trash, { className: "text-ui-fg-subtle" }),
|
|
10862
|
+
"Delete row"
|
|
10863
|
+
]
|
|
10864
|
+
}
|
|
10865
|
+
)
|
|
10866
|
+
] })
|
|
10867
|
+
] })
|
|
10868
|
+
] })
|
|
10869
|
+
},
|
|
10870
|
+
field.id
|
|
10871
|
+
);
|
|
10872
|
+
})
|
|
10873
|
+
] }),
|
|
10874
|
+
hasUneditableRows && /* @__PURE__ */ jsx(InlineTip, { variant: "warning", label: "Some rows are disabled", children: "This object contains non-primitive metadata, such as arrays or objects, that can't be edited here. To edit the disabled rows, use the API directly." })
|
|
10875
|
+
] }),
|
|
10876
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
10877
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
10878
10878
|
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
10879
10879
|
] }) })
|
|
10880
10880
|
]
|
|
10881
10881
|
}
|
|
10882
10882
|
) });
|
|
10883
10883
|
};
|
|
10884
|
-
const
|
|
10885
|
-
const salesChannels = useComboboxData({
|
|
10886
|
-
queryFn: async (params) => {
|
|
10887
|
-
return await sdk.admin.salesChannel.list(params);
|
|
10888
|
-
},
|
|
10889
|
-
queryKey: ["sales-channels"],
|
|
10890
|
-
getOptions: (data) => {
|
|
10891
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
10892
|
-
label: salesChannel.name,
|
|
10893
|
-
value: salesChannel.id
|
|
10894
|
-
}));
|
|
10895
|
-
},
|
|
10896
|
-
defaultValue: order.sales_channel_id || void 0
|
|
10897
|
-
});
|
|
10884
|
+
const GridInput = forwardRef(({ className, ...props }, ref) => {
|
|
10898
10885
|
return /* @__PURE__ */ jsx(
|
|
10899
|
-
|
|
10886
|
+
"input",
|
|
10900
10887
|
{
|
|
10901
|
-
|
|
10902
|
-
|
|
10903
|
-
|
|
10904
|
-
|
|
10905
|
-
|
|
10906
|
-
|
|
10907
|
-
|
|
10908
|
-
{
|
|
10909
|
-
options: salesChannels.options,
|
|
10910
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
10911
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
10912
|
-
searchValue: salesChannels.searchValue,
|
|
10913
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
10914
|
-
placeholder: "Select sales channel",
|
|
10915
|
-
...field
|
|
10916
|
-
}
|
|
10917
|
-
) }),
|
|
10918
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
10919
|
-
] });
|
|
10920
|
-
}
|
|
10888
|
+
ref,
|
|
10889
|
+
...props,
|
|
10890
|
+
autoComplete: "off",
|
|
10891
|
+
className: clx(
|
|
10892
|
+
"txt-compact-small text-ui-fg-base placeholder:text-ui-fg-muted disabled:text-ui-fg-disabled disabled:bg-ui-bg-base bg-transparent px-2 py-1.5 outline-none",
|
|
10893
|
+
className
|
|
10894
|
+
)
|
|
10921
10895
|
}
|
|
10922
10896
|
);
|
|
10923
|
-
};
|
|
10924
|
-
const schema$2 = objectType({
|
|
10925
|
-
sales_channel_id: stringType().min(1)
|
|
10926
10897
|
});
|
|
10898
|
+
GridInput.displayName = "MetadataForm.GridInput";
|
|
10899
|
+
const PlaceholderInner = () => {
|
|
10900
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
10901
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-[148ox] w-full rounded-lg" }) }),
|
|
10902
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
10903
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-12 rounded-md" }),
|
|
10904
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-12 rounded-md" })
|
|
10905
|
+
] }) })
|
|
10906
|
+
] });
|
|
10907
|
+
};
|
|
10908
|
+
const EDITABLE_TYPES = ["string", "number", "boolean"];
|
|
10909
|
+
function getDefaultValues(metadata) {
|
|
10910
|
+
if (!metadata || !Object.keys(metadata).length) {
|
|
10911
|
+
return [
|
|
10912
|
+
{
|
|
10913
|
+
key: "",
|
|
10914
|
+
value: "",
|
|
10915
|
+
disabled: false
|
|
10916
|
+
}
|
|
10917
|
+
];
|
|
10918
|
+
}
|
|
10919
|
+
return Object.entries(metadata).map(([key, value]) => {
|
|
10920
|
+
if (!EDITABLE_TYPES.includes(typeof value)) {
|
|
10921
|
+
return {
|
|
10922
|
+
key,
|
|
10923
|
+
value,
|
|
10924
|
+
disabled: true
|
|
10925
|
+
};
|
|
10926
|
+
}
|
|
10927
|
+
let stringValue = value;
|
|
10928
|
+
if (typeof value !== "string") {
|
|
10929
|
+
stringValue = JSON.stringify(value);
|
|
10930
|
+
}
|
|
10931
|
+
return {
|
|
10932
|
+
key,
|
|
10933
|
+
value: stringValue,
|
|
10934
|
+
original_key: key
|
|
10935
|
+
};
|
|
10936
|
+
});
|
|
10937
|
+
}
|
|
10938
|
+
function parseValues(values) {
|
|
10939
|
+
const metadata = values.metadata;
|
|
10940
|
+
const isEmpty = !metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value;
|
|
10941
|
+
if (isEmpty) {
|
|
10942
|
+
return null;
|
|
10943
|
+
}
|
|
10944
|
+
const update = {};
|
|
10945
|
+
metadata.forEach((field) => {
|
|
10946
|
+
let key = field.key;
|
|
10947
|
+
let value = field.value;
|
|
10948
|
+
const disabled = field.disabled;
|
|
10949
|
+
if (!key || !value) {
|
|
10950
|
+
return;
|
|
10951
|
+
}
|
|
10952
|
+
if (disabled) {
|
|
10953
|
+
update[key] = value;
|
|
10954
|
+
return;
|
|
10955
|
+
}
|
|
10956
|
+
key = key.trim();
|
|
10957
|
+
value = value.trim();
|
|
10958
|
+
if (value === "true") {
|
|
10959
|
+
update[key] = true;
|
|
10960
|
+
} else if (value === "false") {
|
|
10961
|
+
update[key] = false;
|
|
10962
|
+
} else {
|
|
10963
|
+
const parsedNumber = parseFloat(value);
|
|
10964
|
+
if (!isNaN(parsedNumber)) {
|
|
10965
|
+
update[key] = parsedNumber;
|
|
10966
|
+
} else {
|
|
10967
|
+
update[key] = value;
|
|
10968
|
+
}
|
|
10969
|
+
}
|
|
10970
|
+
});
|
|
10971
|
+
return update;
|
|
10972
|
+
}
|
|
10973
|
+
function getHasUneditableRows(metadata) {
|
|
10974
|
+
if (!metadata) {
|
|
10975
|
+
return false;
|
|
10976
|
+
}
|
|
10977
|
+
return Object.values(metadata).some(
|
|
10978
|
+
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
10979
|
+
);
|
|
10980
|
+
}
|
|
10927
10981
|
const PROMOTION_QUERY_KEY = "promotions";
|
|
10928
10982
|
const promotionsQueryKeys = {
|
|
10929
10983
|
list: (query2) => [
|
|
@@ -11198,9 +11252,115 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11198
11252
|
}
|
|
11199
11253
|
}
|
|
11200
11254
|
}
|
|
11201
|
-
}
|
|
11202
|
-
return Array.from(promotionIds);
|
|
11203
|
-
}
|
|
11255
|
+
}
|
|
11256
|
+
return Array.from(promotionIds);
|
|
11257
|
+
}
|
|
11258
|
+
const SalesChannel = () => {
|
|
11259
|
+
const { id } = useParams();
|
|
11260
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11261
|
+
id,
|
|
11262
|
+
{
|
|
11263
|
+
fields: "+sales_channel_id"
|
|
11264
|
+
},
|
|
11265
|
+
{
|
|
11266
|
+
enabled: !!id
|
|
11267
|
+
}
|
|
11268
|
+
);
|
|
11269
|
+
if (isError) {
|
|
11270
|
+
throw error;
|
|
11271
|
+
}
|
|
11272
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
11273
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11274
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11275
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
11276
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
11277
|
+
] }),
|
|
11278
|
+
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
11279
|
+
] });
|
|
11280
|
+
};
|
|
11281
|
+
const SalesChannelForm = ({ order }) => {
|
|
11282
|
+
const form = useForm({
|
|
11283
|
+
defaultValues: {
|
|
11284
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
11285
|
+
},
|
|
11286
|
+
resolver: zodResolver(schema$3)
|
|
11287
|
+
});
|
|
11288
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11289
|
+
const { handleSuccess } = useRouteModal();
|
|
11290
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11291
|
+
await mutateAsync(
|
|
11292
|
+
{
|
|
11293
|
+
sales_channel_id: data.sales_channel_id
|
|
11294
|
+
},
|
|
11295
|
+
{
|
|
11296
|
+
onSuccess: () => {
|
|
11297
|
+
toast.success("Sales channel updated");
|
|
11298
|
+
handleSuccess();
|
|
11299
|
+
},
|
|
11300
|
+
onError: (error) => {
|
|
11301
|
+
toast.error(error.message);
|
|
11302
|
+
}
|
|
11303
|
+
}
|
|
11304
|
+
);
|
|
11305
|
+
});
|
|
11306
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11307
|
+
KeyboundForm,
|
|
11308
|
+
{
|
|
11309
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11310
|
+
onSubmit,
|
|
11311
|
+
children: [
|
|
11312
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11313
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11314
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11315
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11316
|
+
] }) })
|
|
11317
|
+
]
|
|
11318
|
+
}
|
|
11319
|
+
) });
|
|
11320
|
+
};
|
|
11321
|
+
const SalesChannelField = ({ control, order }) => {
|
|
11322
|
+
const salesChannels = useComboboxData({
|
|
11323
|
+
queryFn: async (params) => {
|
|
11324
|
+
return await sdk.admin.salesChannel.list(params);
|
|
11325
|
+
},
|
|
11326
|
+
queryKey: ["sales-channels"],
|
|
11327
|
+
getOptions: (data) => {
|
|
11328
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
11329
|
+
label: salesChannel.name,
|
|
11330
|
+
value: salesChannel.id
|
|
11331
|
+
}));
|
|
11332
|
+
},
|
|
11333
|
+
defaultValue: order.sales_channel_id || void 0
|
|
11334
|
+
});
|
|
11335
|
+
return /* @__PURE__ */ jsx(
|
|
11336
|
+
Form$2.Field,
|
|
11337
|
+
{
|
|
11338
|
+
control,
|
|
11339
|
+
name: "sales_channel_id",
|
|
11340
|
+
render: ({ field }) => {
|
|
11341
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11342
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11343
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
11344
|
+
Combobox,
|
|
11345
|
+
{
|
|
11346
|
+
options: salesChannels.options,
|
|
11347
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
11348
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11349
|
+
searchValue: salesChannels.searchValue,
|
|
11350
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11351
|
+
placeholder: "Select sales channel",
|
|
11352
|
+
...field
|
|
11353
|
+
}
|
|
11354
|
+
) }),
|
|
11355
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11356
|
+
] });
|
|
11357
|
+
}
|
|
11358
|
+
}
|
|
11359
|
+
);
|
|
11360
|
+
};
|
|
11361
|
+
const schema$3 = objectType({
|
|
11362
|
+
sales_channel_id: stringType().min(1)
|
|
11363
|
+
});
|
|
11204
11364
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11205
11365
|
const Shipping = () => {
|
|
11206
11366
|
var _a;
|
|
@@ -12040,7 +12200,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12040
12200
|
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12041
12201
|
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12042
12202
|
},
|
|
12043
|
-
resolver: zodResolver(schema$
|
|
12203
|
+
resolver: zodResolver(schema$2)
|
|
12044
12204
|
});
|
|
12045
12205
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12046
12206
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12210,7 +12370,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12210
12370
|
}
|
|
12211
12371
|
) });
|
|
12212
12372
|
};
|
|
12213
|
-
const schema$
|
|
12373
|
+
const schema$2 = addressSchema;
|
|
12214
12374
|
const TransferOwnership = () => {
|
|
12215
12375
|
const { id } = useParams();
|
|
12216
12376
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -12234,7 +12394,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12234
12394
|
defaultValues: {
|
|
12235
12395
|
customer_id: order.customer_id || ""
|
|
12236
12396
|
},
|
|
12237
|
-
resolver: zodResolver(schema)
|
|
12397
|
+
resolver: zodResolver(schema$1)
|
|
12238
12398
|
});
|
|
12239
12399
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12240
12400
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12684,57 +12844,13 @@ const Illustration = () => {
|
|
|
12684
12844
|
}
|
|
12685
12845
|
);
|
|
12686
12846
|
};
|
|
12687
|
-
const schema = objectType({
|
|
12847
|
+
const schema$1 = objectType({
|
|
12688
12848
|
customer_id: stringType().min(1)
|
|
12689
12849
|
});
|
|
12690
|
-
const
|
|
12691
|
-
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
12692
|
-
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
12693
|
-
return /* @__PURE__ */ jsxs(
|
|
12694
|
-
"div",
|
|
12695
|
-
{
|
|
12696
|
-
ref,
|
|
12697
|
-
className: clx(
|
|
12698
|
-
"bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
|
|
12699
|
-
className
|
|
12700
|
-
),
|
|
12701
|
-
...props,
|
|
12702
|
-
children: [
|
|
12703
|
-
/* @__PURE__ */ jsx(
|
|
12704
|
-
"div",
|
|
12705
|
-
{
|
|
12706
|
-
role: "presentation",
|
|
12707
|
-
className: clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
|
|
12708
|
-
"bg-ui-tag-orange-icon": variant === "warning"
|
|
12709
|
-
})
|
|
12710
|
-
}
|
|
12711
|
-
),
|
|
12712
|
-
/* @__PURE__ */ jsxs("div", { className: "text-pretty", children: [
|
|
12713
|
-
/* @__PURE__ */ jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
|
|
12714
|
-
labelValue,
|
|
12715
|
-
":"
|
|
12716
|
-
] }),
|
|
12717
|
-
" ",
|
|
12718
|
-
children
|
|
12719
|
-
] })
|
|
12720
|
-
]
|
|
12721
|
-
}
|
|
12722
|
-
);
|
|
12723
|
-
}
|
|
12724
|
-
);
|
|
12725
|
-
InlineTip.displayName = "InlineTip";
|
|
12726
|
-
const MetadataFieldSchema = objectType({
|
|
12727
|
-
key: stringType(),
|
|
12728
|
-
disabled: booleanType().optional(),
|
|
12729
|
-
value: anyType()
|
|
12730
|
-
});
|
|
12731
|
-
const MetadataSchema = objectType({
|
|
12732
|
-
metadata: arrayType(MetadataFieldSchema)
|
|
12733
|
-
});
|
|
12734
|
-
const Metadata = () => {
|
|
12850
|
+
const BillingAddress = () => {
|
|
12735
12851
|
const { id } = useParams();
|
|
12736
12852
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
12737
|
-
fields: "
|
|
12853
|
+
fields: "+billing_address"
|
|
12738
12854
|
});
|
|
12739
12855
|
if (isError) {
|
|
12740
12856
|
throw error;
|
|
@@ -12742,301 +12858,185 @@ const Metadata = () => {
|
|
|
12742
12858
|
const isReady = !isPending && !!order;
|
|
12743
12859
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12744
12860
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12745
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "
|
|
12746
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", 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" }) })
|
|
12747
12863
|
] }),
|
|
12748
|
-
|
|
12864
|
+
isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
|
|
12749
12865
|
] });
|
|
12750
12866
|
};
|
|
12751
|
-
const
|
|
12752
|
-
|
|
12753
|
-
const MetadataForm = ({ orderId, metadata }) => {
|
|
12754
|
-
const { handleSuccess } = useRouteModal();
|
|
12755
|
-
const hasUneditableRows = getHasUneditableRows(metadata);
|
|
12756
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
|
|
12867
|
+
const BillingAddressForm = ({ order }) => {
|
|
12868
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12757
12869
|
const form = useForm({
|
|
12758
12870
|
defaultValues: {
|
|
12759
|
-
|
|
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) ?? ""
|
|
12760
12881
|
},
|
|
12761
|
-
resolver: zodResolver(
|
|
12882
|
+
resolver: zodResolver(schema)
|
|
12762
12883
|
});
|
|
12763
|
-
const
|
|
12764
|
-
|
|
12884
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12885
|
+
const { handleSuccess } = useRouteModal();
|
|
12886
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12765
12887
|
await mutateAsync(
|
|
12766
|
-
{
|
|
12767
|
-
metadata: parsedData
|
|
12768
|
-
},
|
|
12888
|
+
{ billing_address: data },
|
|
12769
12889
|
{
|
|
12770
12890
|
onSuccess: () => {
|
|
12771
|
-
toast.success("Metadata updated");
|
|
12772
12891
|
handleSuccess();
|
|
12773
12892
|
},
|
|
12774
12893
|
onError: (error) => {
|
|
12775
12894
|
toast.error(error.message);
|
|
12776
12895
|
}
|
|
12777
12896
|
}
|
|
12778
|
-
);
|
|
12779
|
-
});
|
|
12780
|
-
|
|
12781
|
-
|
|
12782
|
-
|
|
12783
|
-
|
|
12784
|
-
|
|
12785
|
-
|
|
12786
|
-
|
|
12787
|
-
|
|
12788
|
-
|
|
12789
|
-
|
|
12790
|
-
|
|
12791
|
-
|
|
12792
|
-
|
|
12793
|
-
|
|
12794
|
-
|
|
12795
|
-
|
|
12796
|
-
|
|
12797
|
-
|
|
12798
|
-
|
|
12799
|
-
|
|
12800
|
-
|
|
12801
|
-
|
|
12802
|
-
|
|
12803
|
-
|
|
12804
|
-
|
|
12805
|
-
|
|
12806
|
-
|
|
12807
|
-
|
|
12808
|
-
|
|
12809
|
-
|
|
12810
|
-
|
|
12811
|
-
|
|
12812
|
-
|
|
12813
|
-
|
|
12814
|
-
|
|
12815
|
-
|
|
12816
|
-
|
|
12817
|
-
|
|
12818
|
-
|
|
12819
|
-
|
|
12820
|
-
|
|
12821
|
-
|
|
12822
|
-
|
|
12823
|
-
|
|
12824
|
-
{
|
|
12825
|
-
showTooltip: isDisabled,
|
|
12826
|
-
content: "This row is disabled because it contains non-primitive data.",
|
|
12827
|
-
children: /* @__PURE__ */ jsxs("div", { className: "group/table relative", children: [
|
|
12828
|
-
/* @__PURE__ */ jsxs(
|
|
12829
|
-
"div",
|
|
12830
|
-
{
|
|
12831
|
-
className: clx("grid grid-cols-2 divide-x", {
|
|
12832
|
-
"overflow-hidden rounded-b-lg": index === fields.length - 1
|
|
12833
|
-
}),
|
|
12834
|
-
children: [
|
|
12835
|
-
/* @__PURE__ */ jsx(
|
|
12836
|
-
Form$2.Field,
|
|
12837
|
-
{
|
|
12838
|
-
control: form.control,
|
|
12839
|
-
name: `metadata.${index}.key`,
|
|
12840
|
-
render: ({ field: field2 }) => {
|
|
12841
|
-
return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
12842
|
-
GridInput,
|
|
12843
|
-
{
|
|
12844
|
-
"aria-labelledby": METADATA_KEY_LABEL_ID,
|
|
12845
|
-
...field2,
|
|
12846
|
-
disabled: isDisabled,
|
|
12847
|
-
placeholder: "Key"
|
|
12848
|
-
}
|
|
12849
|
-
) }) });
|
|
12850
|
-
}
|
|
12851
|
-
}
|
|
12852
|
-
),
|
|
12853
|
-
/* @__PURE__ */ jsx(
|
|
12854
|
-
Form$2.Field,
|
|
12855
|
-
{
|
|
12856
|
-
control: form.control,
|
|
12857
|
-
name: `metadata.${index}.value`,
|
|
12858
|
-
render: ({ field: { value, ...field2 } }) => {
|
|
12859
|
-
return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
12860
|
-
GridInput,
|
|
12861
|
-
{
|
|
12862
|
-
"aria-labelledby": METADATA_VALUE_LABEL_ID,
|
|
12863
|
-
...field2,
|
|
12864
|
-
value: isDisabled ? placeholder : value,
|
|
12865
|
-
disabled: isDisabled,
|
|
12866
|
-
placeholder: "Value"
|
|
12867
|
-
}
|
|
12868
|
-
) }) });
|
|
12869
|
-
}
|
|
12870
|
-
}
|
|
12871
|
-
)
|
|
12872
|
-
]
|
|
12873
|
-
}
|
|
12874
|
-
),
|
|
12875
|
-
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
12876
|
-
/* @__PURE__ */ jsx(
|
|
12877
|
-
DropdownMenu.Trigger,
|
|
12878
|
-
{
|
|
12879
|
-
className: clx(
|
|
12880
|
-
"invisible absolute inset-y-0 -right-2.5 my-auto group-hover/table:visible data-[state='open']:visible",
|
|
12881
|
-
{
|
|
12882
|
-
hidden: isDisabled
|
|
12883
|
-
}
|
|
12884
|
-
),
|
|
12885
|
-
disabled: isDisabled,
|
|
12886
|
-
asChild: true,
|
|
12887
|
-
children: /* @__PURE__ */ jsx(IconButton, { size: "2xsmall", children: /* @__PURE__ */ jsx(EllipsisVertical, {}) })
|
|
12888
|
-
}
|
|
12889
|
-
),
|
|
12890
|
-
/* @__PURE__ */ jsxs(DropdownMenu.Content, { children: [
|
|
12891
|
-
/* @__PURE__ */ jsxs(
|
|
12892
|
-
DropdownMenu.Item,
|
|
12893
|
-
{
|
|
12894
|
-
className: "gap-x-2",
|
|
12895
|
-
onClick: () => insertRow(index, "above"),
|
|
12896
|
-
children: [
|
|
12897
|
-
/* @__PURE__ */ jsx(ArrowUpMini, { className: "text-ui-fg-subtle" }),
|
|
12898
|
-
"Insert row above"
|
|
12899
|
-
]
|
|
12900
|
-
}
|
|
12901
|
-
),
|
|
12902
|
-
/* @__PURE__ */ jsxs(
|
|
12903
|
-
DropdownMenu.Item,
|
|
12904
|
-
{
|
|
12905
|
-
className: "gap-x-2",
|
|
12906
|
-
onClick: () => insertRow(index, "below"),
|
|
12907
|
-
children: [
|
|
12908
|
-
/* @__PURE__ */ jsx(ArrowDownMini, { className: "text-ui-fg-subtle" }),
|
|
12909
|
-
"Insert row below"
|
|
12910
|
-
]
|
|
12911
|
-
}
|
|
12912
|
-
),
|
|
12913
|
-
/* @__PURE__ */ jsx(DropdownMenu.Separator, {}),
|
|
12914
|
-
/* @__PURE__ */ jsxs(
|
|
12915
|
-
DropdownMenu.Item,
|
|
12916
|
-
{
|
|
12917
|
-
className: "gap-x-2",
|
|
12918
|
-
onClick: () => deleteRow(index),
|
|
12919
|
-
children: [
|
|
12920
|
-
/* @__PURE__ */ jsx(Trash, { className: "text-ui-fg-subtle" }),
|
|
12921
|
-
"Delete row"
|
|
12922
|
-
]
|
|
12923
|
-
}
|
|
12924
|
-
)
|
|
12925
|
-
] })
|
|
12926
|
-
] })
|
|
12927
|
-
] })
|
|
12928
|
-
},
|
|
12929
|
-
field.id
|
|
12930
|
-
);
|
|
12931
|
-
})
|
|
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
|
+
)
|
|
12932
12943
|
] }),
|
|
12933
|
-
|
|
12934
|
-
|
|
12935
|
-
|
|
12936
|
-
|
|
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" }) }),
|
|
12937
13033
|
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12938
13034
|
] }) })
|
|
12939
13035
|
]
|
|
12940
13036
|
}
|
|
12941
13037
|
) });
|
|
12942
13038
|
};
|
|
12943
|
-
const
|
|
12944
|
-
return /* @__PURE__ */ jsx(
|
|
12945
|
-
"input",
|
|
12946
|
-
{
|
|
12947
|
-
ref,
|
|
12948
|
-
...props,
|
|
12949
|
-
autoComplete: "off",
|
|
12950
|
-
className: clx(
|
|
12951
|
-
"txt-compact-small text-ui-fg-base placeholder:text-ui-fg-muted disabled:text-ui-fg-disabled disabled:bg-ui-bg-base bg-transparent px-2 py-1.5 outline-none",
|
|
12952
|
-
className
|
|
12953
|
-
)
|
|
12954
|
-
}
|
|
12955
|
-
);
|
|
12956
|
-
});
|
|
12957
|
-
GridInput.displayName = "MetadataForm.GridInput";
|
|
12958
|
-
const PlaceholderInner = () => {
|
|
12959
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
12960
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-[148ox] w-full rounded-lg" }) }),
|
|
12961
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
12962
|
-
/* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-12 rounded-md" }),
|
|
12963
|
-
/* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-12 rounded-md" })
|
|
12964
|
-
] }) })
|
|
12965
|
-
] });
|
|
12966
|
-
};
|
|
12967
|
-
const EDITABLE_TYPES = ["string", "number", "boolean"];
|
|
12968
|
-
function getDefaultValues(metadata) {
|
|
12969
|
-
if (!metadata || !Object.keys(metadata).length) {
|
|
12970
|
-
return [
|
|
12971
|
-
{
|
|
12972
|
-
key: "",
|
|
12973
|
-
value: "",
|
|
12974
|
-
disabled: false
|
|
12975
|
-
}
|
|
12976
|
-
];
|
|
12977
|
-
}
|
|
12978
|
-
return Object.entries(metadata).map(([key, value]) => {
|
|
12979
|
-
if (!EDITABLE_TYPES.includes(typeof value)) {
|
|
12980
|
-
return {
|
|
12981
|
-
key,
|
|
12982
|
-
value,
|
|
12983
|
-
disabled: true
|
|
12984
|
-
};
|
|
12985
|
-
}
|
|
12986
|
-
let stringValue = value;
|
|
12987
|
-
if (typeof value !== "string") {
|
|
12988
|
-
stringValue = JSON.stringify(value);
|
|
12989
|
-
}
|
|
12990
|
-
return {
|
|
12991
|
-
key,
|
|
12992
|
-
value: stringValue,
|
|
12993
|
-
original_key: key
|
|
12994
|
-
};
|
|
12995
|
-
});
|
|
12996
|
-
}
|
|
12997
|
-
function parseValues(values) {
|
|
12998
|
-
const metadata = values.metadata;
|
|
12999
|
-
const isEmpty = !metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value;
|
|
13000
|
-
if (isEmpty) {
|
|
13001
|
-
return null;
|
|
13002
|
-
}
|
|
13003
|
-
const update = {};
|
|
13004
|
-
metadata.forEach((field) => {
|
|
13005
|
-
let key = field.key;
|
|
13006
|
-
let value = field.value;
|
|
13007
|
-
const disabled = field.disabled;
|
|
13008
|
-
if (!key || !value) {
|
|
13009
|
-
return;
|
|
13010
|
-
}
|
|
13011
|
-
if (disabled) {
|
|
13012
|
-
update[key] = value;
|
|
13013
|
-
return;
|
|
13014
|
-
}
|
|
13015
|
-
key = key.trim();
|
|
13016
|
-
value = value.trim();
|
|
13017
|
-
if (value === "true") {
|
|
13018
|
-
update[key] = true;
|
|
13019
|
-
} else if (value === "false") {
|
|
13020
|
-
update[key] = false;
|
|
13021
|
-
} else {
|
|
13022
|
-
const parsedNumber = parseFloat(value);
|
|
13023
|
-
if (!isNaN(parsedNumber)) {
|
|
13024
|
-
update[key] = parsedNumber;
|
|
13025
|
-
} else {
|
|
13026
|
-
update[key] = value;
|
|
13027
|
-
}
|
|
13028
|
-
}
|
|
13029
|
-
});
|
|
13030
|
-
return update;
|
|
13031
|
-
}
|
|
13032
|
-
function getHasUneditableRows(metadata) {
|
|
13033
|
-
if (!metadata) {
|
|
13034
|
-
return false;
|
|
13035
|
-
}
|
|
13036
|
-
return Object.values(metadata).some(
|
|
13037
|
-
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
13038
|
-
);
|
|
13039
|
-
}
|
|
13039
|
+
const schema = addressSchema;
|
|
13040
13040
|
const widgetModule = { widgets: [] };
|
|
13041
13041
|
const routeModule = {
|
|
13042
13042
|
routes: [
|
|
@@ -13062,25 +13062,25 @@ const routeModule = {
|
|
|
13062
13062
|
path: "/draft-orders/:id/custom-items"
|
|
13063
13063
|
},
|
|
13064
13064
|
{
|
|
13065
|
-
Component:
|
|
13066
|
-
path: "/draft-orders/:id/
|
|
13065
|
+
Component: Email,
|
|
13066
|
+
path: "/draft-orders/:id/email"
|
|
13067
13067
|
},
|
|
13068
13068
|
{
|
|
13069
13069
|
Component: Items,
|
|
13070
13070
|
path: "/draft-orders/:id/items"
|
|
13071
13071
|
},
|
|
13072
13072
|
{
|
|
13073
|
-
Component:
|
|
13074
|
-
path: "/draft-orders/:id/
|
|
13075
|
-
},
|
|
13076
|
-
{
|
|
13077
|
-
Component: SalesChannel,
|
|
13078
|
-
path: "/draft-orders/:id/sales-channel"
|
|
13073
|
+
Component: Metadata,
|
|
13074
|
+
path: "/draft-orders/:id/metadata"
|
|
13079
13075
|
},
|
|
13080
13076
|
{
|
|
13081
13077
|
Component: Promotions,
|
|
13082
13078
|
path: "/draft-orders/:id/promotions"
|
|
13083
13079
|
},
|
|
13080
|
+
{
|
|
13081
|
+
Component: SalesChannel,
|
|
13082
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13083
|
+
},
|
|
13084
13084
|
{
|
|
13085
13085
|
Component: Shipping,
|
|
13086
13086
|
path: "/draft-orders/:id/shipping"
|
|
@@ -13094,8 +13094,8 @@ const routeModule = {
|
|
|
13094
13094
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13095
13095
|
},
|
|
13096
13096
|
{
|
|
13097
|
-
Component:
|
|
13098
|
-
path: "/draft-orders/:id/
|
|
13097
|
+
Component: BillingAddress,
|
|
13098
|
+
path: "/draft-orders/:id/billing-address"
|
|
13099
13099
|
}
|
|
13100
13100
|
]
|
|
13101
13101
|
}
|