@medusajs/draft-order 2.11.0 → 2.11.1-snapshot-20251021083840
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 +690 -690
- package/.medusa/server/src/admin/index.mjs +690 -690
- package/package.json +24 -22
|
@@ -9571,27 +9571,6 @@ const ID = () => {
|
|
|
9571
9571
|
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
9572
9572
|
] });
|
|
9573
9573
|
};
|
|
9574
|
-
const CustomItems = () => {
|
|
9575
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9576
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
9577
|
-
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
9578
|
-
] });
|
|
9579
|
-
};
|
|
9580
|
-
const CustomItemsForm = () => {
|
|
9581
|
-
const form = reactHookForm.useForm({
|
|
9582
|
-
resolver: zod.zodResolver(schema$5)
|
|
9583
|
-
});
|
|
9584
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9585
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
9586
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9587
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9588
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
9589
|
-
] }) })
|
|
9590
|
-
] }) });
|
|
9591
|
-
};
|
|
9592
|
-
const schema$5 = objectType({
|
|
9593
|
-
email: stringType().email()
|
|
9594
|
-
});
|
|
9595
9574
|
const BillingAddress = () => {
|
|
9596
9575
|
const { id } = reactRouterDom.useParams();
|
|
9597
9576
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -9624,7 +9603,7 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9624
9603
|
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9625
9604
|
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9626
9605
|
},
|
|
9627
|
-
resolver: zod.zodResolver(schema$
|
|
9606
|
+
resolver: zod.zodResolver(schema$5)
|
|
9628
9607
|
});
|
|
9629
9608
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9630
9609
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9781,7 +9760,96 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9781
9760
|
}
|
|
9782
9761
|
) });
|
|
9783
9762
|
};
|
|
9784
|
-
const schema$
|
|
9763
|
+
const schema$5 = addressSchema;
|
|
9764
|
+
const CustomItems = () => {
|
|
9765
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9766
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
9767
|
+
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
9768
|
+
] });
|
|
9769
|
+
};
|
|
9770
|
+
const CustomItemsForm = () => {
|
|
9771
|
+
const form = reactHookForm.useForm({
|
|
9772
|
+
resolver: zod.zodResolver(schema$4)
|
|
9773
|
+
});
|
|
9774
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9775
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
9776
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9777
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9778
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
9779
|
+
] }) })
|
|
9780
|
+
] }) });
|
|
9781
|
+
};
|
|
9782
|
+
const schema$4 = objectType({
|
|
9783
|
+
email: stringType().email()
|
|
9784
|
+
});
|
|
9785
|
+
const Email = () => {
|
|
9786
|
+
const { id } = reactRouterDom.useParams();
|
|
9787
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
9788
|
+
fields: "+email"
|
|
9789
|
+
});
|
|
9790
|
+
if (isError) {
|
|
9791
|
+
throw error;
|
|
9792
|
+
}
|
|
9793
|
+
const isReady = !isPending && !!order;
|
|
9794
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9795
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
9796
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
|
|
9797
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
9798
|
+
] }),
|
|
9799
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
|
|
9800
|
+
] });
|
|
9801
|
+
};
|
|
9802
|
+
const EmailForm = ({ order }) => {
|
|
9803
|
+
const form = reactHookForm.useForm({
|
|
9804
|
+
defaultValues: {
|
|
9805
|
+
email: order.email ?? ""
|
|
9806
|
+
},
|
|
9807
|
+
resolver: zod.zodResolver(schema$3)
|
|
9808
|
+
});
|
|
9809
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9810
|
+
const { handleSuccess } = useRouteModal();
|
|
9811
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
9812
|
+
await mutateAsync(
|
|
9813
|
+
{ email: data.email },
|
|
9814
|
+
{
|
|
9815
|
+
onSuccess: () => {
|
|
9816
|
+
handleSuccess();
|
|
9817
|
+
},
|
|
9818
|
+
onError: (error) => {
|
|
9819
|
+
ui.toast.error(error.message);
|
|
9820
|
+
}
|
|
9821
|
+
}
|
|
9822
|
+
);
|
|
9823
|
+
});
|
|
9824
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9825
|
+
KeyboundForm,
|
|
9826
|
+
{
|
|
9827
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
9828
|
+
onSubmit,
|
|
9829
|
+
children: [
|
|
9830
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9831
|
+
Form$2.Field,
|
|
9832
|
+
{
|
|
9833
|
+
control: form.control,
|
|
9834
|
+
name: "email",
|
|
9835
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9836
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
|
|
9837
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9838
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9839
|
+
] })
|
|
9840
|
+
}
|
|
9841
|
+
) }),
|
|
9842
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9843
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9844
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9845
|
+
] }) })
|
|
9846
|
+
]
|
|
9847
|
+
}
|
|
9848
|
+
) });
|
|
9849
|
+
};
|
|
9850
|
+
const schema$3 = objectType({
|
|
9851
|
+
email: stringType().email()
|
|
9852
|
+
});
|
|
9785
9853
|
const NumberInput = React.forwardRef(
|
|
9786
9854
|
({
|
|
9787
9855
|
value,
|
|
@@ -10756,10 +10824,54 @@ const customItemSchema = objectType({
|
|
|
10756
10824
|
quantity: numberType(),
|
|
10757
10825
|
unit_price: unionType([numberType(), stringType()])
|
|
10758
10826
|
});
|
|
10759
|
-
const
|
|
10827
|
+
const InlineTip = React.forwardRef(
|
|
10828
|
+
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
10829
|
+
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
10830
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10831
|
+
"div",
|
|
10832
|
+
{
|
|
10833
|
+
ref,
|
|
10834
|
+
className: ui.clx(
|
|
10835
|
+
"bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
|
|
10836
|
+
className
|
|
10837
|
+
),
|
|
10838
|
+
...props,
|
|
10839
|
+
children: [
|
|
10840
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10841
|
+
"div",
|
|
10842
|
+
{
|
|
10843
|
+
role: "presentation",
|
|
10844
|
+
className: ui.clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
|
|
10845
|
+
"bg-ui-tag-orange-icon": variant === "warning"
|
|
10846
|
+
})
|
|
10847
|
+
}
|
|
10848
|
+
),
|
|
10849
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-pretty", children: [
|
|
10850
|
+
/* @__PURE__ */ jsxRuntime.jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
|
|
10851
|
+
labelValue,
|
|
10852
|
+
":"
|
|
10853
|
+
] }),
|
|
10854
|
+
" ",
|
|
10855
|
+
children
|
|
10856
|
+
] })
|
|
10857
|
+
]
|
|
10858
|
+
}
|
|
10859
|
+
);
|
|
10860
|
+
}
|
|
10861
|
+
);
|
|
10862
|
+
InlineTip.displayName = "InlineTip";
|
|
10863
|
+
const MetadataFieldSchema = objectType({
|
|
10864
|
+
key: stringType(),
|
|
10865
|
+
disabled: booleanType().optional(),
|
|
10866
|
+
value: anyType()
|
|
10867
|
+
});
|
|
10868
|
+
const MetadataSchema = objectType({
|
|
10869
|
+
metadata: arrayType(MetadataFieldSchema)
|
|
10870
|
+
});
|
|
10871
|
+
const Metadata = () => {
|
|
10760
10872
|
const { id } = reactRouterDom.useParams();
|
|
10761
10873
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
10762
|
-
fields: "
|
|
10874
|
+
fields: "metadata"
|
|
10763
10875
|
});
|
|
10764
10876
|
if (isError) {
|
|
10765
10877
|
throw error;
|
|
@@ -10767,26 +10879,33 @@ const Email = () => {
|
|
|
10767
10879
|
const isReady = !isPending && !!order;
|
|
10768
10880
|
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
10769
10881
|
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
10770
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "
|
|
10771
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "
|
|
10882
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Metadata" }) }),
|
|
10883
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
|
|
10772
10884
|
] }),
|
|
10773
|
-
isReady
|
|
10885
|
+
!isReady ? /* @__PURE__ */ jsxRuntime.jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsxRuntime.jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
|
|
10774
10886
|
] });
|
|
10775
10887
|
};
|
|
10776
|
-
const
|
|
10888
|
+
const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
|
|
10889
|
+
const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
|
|
10890
|
+
const MetadataForm = ({ orderId, metadata }) => {
|
|
10891
|
+
const { handleSuccess } = useRouteModal();
|
|
10892
|
+
const hasUneditableRows = getHasUneditableRows(metadata);
|
|
10893
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
|
|
10777
10894
|
const form = reactHookForm.useForm({
|
|
10778
10895
|
defaultValues: {
|
|
10779
|
-
|
|
10896
|
+
metadata: getDefaultValues(metadata)
|
|
10780
10897
|
},
|
|
10781
|
-
resolver: zod.zodResolver(
|
|
10898
|
+
resolver: zod.zodResolver(MetadataSchema)
|
|
10782
10899
|
});
|
|
10783
|
-
const
|
|
10784
|
-
|
|
10785
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
10900
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
10901
|
+
const parsedData = parseValues(data);
|
|
10786
10902
|
await mutateAsync(
|
|
10787
|
-
{
|
|
10903
|
+
{
|
|
10904
|
+
metadata: parsedData
|
|
10905
|
+
},
|
|
10788
10906
|
{
|
|
10789
10907
|
onSuccess: () => {
|
|
10908
|
+
ui.toast.success("Metadata updated");
|
|
10790
10909
|
handleSuccess();
|
|
10791
10910
|
},
|
|
10792
10911
|
onError: (error) => {
|
|
@@ -10795,182 +10914,307 @@ const EmailForm = ({ order }) => {
|
|
|
10795
10914
|
}
|
|
10796
10915
|
);
|
|
10797
10916
|
});
|
|
10917
|
+
const { fields, insert, remove } = reactHookForm.useFieldArray({
|
|
10918
|
+
control: form.control,
|
|
10919
|
+
name: "metadata"
|
|
10920
|
+
});
|
|
10921
|
+
function deleteRow(index) {
|
|
10922
|
+
remove(index);
|
|
10923
|
+
if (fields.length === 1) {
|
|
10924
|
+
insert(0, {
|
|
10925
|
+
key: "",
|
|
10926
|
+
value: "",
|
|
10927
|
+
disabled: false
|
|
10928
|
+
});
|
|
10929
|
+
}
|
|
10930
|
+
}
|
|
10931
|
+
function insertRow(index, position) {
|
|
10932
|
+
insert(index + (position === "above" ? 0 : 1), {
|
|
10933
|
+
key: "",
|
|
10934
|
+
value: "",
|
|
10935
|
+
disabled: false
|
|
10936
|
+
});
|
|
10937
|
+
}
|
|
10798
10938
|
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10799
10939
|
KeyboundForm,
|
|
10800
10940
|
{
|
|
10941
|
+
onSubmit: handleSubmit,
|
|
10801
10942
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
10802
|
-
onSubmit,
|
|
10803
10943
|
children: [
|
|
10804
|
-
/* @__PURE__ */ jsxRuntime.
|
|
10805
|
-
|
|
10806
|
-
|
|
10807
|
-
|
|
10808
|
-
|
|
10809
|
-
|
|
10810
|
-
|
|
10811
|
-
|
|
10812
|
-
|
|
10813
|
-
|
|
10814
|
-
|
|
10815
|
-
|
|
10816
|
-
|
|
10817
|
-
|
|
10818
|
-
|
|
10819
|
-
|
|
10820
|
-
|
|
10821
|
-
|
|
10822
|
-
|
|
10823
|
-
|
|
10824
|
-
|
|
10825
|
-
|
|
10826
|
-
|
|
10827
|
-
|
|
10828
|
-
|
|
10829
|
-
|
|
10830
|
-
|
|
10831
|
-
|
|
10832
|
-
|
|
10833
|
-
|
|
10834
|
-
|
|
10835
|
-
|
|
10836
|
-
|
|
10837
|
-
|
|
10838
|
-
|
|
10839
|
-
|
|
10840
|
-
|
|
10841
|
-
|
|
10842
|
-
|
|
10843
|
-
|
|
10844
|
-
|
|
10845
|
-
|
|
10846
|
-
|
|
10847
|
-
|
|
10848
|
-
|
|
10849
|
-
|
|
10850
|
-
|
|
10851
|
-
|
|
10852
|
-
|
|
10853
|
-
|
|
10854
|
-
|
|
10855
|
-
|
|
10856
|
-
|
|
10857
|
-
|
|
10858
|
-
|
|
10859
|
-
|
|
10860
|
-
|
|
10861
|
-
|
|
10862
|
-
|
|
10863
|
-
|
|
10864
|
-
|
|
10865
|
-
|
|
10866
|
-
|
|
10867
|
-
|
|
10868
|
-
|
|
10869
|
-
|
|
10870
|
-
|
|
10871
|
-
|
|
10872
|
-
|
|
10873
|
-
|
|
10874
|
-
|
|
10875
|
-
|
|
10876
|
-
|
|
10877
|
-
|
|
10878
|
-
|
|
10879
|
-
|
|
10880
|
-
|
|
10881
|
-
|
|
10882
|
-
|
|
10883
|
-
|
|
10944
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: [
|
|
10945
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-1 divide-y rounded-lg", children: [
|
|
10946
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle grid grid-cols-2 divide-x rounded-t-lg", children: [
|
|
10947
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsxRuntime.jsx("label", { id: METADATA_KEY_LABEL_ID, children: "Key" }) }),
|
|
10948
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsxRuntime.jsx("label", { id: METADATA_VALUE_LABEL_ID, children: "Value" }) })
|
|
10949
|
+
] }),
|
|
10950
|
+
fields.map((field, index) => {
|
|
10951
|
+
const isDisabled = field.disabled || false;
|
|
10952
|
+
let placeholder = "-";
|
|
10953
|
+
if (typeof field.value === "object") {
|
|
10954
|
+
placeholder = "{ ... }";
|
|
10955
|
+
}
|
|
10956
|
+
if (Array.isArray(field.value)) {
|
|
10957
|
+
placeholder = "[ ... ]";
|
|
10958
|
+
}
|
|
10959
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10960
|
+
ConditionalTooltip,
|
|
10961
|
+
{
|
|
10962
|
+
showTooltip: isDisabled,
|
|
10963
|
+
content: "This row is disabled because it contains non-primitive data.",
|
|
10964
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "group/table relative", children: [
|
|
10965
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10966
|
+
"div",
|
|
10967
|
+
{
|
|
10968
|
+
className: ui.clx("grid grid-cols-2 divide-x", {
|
|
10969
|
+
"overflow-hidden rounded-b-lg": index === fields.length - 1
|
|
10970
|
+
}),
|
|
10971
|
+
children: [
|
|
10972
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10973
|
+
Form$2.Field,
|
|
10974
|
+
{
|
|
10975
|
+
control: form.control,
|
|
10976
|
+
name: `metadata.${index}.key`,
|
|
10977
|
+
render: ({ field: field2 }) => {
|
|
10978
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10979
|
+
GridInput,
|
|
10980
|
+
{
|
|
10981
|
+
"aria-labelledby": METADATA_KEY_LABEL_ID,
|
|
10982
|
+
...field2,
|
|
10983
|
+
disabled: isDisabled,
|
|
10984
|
+
placeholder: "Key"
|
|
10985
|
+
}
|
|
10986
|
+
) }) });
|
|
10987
|
+
}
|
|
10988
|
+
}
|
|
10989
|
+
),
|
|
10990
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10991
|
+
Form$2.Field,
|
|
10992
|
+
{
|
|
10993
|
+
control: form.control,
|
|
10994
|
+
name: `metadata.${index}.value`,
|
|
10995
|
+
render: ({ field: { value, ...field2 } }) => {
|
|
10996
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10997
|
+
GridInput,
|
|
10998
|
+
{
|
|
10999
|
+
"aria-labelledby": METADATA_VALUE_LABEL_ID,
|
|
11000
|
+
...field2,
|
|
11001
|
+
value: isDisabled ? placeholder : value,
|
|
11002
|
+
disabled: isDisabled,
|
|
11003
|
+
placeholder: "Value"
|
|
11004
|
+
}
|
|
11005
|
+
) }) });
|
|
11006
|
+
}
|
|
11007
|
+
}
|
|
11008
|
+
)
|
|
11009
|
+
]
|
|
11010
|
+
}
|
|
11011
|
+
),
|
|
11012
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu, { children: [
|
|
11013
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11014
|
+
ui.DropdownMenu.Trigger,
|
|
11015
|
+
{
|
|
11016
|
+
className: ui.clx(
|
|
11017
|
+
"invisible absolute inset-y-0 -right-2.5 my-auto group-hover/table:visible data-[state='open']:visible",
|
|
11018
|
+
{
|
|
11019
|
+
hidden: isDisabled
|
|
11020
|
+
}
|
|
11021
|
+
),
|
|
11022
|
+
disabled: isDisabled,
|
|
11023
|
+
asChild: true,
|
|
11024
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { size: "2xsmall", children: /* @__PURE__ */ jsxRuntime.jsx(icons.EllipsisVertical, {}) })
|
|
11025
|
+
}
|
|
11026
|
+
),
|
|
11027
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu.Content, { children: [
|
|
11028
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
11029
|
+
ui.DropdownMenu.Item,
|
|
11030
|
+
{
|
|
11031
|
+
className: "gap-x-2",
|
|
11032
|
+
onClick: () => insertRow(index, "above"),
|
|
11033
|
+
children: [
|
|
11034
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowUpMini, { className: "text-ui-fg-subtle" }),
|
|
11035
|
+
"Insert row above"
|
|
11036
|
+
]
|
|
11037
|
+
}
|
|
11038
|
+
),
|
|
11039
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
11040
|
+
ui.DropdownMenu.Item,
|
|
11041
|
+
{
|
|
11042
|
+
className: "gap-x-2",
|
|
11043
|
+
onClick: () => insertRow(index, "below"),
|
|
11044
|
+
children: [
|
|
11045
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowDownMini, { className: "text-ui-fg-subtle" }),
|
|
11046
|
+
"Insert row below"
|
|
11047
|
+
]
|
|
11048
|
+
}
|
|
11049
|
+
),
|
|
11050
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenu.Separator, {}),
|
|
11051
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
11052
|
+
ui.DropdownMenu.Item,
|
|
11053
|
+
{
|
|
11054
|
+
className: "gap-x-2",
|
|
11055
|
+
onClick: () => deleteRow(index),
|
|
11056
|
+
children: [
|
|
11057
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.Trash, { className: "text-ui-fg-subtle" }),
|
|
11058
|
+
"Delete row"
|
|
11059
|
+
]
|
|
11060
|
+
}
|
|
11061
|
+
)
|
|
11062
|
+
] })
|
|
11063
|
+
] })
|
|
11064
|
+
] })
|
|
11065
|
+
},
|
|
11066
|
+
field.id
|
|
11067
|
+
);
|
|
11068
|
+
})
|
|
11069
|
+
] }),
|
|
11070
|
+
hasUneditableRows && /* @__PURE__ */ jsxRuntime.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." })
|
|
11071
|
+
] }),
|
|
11072
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
11073
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
10884
11074
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
10885
11075
|
] }) })
|
|
10886
11076
|
]
|
|
10887
11077
|
}
|
|
10888
11078
|
) });
|
|
10889
11079
|
};
|
|
10890
|
-
const
|
|
10891
|
-
const salesChannels = useComboboxData({
|
|
10892
|
-
queryFn: async (params) => {
|
|
10893
|
-
return await sdk.admin.salesChannel.list(params);
|
|
10894
|
-
},
|
|
10895
|
-
queryKey: ["sales-channels"],
|
|
10896
|
-
getOptions: (data) => {
|
|
10897
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
10898
|
-
label: salesChannel.name,
|
|
10899
|
-
value: salesChannel.id
|
|
10900
|
-
}));
|
|
10901
|
-
},
|
|
10902
|
-
defaultValue: order.sales_channel_id || void 0
|
|
10903
|
-
});
|
|
11080
|
+
const GridInput = React.forwardRef(({ className, ...props }, ref) => {
|
|
10904
11081
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10905
|
-
|
|
11082
|
+
"input",
|
|
10906
11083
|
{
|
|
10907
|
-
|
|
10908
|
-
|
|
10909
|
-
|
|
10910
|
-
|
|
10911
|
-
|
|
10912
|
-
|
|
10913
|
-
|
|
10914
|
-
{
|
|
10915
|
-
options: salesChannels.options,
|
|
10916
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
10917
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
10918
|
-
searchValue: salesChannels.searchValue,
|
|
10919
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
10920
|
-
placeholder: "Select sales channel",
|
|
10921
|
-
...field
|
|
10922
|
-
}
|
|
10923
|
-
) }),
|
|
10924
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
10925
|
-
] });
|
|
10926
|
-
}
|
|
11084
|
+
ref,
|
|
11085
|
+
...props,
|
|
11086
|
+
autoComplete: "off",
|
|
11087
|
+
className: ui.clx(
|
|
11088
|
+
"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",
|
|
11089
|
+
className
|
|
11090
|
+
)
|
|
10927
11091
|
}
|
|
10928
11092
|
);
|
|
10929
|
-
};
|
|
10930
|
-
const schema$2 = objectType({
|
|
10931
|
-
sales_channel_id: stringType().min(1)
|
|
10932
11093
|
});
|
|
10933
|
-
|
|
10934
|
-
const
|
|
10935
|
-
|
|
10936
|
-
|
|
10937
|
-
|
|
10938
|
-
|
|
10939
|
-
|
|
10940
|
-
|
|
10941
|
-
id,
|
|
10942
|
-
query2 ? query2 : void 0
|
|
10943
|
-
]
|
|
10944
|
-
};
|
|
10945
|
-
const usePromotions = (query2, options) => {
|
|
10946
|
-
const { data, ...rest } = reactQuery.useQuery({
|
|
10947
|
-
queryKey: promotionsQueryKeys.list(query2),
|
|
10948
|
-
queryFn: async () => sdk.admin.promotion.list(query2),
|
|
10949
|
-
...options
|
|
10950
|
-
});
|
|
10951
|
-
return { ...data, ...rest };
|
|
10952
|
-
};
|
|
10953
|
-
const Promotions = () => {
|
|
10954
|
-
const { id } = reactRouterDom.useParams();
|
|
10955
|
-
const {
|
|
10956
|
-
order: preview,
|
|
10957
|
-
isError: isPreviewError,
|
|
10958
|
-
error: previewError
|
|
10959
|
-
} = useOrderPreview(id, void 0);
|
|
10960
|
-
useInitiateOrderEdit({ preview });
|
|
10961
|
-
const { onCancel } = useCancelOrderEdit({ preview });
|
|
10962
|
-
if (isPreviewError) {
|
|
10963
|
-
throw previewError;
|
|
10964
|
-
}
|
|
10965
|
-
const isReady = !!preview;
|
|
10966
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { onClose: onCancel, children: [
|
|
10967
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Promotions" }) }) }),
|
|
10968
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(PromotionForm, { preview })
|
|
11094
|
+
GridInput.displayName = "MetadataForm.GridInput";
|
|
11095
|
+
const PlaceholderInner = () => {
|
|
11096
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
11097
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-[148ox] w-full rounded-lg" }) }),
|
|
11098
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
11099
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" }),
|
|
11100
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" })
|
|
11101
|
+
] }) })
|
|
10969
11102
|
] });
|
|
10970
11103
|
};
|
|
10971
|
-
const
|
|
10972
|
-
|
|
10973
|
-
|
|
11104
|
+
const EDITABLE_TYPES = ["string", "number", "boolean"];
|
|
11105
|
+
function getDefaultValues(metadata) {
|
|
11106
|
+
if (!metadata || !Object.keys(metadata).length) {
|
|
11107
|
+
return [
|
|
11108
|
+
{
|
|
11109
|
+
key: "",
|
|
11110
|
+
value: "",
|
|
11111
|
+
disabled: false
|
|
11112
|
+
}
|
|
11113
|
+
];
|
|
11114
|
+
}
|
|
11115
|
+
return Object.entries(metadata).map(([key, value]) => {
|
|
11116
|
+
if (!EDITABLE_TYPES.includes(typeof value)) {
|
|
11117
|
+
return {
|
|
11118
|
+
key,
|
|
11119
|
+
value,
|
|
11120
|
+
disabled: true
|
|
11121
|
+
};
|
|
11122
|
+
}
|
|
11123
|
+
let stringValue = value;
|
|
11124
|
+
if (typeof value !== "string") {
|
|
11125
|
+
stringValue = JSON.stringify(value);
|
|
11126
|
+
}
|
|
11127
|
+
return {
|
|
11128
|
+
key,
|
|
11129
|
+
value: stringValue,
|
|
11130
|
+
original_key: key
|
|
11131
|
+
};
|
|
11132
|
+
});
|
|
11133
|
+
}
|
|
11134
|
+
function parseValues(values) {
|
|
11135
|
+
const metadata = values.metadata;
|
|
11136
|
+
const isEmpty = !metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value;
|
|
11137
|
+
if (isEmpty) {
|
|
11138
|
+
return null;
|
|
11139
|
+
}
|
|
11140
|
+
const update = {};
|
|
11141
|
+
metadata.forEach((field) => {
|
|
11142
|
+
let key = field.key;
|
|
11143
|
+
let value = field.value;
|
|
11144
|
+
const disabled = field.disabled;
|
|
11145
|
+
if (!key || !value) {
|
|
11146
|
+
return;
|
|
11147
|
+
}
|
|
11148
|
+
if (disabled) {
|
|
11149
|
+
update[key] = value;
|
|
11150
|
+
return;
|
|
11151
|
+
}
|
|
11152
|
+
key = key.trim();
|
|
11153
|
+
value = value.trim();
|
|
11154
|
+
if (value === "true") {
|
|
11155
|
+
update[key] = true;
|
|
11156
|
+
} else if (value === "false") {
|
|
11157
|
+
update[key] = false;
|
|
11158
|
+
} else {
|
|
11159
|
+
const parsedNumber = parseFloat(value);
|
|
11160
|
+
if (!isNaN(parsedNumber)) {
|
|
11161
|
+
update[key] = parsedNumber;
|
|
11162
|
+
} else {
|
|
11163
|
+
update[key] = value;
|
|
11164
|
+
}
|
|
11165
|
+
}
|
|
11166
|
+
});
|
|
11167
|
+
return update;
|
|
11168
|
+
}
|
|
11169
|
+
function getHasUneditableRows(metadata) {
|
|
11170
|
+
if (!metadata) {
|
|
11171
|
+
return false;
|
|
11172
|
+
}
|
|
11173
|
+
return Object.values(metadata).some(
|
|
11174
|
+
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
11175
|
+
);
|
|
11176
|
+
}
|
|
11177
|
+
const PROMOTION_QUERY_KEY = "promotions";
|
|
11178
|
+
const promotionsQueryKeys = {
|
|
11179
|
+
list: (query2) => [
|
|
11180
|
+
PROMOTION_QUERY_KEY,
|
|
11181
|
+
query2 ? query2 : void 0
|
|
11182
|
+
],
|
|
11183
|
+
detail: (id, query2) => [
|
|
11184
|
+
PROMOTION_QUERY_KEY,
|
|
11185
|
+
id,
|
|
11186
|
+
query2 ? query2 : void 0
|
|
11187
|
+
]
|
|
11188
|
+
};
|
|
11189
|
+
const usePromotions = (query2, options) => {
|
|
11190
|
+
const { data, ...rest } = reactQuery.useQuery({
|
|
11191
|
+
queryKey: promotionsQueryKeys.list(query2),
|
|
11192
|
+
queryFn: async () => sdk.admin.promotion.list(query2),
|
|
11193
|
+
...options
|
|
11194
|
+
});
|
|
11195
|
+
return { ...data, ...rest };
|
|
11196
|
+
};
|
|
11197
|
+
const Promotions = () => {
|
|
11198
|
+
const { id } = reactRouterDom.useParams();
|
|
11199
|
+
const {
|
|
11200
|
+
order: preview,
|
|
11201
|
+
isError: isPreviewError,
|
|
11202
|
+
error: previewError
|
|
11203
|
+
} = useOrderPreview(id, void 0);
|
|
11204
|
+
useInitiateOrderEdit({ preview });
|
|
11205
|
+
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11206
|
+
if (isPreviewError) {
|
|
11207
|
+
throw previewError;
|
|
11208
|
+
}
|
|
11209
|
+
const isReady = !!preview;
|
|
11210
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { onClose: onCancel, children: [
|
|
11211
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Promotions" }) }) }),
|
|
11212
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(PromotionForm, { preview })
|
|
11213
|
+
] });
|
|
11214
|
+
};
|
|
11215
|
+
const PromotionForm = ({ preview }) => {
|
|
11216
|
+
const { items, shipping_methods } = preview;
|
|
11217
|
+
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
10974
11218
|
const [comboboxValue, setComboboxValue] = React.useState("");
|
|
10975
11219
|
const { handleSuccess } = useRouteModal();
|
|
10976
11220
|
const { mutateAsync: addPromotions, isPending: isAddingPromotions } = useDraftOrderAddPromotions(preview.id);
|
|
@@ -11207,6 +11451,112 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11207
11451
|
}
|
|
11208
11452
|
return Array.from(promotionIds);
|
|
11209
11453
|
}
|
|
11454
|
+
const SalesChannel = () => {
|
|
11455
|
+
const { id } = reactRouterDom.useParams();
|
|
11456
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11457
|
+
id,
|
|
11458
|
+
{
|
|
11459
|
+
fields: "+sales_channel_id"
|
|
11460
|
+
},
|
|
11461
|
+
{
|
|
11462
|
+
enabled: !!id
|
|
11463
|
+
}
|
|
11464
|
+
);
|
|
11465
|
+
if (isError) {
|
|
11466
|
+
throw error;
|
|
11467
|
+
}
|
|
11468
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
11469
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11470
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
11471
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
11472
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
11473
|
+
] }),
|
|
11474
|
+
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
11475
|
+
] });
|
|
11476
|
+
};
|
|
11477
|
+
const SalesChannelForm = ({ order }) => {
|
|
11478
|
+
const form = reactHookForm.useForm({
|
|
11479
|
+
defaultValues: {
|
|
11480
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
11481
|
+
},
|
|
11482
|
+
resolver: zod.zodResolver(schema$2)
|
|
11483
|
+
});
|
|
11484
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11485
|
+
const { handleSuccess } = useRouteModal();
|
|
11486
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11487
|
+
await mutateAsync(
|
|
11488
|
+
{
|
|
11489
|
+
sales_channel_id: data.sales_channel_id
|
|
11490
|
+
},
|
|
11491
|
+
{
|
|
11492
|
+
onSuccess: () => {
|
|
11493
|
+
ui.toast.success("Sales channel updated");
|
|
11494
|
+
handleSuccess();
|
|
11495
|
+
},
|
|
11496
|
+
onError: (error) => {
|
|
11497
|
+
ui.toast.error(error.message);
|
|
11498
|
+
}
|
|
11499
|
+
}
|
|
11500
|
+
);
|
|
11501
|
+
});
|
|
11502
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11503
|
+
KeyboundForm,
|
|
11504
|
+
{
|
|
11505
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11506
|
+
onSubmit,
|
|
11507
|
+
children: [
|
|
11508
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11509
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11510
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11511
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11512
|
+
] }) })
|
|
11513
|
+
]
|
|
11514
|
+
}
|
|
11515
|
+
) });
|
|
11516
|
+
};
|
|
11517
|
+
const SalesChannelField = ({ control, order }) => {
|
|
11518
|
+
const salesChannels = useComboboxData({
|
|
11519
|
+
queryFn: async (params) => {
|
|
11520
|
+
return await sdk.admin.salesChannel.list(params);
|
|
11521
|
+
},
|
|
11522
|
+
queryKey: ["sales-channels"],
|
|
11523
|
+
getOptions: (data) => {
|
|
11524
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
11525
|
+
label: salesChannel.name,
|
|
11526
|
+
value: salesChannel.id
|
|
11527
|
+
}));
|
|
11528
|
+
},
|
|
11529
|
+
defaultValue: order.sales_channel_id || void 0
|
|
11530
|
+
});
|
|
11531
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11532
|
+
Form$2.Field,
|
|
11533
|
+
{
|
|
11534
|
+
control,
|
|
11535
|
+
name: "sales_channel_id",
|
|
11536
|
+
render: ({ field }) => {
|
|
11537
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11538
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11539
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11540
|
+
Combobox,
|
|
11541
|
+
{
|
|
11542
|
+
options: salesChannels.options,
|
|
11543
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
11544
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11545
|
+
searchValue: salesChannels.searchValue,
|
|
11546
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11547
|
+
placeholder: "Select sales channel",
|
|
11548
|
+
...field
|
|
11549
|
+
}
|
|
11550
|
+
) }),
|
|
11551
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11552
|
+
] });
|
|
11553
|
+
}
|
|
11554
|
+
}
|
|
11555
|
+
);
|
|
11556
|
+
};
|
|
11557
|
+
const schema$2 = objectType({
|
|
11558
|
+
sales_channel_id: stringType().min(1)
|
|
11559
|
+
});
|
|
11210
11560
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11211
11561
|
const Shipping = () => {
|
|
11212
11562
|
var _a;
|
|
@@ -12554,495 +12904,145 @@ const Illustration = () => {
|
|
|
12554
12904
|
}
|
|
12555
12905
|
),
|
|
12556
12906
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12557
|
-
"rect",
|
|
12558
|
-
{
|
|
12559
|
-
width: "12",
|
|
12560
|
-
height: "3",
|
|
12561
|
-
rx: "1.5",
|
|
12562
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 105.4 62.5457)",
|
|
12563
|
-
fill: "#A1A1AA"
|
|
12564
|
-
}
|
|
12565
|
-
),
|
|
12566
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12567
|
-
"path",
|
|
12568
|
-
{
|
|
12569
|
-
d: "M104.562 57.0927C103.13 56.265 100.792 56.2515 99.3501 57.0626C97.9081 57.8738 97.9004 59.2065 99.333 60.0343C100.766 60.862 103.103 60.8754 104.545 60.0643C105.987 59.2532 105.995 57.9204 104.562 57.0927ZM103.858 58.8972L100.815 59.1265C100.683 59.1367 100.55 59.1134 100.449 59.063C100.44 59.0585 100.432 59.0545 100.425 59.05C100.339 59.0005 100.29 58.9336 100.291 58.8637L100.294 58.1201C100.294 57.9752 100.501 57.8585 100.756 57.86C101.01 57.8615 101.217 57.98 101.216 58.1256L101.214 58.5669L103.732 58.3769C103.984 58.3578 104.217 58.4584 104.251 58.603C104.286 58.7468 104.11 58.8788 103.858 58.8977L103.858 58.8972Z",
|
|
12570
|
-
fill: "#52525B"
|
|
12571
|
-
}
|
|
12572
|
-
),
|
|
12573
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip0_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12574
|
-
"path",
|
|
12575
|
-
{
|
|
12576
|
-
d: "M133.106 81.8022L140.49 81.8447L140.515 77.6349",
|
|
12577
|
-
stroke: "#A1A1AA",
|
|
12578
|
-
strokeWidth: "1.5",
|
|
12579
|
-
strokeLinecap: "round",
|
|
12580
|
-
strokeLinejoin: "round"
|
|
12581
|
-
}
|
|
12582
|
-
) }),
|
|
12583
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip1_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12584
|
-
"path",
|
|
12585
|
-
{
|
|
12586
|
-
d: "M143.496 87.8055L150.881 87.8481L150.905 83.6383",
|
|
12587
|
-
stroke: "#A1A1AA",
|
|
12588
|
-
strokeWidth: "1.5",
|
|
12589
|
-
strokeLinecap: "round",
|
|
12590
|
-
strokeLinejoin: "round"
|
|
12591
|
-
}
|
|
12592
|
-
) }),
|
|
12593
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip2_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12594
|
-
"path",
|
|
12595
|
-
{
|
|
12596
|
-
d: "M153.887 93.8088L161.271 93.8514L161.295 89.6416",
|
|
12597
|
-
stroke: "#A1A1AA",
|
|
12598
|
-
strokeWidth: "1.5",
|
|
12599
|
-
strokeLinecap: "round",
|
|
12600
|
-
strokeLinejoin: "round"
|
|
12601
|
-
}
|
|
12602
|
-
) }),
|
|
12603
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip3_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12604
|
-
"path",
|
|
12605
|
-
{
|
|
12606
|
-
d: "M126.114 89.1912L118.729 89.1486L118.705 93.3584",
|
|
12607
|
-
stroke: "#A1A1AA",
|
|
12608
|
-
strokeWidth: "1.5",
|
|
12609
|
-
strokeLinecap: "round",
|
|
12610
|
-
strokeLinejoin: "round"
|
|
12611
|
-
}
|
|
12612
|
-
) }),
|
|
12613
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip4_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12614
|
-
"path",
|
|
12615
|
-
{
|
|
12616
|
-
d: "M136.504 95.1945L129.12 95.1519L129.095 99.3617",
|
|
12617
|
-
stroke: "#A1A1AA",
|
|
12618
|
-
strokeWidth: "1.5",
|
|
12619
|
-
strokeLinecap: "round",
|
|
12620
|
-
strokeLinejoin: "round"
|
|
12621
|
-
}
|
|
12622
|
-
) }),
|
|
12623
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip5_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12624
|
-
"path",
|
|
12625
|
-
{
|
|
12626
|
-
d: "M146.894 101.198L139.51 101.155L139.486 105.365",
|
|
12627
|
-
stroke: "#A1A1AA",
|
|
12628
|
-
strokeWidth: "1.5",
|
|
12629
|
-
strokeLinecap: "round",
|
|
12630
|
-
strokeLinejoin: "round"
|
|
12631
|
-
}
|
|
12632
|
-
) }),
|
|
12633
|
-
/* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
|
|
12634
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12635
|
-
"rect",
|
|
12636
|
-
{
|
|
12637
|
-
width: "12",
|
|
12638
|
-
height: "12",
|
|
12639
|
-
fill: "white",
|
|
12640
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
|
|
12641
|
-
}
|
|
12642
|
-
) }),
|
|
12643
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12644
|
-
"rect",
|
|
12645
|
-
{
|
|
12646
|
-
width: "12",
|
|
12647
|
-
height: "12",
|
|
12648
|
-
fill: "white",
|
|
12649
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
|
|
12650
|
-
}
|
|
12651
|
-
) }),
|
|
12652
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12653
|
-
"rect",
|
|
12654
|
-
{
|
|
12655
|
-
width: "12",
|
|
12656
|
-
height: "12",
|
|
12657
|
-
fill: "white",
|
|
12658
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
|
|
12659
|
-
}
|
|
12660
|
-
) }),
|
|
12661
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12662
|
-
"rect",
|
|
12663
|
-
{
|
|
12664
|
-
width: "12",
|
|
12665
|
-
height: "12",
|
|
12666
|
-
fill: "white",
|
|
12667
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
|
|
12668
|
-
}
|
|
12669
|
-
) }),
|
|
12670
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12671
|
-
"rect",
|
|
12672
|
-
{
|
|
12673
|
-
width: "12",
|
|
12674
|
-
height: "12",
|
|
12675
|
-
fill: "white",
|
|
12676
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
|
|
12677
|
-
}
|
|
12678
|
-
) }),
|
|
12679
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12680
|
-
"rect",
|
|
12681
|
-
{
|
|
12682
|
-
width: "12",
|
|
12683
|
-
height: "12",
|
|
12684
|
-
fill: "white",
|
|
12685
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
|
|
12686
|
-
}
|
|
12687
|
-
) })
|
|
12688
|
-
] })
|
|
12689
|
-
]
|
|
12690
|
-
}
|
|
12691
|
-
);
|
|
12692
|
-
};
|
|
12693
|
-
const schema = objectType({
|
|
12694
|
-
customer_id: stringType().min(1)
|
|
12695
|
-
});
|
|
12696
|
-
const InlineTip = React.forwardRef(
|
|
12697
|
-
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
12698
|
-
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
12699
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12700
|
-
"div",
|
|
12701
|
-
{
|
|
12702
|
-
ref,
|
|
12703
|
-
className: ui.clx(
|
|
12704
|
-
"bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
|
|
12705
|
-
className
|
|
12706
|
-
),
|
|
12707
|
-
...props,
|
|
12708
|
-
children: [
|
|
12709
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12710
|
-
"div",
|
|
12711
|
-
{
|
|
12712
|
-
role: "presentation",
|
|
12713
|
-
className: ui.clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
|
|
12714
|
-
"bg-ui-tag-orange-icon": variant === "warning"
|
|
12715
|
-
})
|
|
12716
|
-
}
|
|
12717
|
-
),
|
|
12718
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-pretty", children: [
|
|
12719
|
-
/* @__PURE__ */ jsxRuntime.jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
|
|
12720
|
-
labelValue,
|
|
12721
|
-
":"
|
|
12722
|
-
] }),
|
|
12723
|
-
" ",
|
|
12724
|
-
children
|
|
12725
|
-
] })
|
|
12726
|
-
]
|
|
12727
|
-
}
|
|
12728
|
-
);
|
|
12729
|
-
}
|
|
12730
|
-
);
|
|
12731
|
-
InlineTip.displayName = "InlineTip";
|
|
12732
|
-
const MetadataFieldSchema = objectType({
|
|
12733
|
-
key: stringType(),
|
|
12734
|
-
disabled: booleanType().optional(),
|
|
12735
|
-
value: anyType()
|
|
12736
|
-
});
|
|
12737
|
-
const MetadataSchema = objectType({
|
|
12738
|
-
metadata: arrayType(MetadataFieldSchema)
|
|
12739
|
-
});
|
|
12740
|
-
const Metadata = () => {
|
|
12741
|
-
const { id } = reactRouterDom.useParams();
|
|
12742
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
12743
|
-
fields: "metadata"
|
|
12744
|
-
});
|
|
12745
|
-
if (isError) {
|
|
12746
|
-
throw error;
|
|
12747
|
-
}
|
|
12748
|
-
const isReady = !isPending && !!order;
|
|
12749
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12750
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12751
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Metadata" }) }),
|
|
12752
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
|
|
12753
|
-
] }),
|
|
12754
|
-
!isReady ? /* @__PURE__ */ jsxRuntime.jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsxRuntime.jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
|
|
12755
|
-
] });
|
|
12756
|
-
};
|
|
12757
|
-
const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
|
|
12758
|
-
const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
|
|
12759
|
-
const MetadataForm = ({ orderId, metadata }) => {
|
|
12760
|
-
const { handleSuccess } = useRouteModal();
|
|
12761
|
-
const hasUneditableRows = getHasUneditableRows(metadata);
|
|
12762
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
|
|
12763
|
-
const form = reactHookForm.useForm({
|
|
12764
|
-
defaultValues: {
|
|
12765
|
-
metadata: getDefaultValues(metadata)
|
|
12766
|
-
},
|
|
12767
|
-
resolver: zod.zodResolver(MetadataSchema)
|
|
12768
|
-
});
|
|
12769
|
-
const handleSubmit = form.handleSubmit(async (data) => {
|
|
12770
|
-
const parsedData = parseValues(data);
|
|
12771
|
-
await mutateAsync(
|
|
12772
|
-
{
|
|
12773
|
-
metadata: parsedData
|
|
12774
|
-
},
|
|
12775
|
-
{
|
|
12776
|
-
onSuccess: () => {
|
|
12777
|
-
ui.toast.success("Metadata updated");
|
|
12778
|
-
handleSuccess();
|
|
12779
|
-
},
|
|
12780
|
-
onError: (error) => {
|
|
12781
|
-
ui.toast.error(error.message);
|
|
12782
|
-
}
|
|
12783
|
-
}
|
|
12784
|
-
);
|
|
12785
|
-
});
|
|
12786
|
-
const { fields, insert, remove } = reactHookForm.useFieldArray({
|
|
12787
|
-
control: form.control,
|
|
12788
|
-
name: "metadata"
|
|
12789
|
-
});
|
|
12790
|
-
function deleteRow(index) {
|
|
12791
|
-
remove(index);
|
|
12792
|
-
if (fields.length === 1) {
|
|
12793
|
-
insert(0, {
|
|
12794
|
-
key: "",
|
|
12795
|
-
value: "",
|
|
12796
|
-
disabled: false
|
|
12797
|
-
});
|
|
12798
|
-
}
|
|
12799
|
-
}
|
|
12800
|
-
function insertRow(index, position) {
|
|
12801
|
-
insert(index + (position === "above" ? 0 : 1), {
|
|
12802
|
-
key: "",
|
|
12803
|
-
value: "",
|
|
12804
|
-
disabled: false
|
|
12805
|
-
});
|
|
12806
|
-
}
|
|
12807
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12808
|
-
KeyboundForm,
|
|
12809
|
-
{
|
|
12810
|
-
onSubmit: handleSubmit,
|
|
12811
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12812
|
-
children: [
|
|
12813
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: [
|
|
12814
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-1 divide-y rounded-lg", children: [
|
|
12815
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle grid grid-cols-2 divide-x rounded-t-lg", children: [
|
|
12816
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsxRuntime.jsx("label", { id: METADATA_KEY_LABEL_ID, children: "Key" }) }),
|
|
12817
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsxRuntime.jsx("label", { id: METADATA_VALUE_LABEL_ID, children: "Value" }) })
|
|
12818
|
-
] }),
|
|
12819
|
-
fields.map((field, index) => {
|
|
12820
|
-
const isDisabled = field.disabled || false;
|
|
12821
|
-
let placeholder = "-";
|
|
12822
|
-
if (typeof field.value === "object") {
|
|
12823
|
-
placeholder = "{ ... }";
|
|
12824
|
-
}
|
|
12825
|
-
if (Array.isArray(field.value)) {
|
|
12826
|
-
placeholder = "[ ... ]";
|
|
12827
|
-
}
|
|
12828
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12829
|
-
ConditionalTooltip,
|
|
12830
|
-
{
|
|
12831
|
-
showTooltip: isDisabled,
|
|
12832
|
-
content: "This row is disabled because it contains non-primitive data.",
|
|
12833
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "group/table relative", children: [
|
|
12834
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
12835
|
-
"div",
|
|
12836
|
-
{
|
|
12837
|
-
className: ui.clx("grid grid-cols-2 divide-x", {
|
|
12838
|
-
"overflow-hidden rounded-b-lg": index === fields.length - 1
|
|
12839
|
-
}),
|
|
12840
|
-
children: [
|
|
12841
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12842
|
-
Form$2.Field,
|
|
12843
|
-
{
|
|
12844
|
-
control: form.control,
|
|
12845
|
-
name: `metadata.${index}.key`,
|
|
12846
|
-
render: ({ field: field2 }) => {
|
|
12847
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12848
|
-
GridInput,
|
|
12849
|
-
{
|
|
12850
|
-
"aria-labelledby": METADATA_KEY_LABEL_ID,
|
|
12851
|
-
...field2,
|
|
12852
|
-
disabled: isDisabled,
|
|
12853
|
-
placeholder: "Key"
|
|
12854
|
-
}
|
|
12855
|
-
) }) });
|
|
12856
|
-
}
|
|
12857
|
-
}
|
|
12858
|
-
),
|
|
12859
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12860
|
-
Form$2.Field,
|
|
12861
|
-
{
|
|
12862
|
-
control: form.control,
|
|
12863
|
-
name: `metadata.${index}.value`,
|
|
12864
|
-
render: ({ field: { value, ...field2 } }) => {
|
|
12865
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12866
|
-
GridInput,
|
|
12867
|
-
{
|
|
12868
|
-
"aria-labelledby": METADATA_VALUE_LABEL_ID,
|
|
12869
|
-
...field2,
|
|
12870
|
-
value: isDisabled ? placeholder : value,
|
|
12871
|
-
disabled: isDisabled,
|
|
12872
|
-
placeholder: "Value"
|
|
12873
|
-
}
|
|
12874
|
-
) }) });
|
|
12875
|
-
}
|
|
12876
|
-
}
|
|
12877
|
-
)
|
|
12878
|
-
]
|
|
12879
|
-
}
|
|
12880
|
-
),
|
|
12881
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu, { children: [
|
|
12882
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12883
|
-
ui.DropdownMenu.Trigger,
|
|
12884
|
-
{
|
|
12885
|
-
className: ui.clx(
|
|
12886
|
-
"invisible absolute inset-y-0 -right-2.5 my-auto group-hover/table:visible data-[state='open']:visible",
|
|
12887
|
-
{
|
|
12888
|
-
hidden: isDisabled
|
|
12889
|
-
}
|
|
12890
|
-
),
|
|
12891
|
-
disabled: isDisabled,
|
|
12892
|
-
asChild: true,
|
|
12893
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { size: "2xsmall", children: /* @__PURE__ */ jsxRuntime.jsx(icons.EllipsisVertical, {}) })
|
|
12894
|
-
}
|
|
12895
|
-
),
|
|
12896
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu.Content, { children: [
|
|
12897
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
12898
|
-
ui.DropdownMenu.Item,
|
|
12899
|
-
{
|
|
12900
|
-
className: "gap-x-2",
|
|
12901
|
-
onClick: () => insertRow(index, "above"),
|
|
12902
|
-
children: [
|
|
12903
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowUpMini, { className: "text-ui-fg-subtle" }),
|
|
12904
|
-
"Insert row above"
|
|
12905
|
-
]
|
|
12906
|
-
}
|
|
12907
|
-
),
|
|
12908
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
12909
|
-
ui.DropdownMenu.Item,
|
|
12910
|
-
{
|
|
12911
|
-
className: "gap-x-2",
|
|
12912
|
-
onClick: () => insertRow(index, "below"),
|
|
12913
|
-
children: [
|
|
12914
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowDownMini, { className: "text-ui-fg-subtle" }),
|
|
12915
|
-
"Insert row below"
|
|
12916
|
-
]
|
|
12917
|
-
}
|
|
12918
|
-
),
|
|
12919
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenu.Separator, {}),
|
|
12920
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
12921
|
-
ui.DropdownMenu.Item,
|
|
12922
|
-
{
|
|
12923
|
-
className: "gap-x-2",
|
|
12924
|
-
onClick: () => deleteRow(index),
|
|
12925
|
-
children: [
|
|
12926
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.Trash, { className: "text-ui-fg-subtle" }),
|
|
12927
|
-
"Delete row"
|
|
12928
|
-
]
|
|
12929
|
-
}
|
|
12930
|
-
)
|
|
12931
|
-
] })
|
|
12932
|
-
] })
|
|
12933
|
-
] })
|
|
12934
|
-
},
|
|
12935
|
-
field.id
|
|
12936
|
-
);
|
|
12937
|
-
})
|
|
12938
|
-
] }),
|
|
12939
|
-
hasUneditableRows && /* @__PURE__ */ jsxRuntime.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." })
|
|
12940
|
-
] }),
|
|
12941
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
12942
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
12943
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12944
|
-
] }) })
|
|
12907
|
+
"rect",
|
|
12908
|
+
{
|
|
12909
|
+
width: "12",
|
|
12910
|
+
height: "3",
|
|
12911
|
+
rx: "1.5",
|
|
12912
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 105.4 62.5457)",
|
|
12913
|
+
fill: "#A1A1AA"
|
|
12914
|
+
}
|
|
12915
|
+
),
|
|
12916
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12917
|
+
"path",
|
|
12918
|
+
{
|
|
12919
|
+
d: "M104.562 57.0927C103.13 56.265 100.792 56.2515 99.3501 57.0626C97.9081 57.8738 97.9004 59.2065 99.333 60.0343C100.766 60.862 103.103 60.8754 104.545 60.0643C105.987 59.2532 105.995 57.9204 104.562 57.0927ZM103.858 58.8972L100.815 59.1265C100.683 59.1367 100.55 59.1134 100.449 59.063C100.44 59.0585 100.432 59.0545 100.425 59.05C100.339 59.0005 100.29 58.9336 100.291 58.8637L100.294 58.1201C100.294 57.9752 100.501 57.8585 100.756 57.86C101.01 57.8615 101.217 57.98 101.216 58.1256L101.214 58.5669L103.732 58.3769C103.984 58.3578 104.217 58.4584 104.251 58.603C104.286 58.7468 104.11 58.8788 103.858 58.8977L103.858 58.8972Z",
|
|
12920
|
+
fill: "#52525B"
|
|
12921
|
+
}
|
|
12922
|
+
),
|
|
12923
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip0_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12924
|
+
"path",
|
|
12925
|
+
{
|
|
12926
|
+
d: "M133.106 81.8022L140.49 81.8447L140.515 77.6349",
|
|
12927
|
+
stroke: "#A1A1AA",
|
|
12928
|
+
strokeWidth: "1.5",
|
|
12929
|
+
strokeLinecap: "round",
|
|
12930
|
+
strokeLinejoin: "round"
|
|
12931
|
+
}
|
|
12932
|
+
) }),
|
|
12933
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip1_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12934
|
+
"path",
|
|
12935
|
+
{
|
|
12936
|
+
d: "M143.496 87.8055L150.881 87.8481L150.905 83.6383",
|
|
12937
|
+
stroke: "#A1A1AA",
|
|
12938
|
+
strokeWidth: "1.5",
|
|
12939
|
+
strokeLinecap: "round",
|
|
12940
|
+
strokeLinejoin: "round"
|
|
12941
|
+
}
|
|
12942
|
+
) }),
|
|
12943
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip2_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12944
|
+
"path",
|
|
12945
|
+
{
|
|
12946
|
+
d: "M153.887 93.8088L161.271 93.8514L161.295 89.6416",
|
|
12947
|
+
stroke: "#A1A1AA",
|
|
12948
|
+
strokeWidth: "1.5",
|
|
12949
|
+
strokeLinecap: "round",
|
|
12950
|
+
strokeLinejoin: "round"
|
|
12951
|
+
}
|
|
12952
|
+
) }),
|
|
12953
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip3_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12954
|
+
"path",
|
|
12955
|
+
{
|
|
12956
|
+
d: "M126.114 89.1912L118.729 89.1486L118.705 93.3584",
|
|
12957
|
+
stroke: "#A1A1AA",
|
|
12958
|
+
strokeWidth: "1.5",
|
|
12959
|
+
strokeLinecap: "round",
|
|
12960
|
+
strokeLinejoin: "round"
|
|
12961
|
+
}
|
|
12962
|
+
) }),
|
|
12963
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip4_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12964
|
+
"path",
|
|
12965
|
+
{
|
|
12966
|
+
d: "M136.504 95.1945L129.12 95.1519L129.095 99.3617",
|
|
12967
|
+
stroke: "#A1A1AA",
|
|
12968
|
+
strokeWidth: "1.5",
|
|
12969
|
+
strokeLinecap: "round",
|
|
12970
|
+
strokeLinejoin: "round"
|
|
12971
|
+
}
|
|
12972
|
+
) }),
|
|
12973
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip5_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12974
|
+
"path",
|
|
12975
|
+
{
|
|
12976
|
+
d: "M146.894 101.198L139.51 101.155L139.486 105.365",
|
|
12977
|
+
stroke: "#A1A1AA",
|
|
12978
|
+
strokeWidth: "1.5",
|
|
12979
|
+
strokeLinecap: "round",
|
|
12980
|
+
strokeLinejoin: "round"
|
|
12981
|
+
}
|
|
12982
|
+
) }),
|
|
12983
|
+
/* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
|
|
12984
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12985
|
+
"rect",
|
|
12986
|
+
{
|
|
12987
|
+
width: "12",
|
|
12988
|
+
height: "12",
|
|
12989
|
+
fill: "white",
|
|
12990
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
|
|
12991
|
+
}
|
|
12992
|
+
) }),
|
|
12993
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12994
|
+
"rect",
|
|
12995
|
+
{
|
|
12996
|
+
width: "12",
|
|
12997
|
+
height: "12",
|
|
12998
|
+
fill: "white",
|
|
12999
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
|
|
13000
|
+
}
|
|
13001
|
+
) }),
|
|
13002
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13003
|
+
"rect",
|
|
13004
|
+
{
|
|
13005
|
+
width: "12",
|
|
13006
|
+
height: "12",
|
|
13007
|
+
fill: "white",
|
|
13008
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
|
|
13009
|
+
}
|
|
13010
|
+
) }),
|
|
13011
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13012
|
+
"rect",
|
|
13013
|
+
{
|
|
13014
|
+
width: "12",
|
|
13015
|
+
height: "12",
|
|
13016
|
+
fill: "white",
|
|
13017
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
|
|
13018
|
+
}
|
|
13019
|
+
) }),
|
|
13020
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13021
|
+
"rect",
|
|
13022
|
+
{
|
|
13023
|
+
width: "12",
|
|
13024
|
+
height: "12",
|
|
13025
|
+
fill: "white",
|
|
13026
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
|
|
13027
|
+
}
|
|
13028
|
+
) }),
|
|
13029
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13030
|
+
"rect",
|
|
13031
|
+
{
|
|
13032
|
+
width: "12",
|
|
13033
|
+
height: "12",
|
|
13034
|
+
fill: "white",
|
|
13035
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
|
|
13036
|
+
}
|
|
13037
|
+
) })
|
|
13038
|
+
] })
|
|
12945
13039
|
]
|
|
12946
13040
|
}
|
|
12947
|
-
) });
|
|
12948
|
-
};
|
|
12949
|
-
const GridInput = React.forwardRef(({ className, ...props }, ref) => {
|
|
12950
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12951
|
-
"input",
|
|
12952
|
-
{
|
|
12953
|
-
ref,
|
|
12954
|
-
...props,
|
|
12955
|
-
autoComplete: "off",
|
|
12956
|
-
className: ui.clx(
|
|
12957
|
-
"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",
|
|
12958
|
-
className
|
|
12959
|
-
)
|
|
12960
|
-
}
|
|
12961
13041
|
);
|
|
12962
|
-
});
|
|
12963
|
-
GridInput.displayName = "MetadataForm.GridInput";
|
|
12964
|
-
const PlaceholderInner = () => {
|
|
12965
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
12966
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-[148ox] w-full rounded-lg" }) }),
|
|
12967
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
12968
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" }),
|
|
12969
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" })
|
|
12970
|
-
] }) })
|
|
12971
|
-
] });
|
|
12972
13042
|
};
|
|
12973
|
-
const
|
|
12974
|
-
|
|
12975
|
-
|
|
12976
|
-
return [
|
|
12977
|
-
{
|
|
12978
|
-
key: "",
|
|
12979
|
-
value: "",
|
|
12980
|
-
disabled: false
|
|
12981
|
-
}
|
|
12982
|
-
];
|
|
12983
|
-
}
|
|
12984
|
-
return Object.entries(metadata).map(([key, value]) => {
|
|
12985
|
-
if (!EDITABLE_TYPES.includes(typeof value)) {
|
|
12986
|
-
return {
|
|
12987
|
-
key,
|
|
12988
|
-
value,
|
|
12989
|
-
disabled: true
|
|
12990
|
-
};
|
|
12991
|
-
}
|
|
12992
|
-
let stringValue = value;
|
|
12993
|
-
if (typeof value !== "string") {
|
|
12994
|
-
stringValue = JSON.stringify(value);
|
|
12995
|
-
}
|
|
12996
|
-
return {
|
|
12997
|
-
key,
|
|
12998
|
-
value: stringValue,
|
|
12999
|
-
original_key: key
|
|
13000
|
-
};
|
|
13001
|
-
});
|
|
13002
|
-
}
|
|
13003
|
-
function parseValues(values) {
|
|
13004
|
-
const metadata = values.metadata;
|
|
13005
|
-
const isEmpty = !metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value;
|
|
13006
|
-
if (isEmpty) {
|
|
13007
|
-
return null;
|
|
13008
|
-
}
|
|
13009
|
-
const update = {};
|
|
13010
|
-
metadata.forEach((field) => {
|
|
13011
|
-
let key = field.key;
|
|
13012
|
-
let value = field.value;
|
|
13013
|
-
const disabled = field.disabled;
|
|
13014
|
-
if (!key || !value) {
|
|
13015
|
-
return;
|
|
13016
|
-
}
|
|
13017
|
-
if (disabled) {
|
|
13018
|
-
update[key] = value;
|
|
13019
|
-
return;
|
|
13020
|
-
}
|
|
13021
|
-
key = key.trim();
|
|
13022
|
-
value = value.trim();
|
|
13023
|
-
if (value === "true") {
|
|
13024
|
-
update[key] = true;
|
|
13025
|
-
} else if (value === "false") {
|
|
13026
|
-
update[key] = false;
|
|
13027
|
-
} else {
|
|
13028
|
-
const parsedNumber = parseFloat(value);
|
|
13029
|
-
if (!isNaN(parsedNumber)) {
|
|
13030
|
-
update[key] = parsedNumber;
|
|
13031
|
-
} else {
|
|
13032
|
-
update[key] = value;
|
|
13033
|
-
}
|
|
13034
|
-
}
|
|
13035
|
-
});
|
|
13036
|
-
return update;
|
|
13037
|
-
}
|
|
13038
|
-
function getHasUneditableRows(metadata) {
|
|
13039
|
-
if (!metadata) {
|
|
13040
|
-
return false;
|
|
13041
|
-
}
|
|
13042
|
-
return Object.values(metadata).some(
|
|
13043
|
-
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
13044
|
-
);
|
|
13045
|
-
}
|
|
13043
|
+
const schema = objectType({
|
|
13044
|
+
customer_id: stringType().min(1)
|
|
13045
|
+
});
|
|
13046
13046
|
const widgetModule = { widgets: [] };
|
|
13047
13047
|
const routeModule = {
|
|
13048
13048
|
routes: [
|
|
@@ -13063,30 +13063,34 @@ const routeModule = {
|
|
|
13063
13063
|
handle,
|
|
13064
13064
|
loader,
|
|
13065
13065
|
children: [
|
|
13066
|
-
{
|
|
13067
|
-
Component: CustomItems,
|
|
13068
|
-
path: "/draft-orders/:id/custom-items"
|
|
13069
|
-
},
|
|
13070
13066
|
{
|
|
13071
13067
|
Component: BillingAddress,
|
|
13072
13068
|
path: "/draft-orders/:id/billing-address"
|
|
13073
13069
|
},
|
|
13074
13070
|
{
|
|
13075
|
-
Component:
|
|
13076
|
-
path: "/draft-orders/:id/items"
|
|
13071
|
+
Component: CustomItems,
|
|
13072
|
+
path: "/draft-orders/:id/custom-items"
|
|
13077
13073
|
},
|
|
13078
13074
|
{
|
|
13079
13075
|
Component: Email,
|
|
13080
13076
|
path: "/draft-orders/:id/email"
|
|
13081
13077
|
},
|
|
13082
13078
|
{
|
|
13083
|
-
Component:
|
|
13084
|
-
path: "/draft-orders/:id/
|
|
13079
|
+
Component: Items,
|
|
13080
|
+
path: "/draft-orders/:id/items"
|
|
13081
|
+
},
|
|
13082
|
+
{
|
|
13083
|
+
Component: Metadata,
|
|
13084
|
+
path: "/draft-orders/:id/metadata"
|
|
13085
13085
|
},
|
|
13086
13086
|
{
|
|
13087
13087
|
Component: Promotions,
|
|
13088
13088
|
path: "/draft-orders/:id/promotions"
|
|
13089
13089
|
},
|
|
13090
|
+
{
|
|
13091
|
+
Component: SalesChannel,
|
|
13092
|
+
path: "/draft-orders/:id/sales-channel"
|
|
13093
|
+
},
|
|
13090
13094
|
{
|
|
13091
13095
|
Component: Shipping,
|
|
13092
13096
|
path: "/draft-orders/:id/shipping"
|
|
@@ -13098,10 +13102,6 @@ const routeModule = {
|
|
|
13098
13102
|
{
|
|
13099
13103
|
Component: TransferOwnership,
|
|
13100
13104
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13101
|
-
},
|
|
13102
|
-
{
|
|
13103
|
-
Component: Metadata,
|
|
13104
|
-
path: "/draft-orders/:id/metadata"
|
|
13105
13105
|
}
|
|
13106
13106
|
]
|
|
13107
13107
|
}
|