@medusajs/draft-order 2.11.0-snapshot-20251016121452 → 2.11.0-snapshot-20251017111015
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 +742 -742
- package/.medusa/server/src/admin/index.mjs +742 -742
- package/package.json +16 -16
|
@@ -9573,6 +9573,27 @@ const ID = () => {
|
|
|
9573
9573
|
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
9574
9574
|
] });
|
|
9575
9575
|
};
|
|
9576
|
+
const CustomItems = () => {
|
|
9577
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9578
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
9579
|
+
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
9580
|
+
] });
|
|
9581
|
+
};
|
|
9582
|
+
const CustomItemsForm = () => {
|
|
9583
|
+
const form = reactHookForm.useForm({
|
|
9584
|
+
resolver: zod.zodResolver(schema$5)
|
|
9585
|
+
});
|
|
9586
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9587
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
9588
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9589
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9590
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
9591
|
+
] }) })
|
|
9592
|
+
] }) });
|
|
9593
|
+
};
|
|
9594
|
+
const schema$5 = objectType({
|
|
9595
|
+
email: stringType().email()
|
|
9596
|
+
});
|
|
9576
9597
|
const BillingAddress = () => {
|
|
9577
9598
|
const { id } = reactRouterDom.useParams();
|
|
9578
9599
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -9605,7 +9626,7 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9605
9626
|
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9606
9627
|
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9607
9628
|
},
|
|
9608
|
-
resolver: zod.zodResolver(schema$
|
|
9629
|
+
resolver: zod.zodResolver(schema$4)
|
|
9609
9630
|
});
|
|
9610
9631
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9611
9632
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9762,26 +9783,73 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9762
9783
|
}
|
|
9763
9784
|
) });
|
|
9764
9785
|
};
|
|
9765
|
-
const schema$
|
|
9766
|
-
const
|
|
9786
|
+
const schema$4 = addressSchema;
|
|
9787
|
+
const Email = () => {
|
|
9788
|
+
const { id } = reactRouterDom.useParams();
|
|
9789
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
9790
|
+
fields: "+email"
|
|
9791
|
+
});
|
|
9792
|
+
if (isError) {
|
|
9793
|
+
throw error;
|
|
9794
|
+
}
|
|
9795
|
+
const isReady = !isPending && !!order;
|
|
9767
9796
|
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9768
|
-
/* @__PURE__ */ jsxRuntime.
|
|
9769
|
-
|
|
9797
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
9798
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
|
|
9799
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
9800
|
+
] }),
|
|
9801
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
|
|
9770
9802
|
] });
|
|
9771
9803
|
};
|
|
9772
|
-
const
|
|
9804
|
+
const EmailForm = ({ order }) => {
|
|
9773
9805
|
const form = reactHookForm.useForm({
|
|
9774
|
-
|
|
9806
|
+
defaultValues: {
|
|
9807
|
+
email: order.email ?? ""
|
|
9808
|
+
},
|
|
9809
|
+
resolver: zod.zodResolver(schema$3)
|
|
9775
9810
|
});
|
|
9776
|
-
|
|
9777
|
-
|
|
9778
|
-
|
|
9779
|
-
|
|
9780
|
-
|
|
9781
|
-
|
|
9782
|
-
|
|
9811
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9812
|
+
const { handleSuccess } = useRouteModal();
|
|
9813
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
9814
|
+
await mutateAsync(
|
|
9815
|
+
{ email: data.email },
|
|
9816
|
+
{
|
|
9817
|
+
onSuccess: () => {
|
|
9818
|
+
handleSuccess();
|
|
9819
|
+
},
|
|
9820
|
+
onError: (error) => {
|
|
9821
|
+
ui.toast.error(error.message);
|
|
9822
|
+
}
|
|
9823
|
+
}
|
|
9824
|
+
);
|
|
9825
|
+
});
|
|
9826
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9827
|
+
KeyboundForm,
|
|
9828
|
+
{
|
|
9829
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
9830
|
+
onSubmit,
|
|
9831
|
+
children: [
|
|
9832
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9833
|
+
Form$2.Field,
|
|
9834
|
+
{
|
|
9835
|
+
control: form.control,
|
|
9836
|
+
name: "email",
|
|
9837
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
9838
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
|
|
9839
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
9840
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
9841
|
+
] })
|
|
9842
|
+
}
|
|
9843
|
+
) }),
|
|
9844
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9845
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9846
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9847
|
+
] }) })
|
|
9848
|
+
]
|
|
9849
|
+
}
|
|
9850
|
+
) });
|
|
9783
9851
|
};
|
|
9784
|
-
const schema$
|
|
9852
|
+
const schema$3 = objectType({
|
|
9785
9853
|
email: stringType().email()
|
|
9786
9854
|
});
|
|
9787
9855
|
const NumberInput = React.forwardRef(
|
|
@@ -10758,188 +10826,538 @@ const customItemSchema = objectType({
|
|
|
10758
10826
|
quantity: numberType(),
|
|
10759
10827
|
unit_price: unionType([numberType(), stringType()])
|
|
10760
10828
|
});
|
|
10761
|
-
const
|
|
10762
|
-
|
|
10763
|
-
|
|
10764
|
-
|
|
10765
|
-
|
|
10766
|
-
|
|
10767
|
-
|
|
10768
|
-
|
|
10769
|
-
|
|
10770
|
-
|
|
10771
|
-
|
|
10772
|
-
|
|
10773
|
-
|
|
10774
|
-
|
|
10775
|
-
|
|
10776
|
-
|
|
10777
|
-
|
|
10778
|
-
|
|
10779
|
-
|
|
10780
|
-
}
|
|
10781
|
-
|
|
10829
|
+
const InlineTip = React.forwardRef(
|
|
10830
|
+
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
10831
|
+
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
10832
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10833
|
+
"div",
|
|
10834
|
+
{
|
|
10835
|
+
ref,
|
|
10836
|
+
className: ui.clx(
|
|
10837
|
+
"bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
|
|
10838
|
+
className
|
|
10839
|
+
),
|
|
10840
|
+
...props,
|
|
10841
|
+
children: [
|
|
10842
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10843
|
+
"div",
|
|
10844
|
+
{
|
|
10845
|
+
role: "presentation",
|
|
10846
|
+
className: ui.clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
|
|
10847
|
+
"bg-ui-tag-orange-icon": variant === "warning"
|
|
10848
|
+
})
|
|
10849
|
+
}
|
|
10850
|
+
),
|
|
10851
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-pretty", children: [
|
|
10852
|
+
/* @__PURE__ */ jsxRuntime.jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
|
|
10853
|
+
labelValue,
|
|
10854
|
+
":"
|
|
10855
|
+
] }),
|
|
10856
|
+
" ",
|
|
10857
|
+
children
|
|
10858
|
+
] })
|
|
10859
|
+
]
|
|
10860
|
+
}
|
|
10861
|
+
);
|
|
10862
|
+
}
|
|
10863
|
+
);
|
|
10864
|
+
InlineTip.displayName = "InlineTip";
|
|
10865
|
+
const MetadataFieldSchema = objectType({
|
|
10866
|
+
key: stringType(),
|
|
10867
|
+
disabled: booleanType().optional(),
|
|
10868
|
+
value: anyType()
|
|
10869
|
+
});
|
|
10870
|
+
const MetadataSchema = objectType({
|
|
10871
|
+
metadata: arrayType(MetadataFieldSchema)
|
|
10872
|
+
});
|
|
10873
|
+
const Metadata = () => {
|
|
10782
10874
|
const { id } = reactRouterDom.useParams();
|
|
10783
|
-
const {
|
|
10784
|
-
|
|
10785
|
-
|
|
10786
|
-
|
|
10787
|
-
|
|
10788
|
-
useInitiateOrderEdit({ preview });
|
|
10789
|
-
const { onCancel } = useCancelOrderEdit({ preview });
|
|
10790
|
-
if (isPreviewError) {
|
|
10791
|
-
throw previewError;
|
|
10875
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
10876
|
+
fields: "metadata"
|
|
10877
|
+
});
|
|
10878
|
+
if (isError) {
|
|
10879
|
+
throw error;
|
|
10792
10880
|
}
|
|
10793
|
-
const isReady = !!
|
|
10794
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, {
|
|
10795
|
-
/* @__PURE__ */ jsxRuntime.
|
|
10796
|
-
|
|
10881
|
+
const isReady = !isPending && !!order;
|
|
10882
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
10883
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
10884
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Metadata" }) }),
|
|
10885
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
|
|
10886
|
+
] }),
|
|
10887
|
+
!isReady ? /* @__PURE__ */ jsxRuntime.jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsxRuntime.jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
|
|
10797
10888
|
] });
|
|
10798
10889
|
};
|
|
10799
|
-
const
|
|
10800
|
-
|
|
10801
|
-
|
|
10802
|
-
const [comboboxValue, setComboboxValue] = React.useState("");
|
|
10890
|
+
const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
|
|
10891
|
+
const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
|
|
10892
|
+
const MetadataForm = ({ orderId, metadata }) => {
|
|
10803
10893
|
const { handleSuccess } = useRouteModal();
|
|
10804
|
-
const
|
|
10805
|
-
const
|
|
10806
|
-
const
|
|
10807
|
-
{
|
|
10808
|
-
|
|
10809
|
-
},
|
|
10810
|
-
{
|
|
10811
|
-
enabled: !!promoIds.length
|
|
10812
|
-
}
|
|
10813
|
-
);
|
|
10814
|
-
const comboboxData = useComboboxData({
|
|
10815
|
-
queryKey: ["promotions", "combobox", promoIds],
|
|
10816
|
-
queryFn: async (params) => {
|
|
10817
|
-
return await sdk.admin.promotion.list({
|
|
10818
|
-
...params,
|
|
10819
|
-
id: {
|
|
10820
|
-
$nin: promoIds
|
|
10821
|
-
}
|
|
10822
|
-
});
|
|
10894
|
+
const hasUneditableRows = getHasUneditableRows(metadata);
|
|
10895
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
|
|
10896
|
+
const form = reactHookForm.useForm({
|
|
10897
|
+
defaultValues: {
|
|
10898
|
+
metadata: getDefaultValues(metadata)
|
|
10823
10899
|
},
|
|
10824
|
-
|
|
10825
|
-
return data.promotions.map((promotion) => ({
|
|
10826
|
-
label: promotion.code,
|
|
10827
|
-
value: promotion.code
|
|
10828
|
-
}));
|
|
10829
|
-
}
|
|
10900
|
+
resolver: zod.zodResolver(MetadataSchema)
|
|
10830
10901
|
});
|
|
10831
|
-
const
|
|
10832
|
-
|
|
10833
|
-
|
|
10834
|
-
}
|
|
10835
|
-
addPromotions(
|
|
10902
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
10903
|
+
const parsedData = parseValues(data);
|
|
10904
|
+
await mutateAsync(
|
|
10836
10905
|
{
|
|
10837
|
-
|
|
10906
|
+
metadata: parsedData
|
|
10838
10907
|
},
|
|
10839
10908
|
{
|
|
10840
|
-
onError: (e) => {
|
|
10841
|
-
ui.toast.error(e.message);
|
|
10842
|
-
comboboxData.onSearchValueChange("");
|
|
10843
|
-
setComboboxValue("");
|
|
10844
|
-
},
|
|
10845
10909
|
onSuccess: () => {
|
|
10846
|
-
|
|
10847
|
-
|
|
10910
|
+
ui.toast.success("Metadata updated");
|
|
10911
|
+
handleSuccess();
|
|
10912
|
+
},
|
|
10913
|
+
onError: (error) => {
|
|
10914
|
+
ui.toast.error(error.message);
|
|
10848
10915
|
}
|
|
10849
10916
|
}
|
|
10850
10917
|
);
|
|
10851
|
-
};
|
|
10852
|
-
const {
|
|
10853
|
-
|
|
10854
|
-
|
|
10855
|
-
|
|
10856
|
-
|
|
10857
|
-
|
|
10858
|
-
|
|
10859
|
-
|
|
10860
|
-
|
|
10861
|
-
|
|
10862
|
-
|
|
10863
|
-
}
|
|
10864
|
-
});
|
|
10865
|
-
if (!requestSucceeded) {
|
|
10866
|
-
setIsSubmitting(false);
|
|
10867
|
-
return;
|
|
10918
|
+
});
|
|
10919
|
+
const { fields, insert, remove } = reactHookForm.useFieldArray({
|
|
10920
|
+
control: form.control,
|
|
10921
|
+
name: "metadata"
|
|
10922
|
+
});
|
|
10923
|
+
function deleteRow(index) {
|
|
10924
|
+
remove(index);
|
|
10925
|
+
if (fields.length === 1) {
|
|
10926
|
+
insert(0, {
|
|
10927
|
+
key: "",
|
|
10928
|
+
value: "",
|
|
10929
|
+
disabled: false
|
|
10930
|
+
});
|
|
10868
10931
|
}
|
|
10869
|
-
|
|
10870
|
-
|
|
10871
|
-
|
|
10872
|
-
|
|
10873
|
-
|
|
10874
|
-
|
|
10875
|
-
},
|
|
10876
|
-
onSettled: () => {
|
|
10877
|
-
setIsSubmitting(false);
|
|
10878
|
-
}
|
|
10932
|
+
}
|
|
10933
|
+
function insertRow(index, position) {
|
|
10934
|
+
insert(index + (position === "above" ? 0 : 1), {
|
|
10935
|
+
key: "",
|
|
10936
|
+
value: "",
|
|
10937
|
+
disabled: false
|
|
10879
10938
|
});
|
|
10880
|
-
};
|
|
10881
|
-
if (isError) {
|
|
10882
|
-
throw error;
|
|
10883
10939
|
}
|
|
10884
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
10885
|
-
|
|
10886
|
-
|
|
10887
|
-
|
|
10888
|
-
|
|
10889
|
-
|
|
10940
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10941
|
+
KeyboundForm,
|
|
10942
|
+
{
|
|
10943
|
+
onSubmit: handleSubmit,
|
|
10944
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
10945
|
+
children: [
|
|
10946
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: [
|
|
10947
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-1 divide-y rounded-lg", children: [
|
|
10948
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle grid grid-cols-2 divide-x rounded-t-lg", children: [
|
|
10949
|
+
/* @__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" }) }),
|
|
10950
|
+
/* @__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" }) })
|
|
10951
|
+
] }),
|
|
10952
|
+
fields.map((field, index) => {
|
|
10953
|
+
const isDisabled = field.disabled || false;
|
|
10954
|
+
let placeholder = "-";
|
|
10955
|
+
if (typeof field.value === "object") {
|
|
10956
|
+
placeholder = "{ ... }";
|
|
10957
|
+
}
|
|
10958
|
+
if (Array.isArray(field.value)) {
|
|
10959
|
+
placeholder = "[ ... ]";
|
|
10960
|
+
}
|
|
10961
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10962
|
+
ConditionalTooltip,
|
|
10963
|
+
{
|
|
10964
|
+
showTooltip: isDisabled,
|
|
10965
|
+
content: "This row is disabled because it contains non-primitive data.",
|
|
10966
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "group/table relative", children: [
|
|
10967
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10968
|
+
"div",
|
|
10969
|
+
{
|
|
10970
|
+
className: ui.clx("grid grid-cols-2 divide-x", {
|
|
10971
|
+
"overflow-hidden rounded-b-lg": index === fields.length - 1
|
|
10972
|
+
}),
|
|
10973
|
+
children: [
|
|
10974
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10975
|
+
Form$2.Field,
|
|
10976
|
+
{
|
|
10977
|
+
control: form.control,
|
|
10978
|
+
name: `metadata.${index}.key`,
|
|
10979
|
+
render: ({ field: field2 }) => {
|
|
10980
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10981
|
+
GridInput,
|
|
10982
|
+
{
|
|
10983
|
+
"aria-labelledby": METADATA_KEY_LABEL_ID,
|
|
10984
|
+
...field2,
|
|
10985
|
+
disabled: isDisabled,
|
|
10986
|
+
placeholder: "Key"
|
|
10987
|
+
}
|
|
10988
|
+
) }) });
|
|
10989
|
+
}
|
|
10990
|
+
}
|
|
10991
|
+
),
|
|
10992
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10993
|
+
Form$2.Field,
|
|
10994
|
+
{
|
|
10995
|
+
control: form.control,
|
|
10996
|
+
name: `metadata.${index}.value`,
|
|
10997
|
+
render: ({ field: { value, ...field2 } }) => {
|
|
10998
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10999
|
+
GridInput,
|
|
11000
|
+
{
|
|
11001
|
+
"aria-labelledby": METADATA_VALUE_LABEL_ID,
|
|
11002
|
+
...field2,
|
|
11003
|
+
value: isDisabled ? placeholder : value,
|
|
11004
|
+
disabled: isDisabled,
|
|
11005
|
+
placeholder: "Value"
|
|
11006
|
+
}
|
|
11007
|
+
) }) });
|
|
11008
|
+
}
|
|
11009
|
+
}
|
|
11010
|
+
)
|
|
11011
|
+
]
|
|
11012
|
+
}
|
|
11013
|
+
),
|
|
11014
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu, { children: [
|
|
11015
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11016
|
+
ui.DropdownMenu.Trigger,
|
|
11017
|
+
{
|
|
11018
|
+
className: ui.clx(
|
|
11019
|
+
"invisible absolute inset-y-0 -right-2.5 my-auto group-hover/table:visible data-[state='open']:visible",
|
|
11020
|
+
{
|
|
11021
|
+
hidden: isDisabled
|
|
11022
|
+
}
|
|
11023
|
+
),
|
|
11024
|
+
disabled: isDisabled,
|
|
11025
|
+
asChild: true,
|
|
11026
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { size: "2xsmall", children: /* @__PURE__ */ jsxRuntime.jsx(icons.EllipsisVertical, {}) })
|
|
11027
|
+
}
|
|
11028
|
+
),
|
|
11029
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu.Content, { children: [
|
|
11030
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
11031
|
+
ui.DropdownMenu.Item,
|
|
11032
|
+
{
|
|
11033
|
+
className: "gap-x-2",
|
|
11034
|
+
onClick: () => insertRow(index, "above"),
|
|
11035
|
+
children: [
|
|
11036
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowUpMini, { className: "text-ui-fg-subtle" }),
|
|
11037
|
+
"Insert row above"
|
|
11038
|
+
]
|
|
11039
|
+
}
|
|
11040
|
+
),
|
|
11041
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
11042
|
+
ui.DropdownMenu.Item,
|
|
11043
|
+
{
|
|
11044
|
+
className: "gap-x-2",
|
|
11045
|
+
onClick: () => insertRow(index, "below"),
|
|
11046
|
+
children: [
|
|
11047
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowDownMini, { className: "text-ui-fg-subtle" }),
|
|
11048
|
+
"Insert row below"
|
|
11049
|
+
]
|
|
11050
|
+
}
|
|
11051
|
+
),
|
|
11052
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenu.Separator, {}),
|
|
11053
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
11054
|
+
ui.DropdownMenu.Item,
|
|
11055
|
+
{
|
|
11056
|
+
className: "gap-x-2",
|
|
11057
|
+
onClick: () => deleteRow(index),
|
|
11058
|
+
children: [
|
|
11059
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.Trash, { className: "text-ui-fg-subtle" }),
|
|
11060
|
+
"Delete row"
|
|
11061
|
+
]
|
|
11062
|
+
}
|
|
11063
|
+
)
|
|
11064
|
+
] })
|
|
11065
|
+
] })
|
|
11066
|
+
] })
|
|
11067
|
+
},
|
|
11068
|
+
field.id
|
|
11069
|
+
);
|
|
11070
|
+
})
|
|
11071
|
+
] }),
|
|
11072
|
+
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." })
|
|
10890
11073
|
] }),
|
|
10891
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10892
|
-
|
|
10893
|
-
{
|
|
10894
|
-
|
|
10895
|
-
|
|
10896
|
-
|
|
10897
|
-
|
|
10898
|
-
|
|
10899
|
-
|
|
10900
|
-
|
|
10901
|
-
|
|
10902
|
-
|
|
10903
|
-
|
|
10904
|
-
|
|
10905
|
-
|
|
10906
|
-
|
|
10907
|
-
|
|
10908
|
-
|
|
10909
|
-
PromotionItem,
|
|
10910
|
-
{
|
|
10911
|
-
promotion,
|
|
10912
|
-
orderId: preview.id,
|
|
10913
|
-
isLoading: isPending
|
|
10914
|
-
},
|
|
10915
|
-
promotion.id
|
|
10916
|
-
)) })
|
|
10917
|
-
] }) }),
|
|
10918
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
10919
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
10920
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10921
|
-
ui.Button,
|
|
10922
|
-
{
|
|
10923
|
-
size: "small",
|
|
10924
|
-
type: "submit",
|
|
10925
|
-
isLoading: isSubmitting || isAddingPromotions,
|
|
10926
|
-
children: "Save"
|
|
10927
|
-
}
|
|
11074
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
11075
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
11076
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11077
|
+
] }) })
|
|
11078
|
+
]
|
|
11079
|
+
}
|
|
11080
|
+
) });
|
|
11081
|
+
};
|
|
11082
|
+
const GridInput = React.forwardRef(({ className, ...props }, ref) => {
|
|
11083
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11084
|
+
"input",
|
|
11085
|
+
{
|
|
11086
|
+
ref,
|
|
11087
|
+
...props,
|
|
11088
|
+
autoComplete: "off",
|
|
11089
|
+
className: ui.clx(
|
|
11090
|
+
"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",
|
|
11091
|
+
className
|
|
10928
11092
|
)
|
|
11093
|
+
}
|
|
11094
|
+
);
|
|
11095
|
+
});
|
|
11096
|
+
GridInput.displayName = "MetadataForm.GridInput";
|
|
11097
|
+
const PlaceholderInner = () => {
|
|
11098
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
11099
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-[148ox] w-full rounded-lg" }) }),
|
|
11100
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
11101
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" }),
|
|
11102
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" })
|
|
10929
11103
|
] }) })
|
|
10930
11104
|
] });
|
|
10931
11105
|
};
|
|
10932
|
-
const
|
|
10933
|
-
|
|
10934
|
-
|
|
10935
|
-
|
|
10936
|
-
}) => {
|
|
10937
|
-
var _a;
|
|
10938
|
-
const { mutateAsync: removePromotions, isPending } = useDraftOrderRemovePromotions(orderId);
|
|
10939
|
-
const onRemove = async () => {
|
|
10940
|
-
removePromotions(
|
|
11106
|
+
const EDITABLE_TYPES = ["string", "number", "boolean"];
|
|
11107
|
+
function getDefaultValues(metadata) {
|
|
11108
|
+
if (!metadata || !Object.keys(metadata).length) {
|
|
11109
|
+
return [
|
|
10941
11110
|
{
|
|
10942
|
-
|
|
11111
|
+
key: "",
|
|
11112
|
+
value: "",
|
|
11113
|
+
disabled: false
|
|
11114
|
+
}
|
|
11115
|
+
];
|
|
11116
|
+
}
|
|
11117
|
+
return Object.entries(metadata).map(([key, value]) => {
|
|
11118
|
+
if (!EDITABLE_TYPES.includes(typeof value)) {
|
|
11119
|
+
return {
|
|
11120
|
+
key,
|
|
11121
|
+
value,
|
|
11122
|
+
disabled: true
|
|
11123
|
+
};
|
|
11124
|
+
}
|
|
11125
|
+
let stringValue = value;
|
|
11126
|
+
if (typeof value !== "string") {
|
|
11127
|
+
stringValue = JSON.stringify(value);
|
|
11128
|
+
}
|
|
11129
|
+
return {
|
|
11130
|
+
key,
|
|
11131
|
+
value: stringValue,
|
|
11132
|
+
original_key: key
|
|
11133
|
+
};
|
|
11134
|
+
});
|
|
11135
|
+
}
|
|
11136
|
+
function parseValues(values) {
|
|
11137
|
+
const metadata = values.metadata;
|
|
11138
|
+
const isEmpty = !metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value;
|
|
11139
|
+
if (isEmpty) {
|
|
11140
|
+
return null;
|
|
11141
|
+
}
|
|
11142
|
+
const update = {};
|
|
11143
|
+
metadata.forEach((field) => {
|
|
11144
|
+
let key = field.key;
|
|
11145
|
+
let value = field.value;
|
|
11146
|
+
const disabled = field.disabled;
|
|
11147
|
+
if (!key || !value) {
|
|
11148
|
+
return;
|
|
11149
|
+
}
|
|
11150
|
+
if (disabled) {
|
|
11151
|
+
update[key] = value;
|
|
11152
|
+
return;
|
|
11153
|
+
}
|
|
11154
|
+
key = key.trim();
|
|
11155
|
+
value = value.trim();
|
|
11156
|
+
if (value === "true") {
|
|
11157
|
+
update[key] = true;
|
|
11158
|
+
} else if (value === "false") {
|
|
11159
|
+
update[key] = false;
|
|
11160
|
+
} else {
|
|
11161
|
+
const parsedNumber = parseFloat(value);
|
|
11162
|
+
if (!isNaN(parsedNumber)) {
|
|
11163
|
+
update[key] = parsedNumber;
|
|
11164
|
+
} else {
|
|
11165
|
+
update[key] = value;
|
|
11166
|
+
}
|
|
11167
|
+
}
|
|
11168
|
+
});
|
|
11169
|
+
return update;
|
|
11170
|
+
}
|
|
11171
|
+
function getHasUneditableRows(metadata) {
|
|
11172
|
+
if (!metadata) {
|
|
11173
|
+
return false;
|
|
11174
|
+
}
|
|
11175
|
+
return Object.values(metadata).some(
|
|
11176
|
+
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
11177
|
+
);
|
|
11178
|
+
}
|
|
11179
|
+
const PROMOTION_QUERY_KEY = "promotions";
|
|
11180
|
+
const promotionsQueryKeys = {
|
|
11181
|
+
list: (query2) => [
|
|
11182
|
+
PROMOTION_QUERY_KEY,
|
|
11183
|
+
query2 ? query2 : void 0
|
|
11184
|
+
],
|
|
11185
|
+
detail: (id, query2) => [
|
|
11186
|
+
PROMOTION_QUERY_KEY,
|
|
11187
|
+
id,
|
|
11188
|
+
query2 ? query2 : void 0
|
|
11189
|
+
]
|
|
11190
|
+
};
|
|
11191
|
+
const usePromotions = (query2, options) => {
|
|
11192
|
+
const { data, ...rest } = reactQuery.useQuery({
|
|
11193
|
+
queryKey: promotionsQueryKeys.list(query2),
|
|
11194
|
+
queryFn: async () => sdk.admin.promotion.list(query2),
|
|
11195
|
+
...options
|
|
11196
|
+
});
|
|
11197
|
+
return { ...data, ...rest };
|
|
11198
|
+
};
|
|
11199
|
+
const Promotions = () => {
|
|
11200
|
+
const { id } = reactRouterDom.useParams();
|
|
11201
|
+
const {
|
|
11202
|
+
order: preview,
|
|
11203
|
+
isError: isPreviewError,
|
|
11204
|
+
error: previewError
|
|
11205
|
+
} = useOrderPreview(id, void 0);
|
|
11206
|
+
useInitiateOrderEdit({ preview });
|
|
11207
|
+
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11208
|
+
if (isPreviewError) {
|
|
11209
|
+
throw previewError;
|
|
11210
|
+
}
|
|
11211
|
+
const isReady = !!preview;
|
|
11212
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { onClose: onCancel, children: [
|
|
11213
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Promotions" }) }) }),
|
|
11214
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(PromotionForm, { preview })
|
|
11215
|
+
] });
|
|
11216
|
+
};
|
|
11217
|
+
const PromotionForm = ({ preview }) => {
|
|
11218
|
+
const { items, shipping_methods } = preview;
|
|
11219
|
+
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
11220
|
+
const [comboboxValue, setComboboxValue] = React.useState("");
|
|
11221
|
+
const { handleSuccess } = useRouteModal();
|
|
11222
|
+
const { mutateAsync: addPromotions, isPending: isAddingPromotions } = useDraftOrderAddPromotions(preview.id);
|
|
11223
|
+
const promoIds = getPromotionIds(items, shipping_methods);
|
|
11224
|
+
const { promotions, isPending, isError, error } = usePromotions(
|
|
11225
|
+
{
|
|
11226
|
+
id: promoIds
|
|
11227
|
+
},
|
|
11228
|
+
{
|
|
11229
|
+
enabled: !!promoIds.length
|
|
11230
|
+
}
|
|
11231
|
+
);
|
|
11232
|
+
const comboboxData = useComboboxData({
|
|
11233
|
+
queryKey: ["promotions", "combobox", promoIds],
|
|
11234
|
+
queryFn: async (params) => {
|
|
11235
|
+
return await sdk.admin.promotion.list({
|
|
11236
|
+
...params,
|
|
11237
|
+
id: {
|
|
11238
|
+
$nin: promoIds
|
|
11239
|
+
}
|
|
11240
|
+
});
|
|
11241
|
+
},
|
|
11242
|
+
getOptions: (data) => {
|
|
11243
|
+
return data.promotions.map((promotion) => ({
|
|
11244
|
+
label: promotion.code,
|
|
11245
|
+
value: promotion.code
|
|
11246
|
+
}));
|
|
11247
|
+
}
|
|
11248
|
+
});
|
|
11249
|
+
const add = async (value) => {
|
|
11250
|
+
if (!value) {
|
|
11251
|
+
return;
|
|
11252
|
+
}
|
|
11253
|
+
addPromotions(
|
|
11254
|
+
{
|
|
11255
|
+
promo_codes: [value]
|
|
11256
|
+
},
|
|
11257
|
+
{
|
|
11258
|
+
onError: (e) => {
|
|
11259
|
+
ui.toast.error(e.message);
|
|
11260
|
+
comboboxData.onSearchValueChange("");
|
|
11261
|
+
setComboboxValue("");
|
|
11262
|
+
},
|
|
11263
|
+
onSuccess: () => {
|
|
11264
|
+
comboboxData.onSearchValueChange("");
|
|
11265
|
+
setComboboxValue("");
|
|
11266
|
+
}
|
|
11267
|
+
}
|
|
11268
|
+
);
|
|
11269
|
+
};
|
|
11270
|
+
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
11271
|
+
const { mutateAsync: requestOrderEdit } = useOrderEditRequest(preview.id);
|
|
11272
|
+
const onSubmit = async () => {
|
|
11273
|
+
setIsSubmitting(true);
|
|
11274
|
+
let requestSucceeded = false;
|
|
11275
|
+
await requestOrderEdit(void 0, {
|
|
11276
|
+
onError: (e) => {
|
|
11277
|
+
ui.toast.error(e.message);
|
|
11278
|
+
},
|
|
11279
|
+
onSuccess: () => {
|
|
11280
|
+
requestSucceeded = true;
|
|
11281
|
+
}
|
|
11282
|
+
});
|
|
11283
|
+
if (!requestSucceeded) {
|
|
11284
|
+
setIsSubmitting(false);
|
|
11285
|
+
return;
|
|
11286
|
+
}
|
|
11287
|
+
await confirmOrderEdit(void 0, {
|
|
11288
|
+
onError: (e) => {
|
|
11289
|
+
ui.toast.error(e.message);
|
|
11290
|
+
},
|
|
11291
|
+
onSuccess: () => {
|
|
11292
|
+
handleSuccess();
|
|
11293
|
+
},
|
|
11294
|
+
onSettled: () => {
|
|
11295
|
+
setIsSubmitting(false);
|
|
11296
|
+
}
|
|
11297
|
+
});
|
|
11298
|
+
};
|
|
11299
|
+
if (isError) {
|
|
11300
|
+
throw error;
|
|
11301
|
+
}
|
|
11302
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", onSubmit, children: [
|
|
11303
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
11304
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
11305
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
11306
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "promotion-combobox", children: "Apply promotions" }),
|
|
11307
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { id: "promotion-combobox-hint", children: "Manage promotions that should be applied to the order." })
|
|
11308
|
+
] }),
|
|
11309
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11310
|
+
Combobox,
|
|
11311
|
+
{
|
|
11312
|
+
id: "promotion-combobox",
|
|
11313
|
+
"aria-describedby": "promotion-combobox-hint",
|
|
11314
|
+
isFetchingNextPage: comboboxData.isFetchingNextPage,
|
|
11315
|
+
fetchNextPage: comboboxData.fetchNextPage,
|
|
11316
|
+
options: comboboxData.options,
|
|
11317
|
+
onSearchValueChange: comboboxData.onSearchValueChange,
|
|
11318
|
+
searchValue: comboboxData.searchValue,
|
|
11319
|
+
disabled: comboboxData.disabled || isAddingPromotions,
|
|
11320
|
+
onChange: add,
|
|
11321
|
+
value: comboboxValue
|
|
11322
|
+
}
|
|
11323
|
+
)
|
|
11324
|
+
] }),
|
|
11325
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
11326
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-2", children: promotions == null ? void 0 : promotions.map((promotion) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
11327
|
+
PromotionItem,
|
|
11328
|
+
{
|
|
11329
|
+
promotion,
|
|
11330
|
+
orderId: preview.id,
|
|
11331
|
+
isLoading: isPending
|
|
11332
|
+
},
|
|
11333
|
+
promotion.id
|
|
11334
|
+
)) })
|
|
11335
|
+
] }) }),
|
|
11336
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11337
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11338
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11339
|
+
ui.Button,
|
|
11340
|
+
{
|
|
11341
|
+
size: "small",
|
|
11342
|
+
type: "submit",
|
|
11343
|
+
isLoading: isSubmitting || isAddingPromotions,
|
|
11344
|
+
children: "Save"
|
|
11345
|
+
}
|
|
11346
|
+
)
|
|
11347
|
+
] }) })
|
|
11348
|
+
] });
|
|
11349
|
+
};
|
|
11350
|
+
const PromotionItem = ({
|
|
11351
|
+
promotion,
|
|
11352
|
+
orderId,
|
|
11353
|
+
isLoading
|
|
11354
|
+
}) => {
|
|
11355
|
+
var _a;
|
|
11356
|
+
const { mutateAsync: removePromotions, isPending } = useDraftOrderRemovePromotions(orderId);
|
|
11357
|
+
const onRemove = async () => {
|
|
11358
|
+
removePromotions(
|
|
11359
|
+
{
|
|
11360
|
+
promo_codes: [promotion.code]
|
|
10943
11361
|
},
|
|
10944
11362
|
{
|
|
10945
11363
|
onError: (e) => {
|
|
@@ -11035,75 +11453,7 @@ function getPromotionIds(items, shippingMethods) {
|
|
|
11035
11453
|
}
|
|
11036
11454
|
return Array.from(promotionIds);
|
|
11037
11455
|
}
|
|
11038
|
-
const
|
|
11039
|
-
const { id } = reactRouterDom.useParams();
|
|
11040
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
11041
|
-
fields: "+email"
|
|
11042
|
-
});
|
|
11043
|
-
if (isError) {
|
|
11044
|
-
throw error;
|
|
11045
|
-
}
|
|
11046
|
-
const isReady = !isPending && !!order;
|
|
11047
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11048
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
11049
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
|
|
11050
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
|
|
11051
|
-
] }),
|
|
11052
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
|
|
11053
|
-
] });
|
|
11054
|
-
};
|
|
11055
|
-
const EmailForm = ({ order }) => {
|
|
11056
|
-
const form = reactHookForm.useForm({
|
|
11057
|
-
defaultValues: {
|
|
11058
|
-
email: order.email ?? ""
|
|
11059
|
-
},
|
|
11060
|
-
resolver: zod.zodResolver(schema$3)
|
|
11061
|
-
});
|
|
11062
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11063
|
-
const { handleSuccess } = useRouteModal();
|
|
11064
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
11065
|
-
await mutateAsync(
|
|
11066
|
-
{ email: data.email },
|
|
11067
|
-
{
|
|
11068
|
-
onSuccess: () => {
|
|
11069
|
-
handleSuccess();
|
|
11070
|
-
},
|
|
11071
|
-
onError: (error) => {
|
|
11072
|
-
ui.toast.error(error.message);
|
|
11073
|
-
}
|
|
11074
|
-
}
|
|
11075
|
-
);
|
|
11076
|
-
});
|
|
11077
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11078
|
-
KeyboundForm,
|
|
11079
|
-
{
|
|
11080
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
11081
|
-
onSubmit,
|
|
11082
|
-
children: [
|
|
11083
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11084
|
-
Form$2.Field,
|
|
11085
|
-
{
|
|
11086
|
-
control: form.control,
|
|
11087
|
-
name: "email",
|
|
11088
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11089
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
|
|
11090
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11091
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11092
|
-
] })
|
|
11093
|
-
}
|
|
11094
|
-
) }),
|
|
11095
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11096
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11097
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11098
|
-
] }) })
|
|
11099
|
-
]
|
|
11100
|
-
}
|
|
11101
|
-
) });
|
|
11102
|
-
};
|
|
11103
|
-
const schema$3 = objectType({
|
|
11104
|
-
email: stringType().email()
|
|
11105
|
-
});
|
|
11106
|
-
const SalesChannel = () => {
|
|
11456
|
+
const SalesChannel = () => {
|
|
11107
11457
|
const { id } = reactRouterDom.useParams();
|
|
11108
11458
|
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11109
11459
|
id,
|
|
@@ -12552,499 +12902,149 @@ const Illustration = () => {
|
|
|
12552
12902
|
height: "3",
|
|
12553
12903
|
rx: "1.5",
|
|
12554
12904
|
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 109.758 60.0944)",
|
|
12555
|
-
fill: "#A1A1AA"
|
|
12556
|
-
}
|
|
12557
|
-
),
|
|
12558
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12559
|
-
"rect",
|
|
12560
|
-
{
|
|
12561
|
-
width: "12",
|
|
12562
|
-
height: "3",
|
|
12563
|
-
rx: "1.5",
|
|
12564
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 105.4 62.5457)",
|
|
12565
|
-
fill: "#A1A1AA"
|
|
12566
|
-
}
|
|
12567
|
-
),
|
|
12568
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12569
|
-
"path",
|
|
12570
|
-
{
|
|
12571
|
-
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",
|
|
12572
|
-
fill: "#52525B"
|
|
12573
|
-
}
|
|
12574
|
-
),
|
|
12575
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip0_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12576
|
-
"path",
|
|
12577
|
-
{
|
|
12578
|
-
d: "M133.106 81.8022L140.49 81.8447L140.515 77.6349",
|
|
12579
|
-
stroke: "#A1A1AA",
|
|
12580
|
-
strokeWidth: "1.5",
|
|
12581
|
-
strokeLinecap: "round",
|
|
12582
|
-
strokeLinejoin: "round"
|
|
12583
|
-
}
|
|
12584
|
-
) }),
|
|
12585
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip1_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12586
|
-
"path",
|
|
12587
|
-
{
|
|
12588
|
-
d: "M143.496 87.8055L150.881 87.8481L150.905 83.6383",
|
|
12589
|
-
stroke: "#A1A1AA",
|
|
12590
|
-
strokeWidth: "1.5",
|
|
12591
|
-
strokeLinecap: "round",
|
|
12592
|
-
strokeLinejoin: "round"
|
|
12593
|
-
}
|
|
12594
|
-
) }),
|
|
12595
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip2_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12596
|
-
"path",
|
|
12597
|
-
{
|
|
12598
|
-
d: "M153.887 93.8088L161.271 93.8514L161.295 89.6416",
|
|
12599
|
-
stroke: "#A1A1AA",
|
|
12600
|
-
strokeWidth: "1.5",
|
|
12601
|
-
strokeLinecap: "round",
|
|
12602
|
-
strokeLinejoin: "round"
|
|
12603
|
-
}
|
|
12604
|
-
) }),
|
|
12605
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip3_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12606
|
-
"path",
|
|
12607
|
-
{
|
|
12608
|
-
d: "M126.114 89.1912L118.729 89.1486L118.705 93.3584",
|
|
12609
|
-
stroke: "#A1A1AA",
|
|
12610
|
-
strokeWidth: "1.5",
|
|
12611
|
-
strokeLinecap: "round",
|
|
12612
|
-
strokeLinejoin: "round"
|
|
12613
|
-
}
|
|
12614
|
-
) }),
|
|
12615
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip4_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12616
|
-
"path",
|
|
12617
|
-
{
|
|
12618
|
-
d: "M136.504 95.1945L129.12 95.1519L129.095 99.3617",
|
|
12619
|
-
stroke: "#A1A1AA",
|
|
12620
|
-
strokeWidth: "1.5",
|
|
12621
|
-
strokeLinecap: "round",
|
|
12622
|
-
strokeLinejoin: "round"
|
|
12623
|
-
}
|
|
12624
|
-
) }),
|
|
12625
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip5_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12626
|
-
"path",
|
|
12627
|
-
{
|
|
12628
|
-
d: "M146.894 101.198L139.51 101.155L139.486 105.365",
|
|
12629
|
-
stroke: "#A1A1AA",
|
|
12630
|
-
strokeWidth: "1.5",
|
|
12631
|
-
strokeLinecap: "round",
|
|
12632
|
-
strokeLinejoin: "round"
|
|
12633
|
-
}
|
|
12634
|
-
) }),
|
|
12635
|
-
/* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
|
|
12636
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12637
|
-
"rect",
|
|
12638
|
-
{
|
|
12639
|
-
width: "12",
|
|
12640
|
-
height: "12",
|
|
12641
|
-
fill: "white",
|
|
12642
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
|
|
12643
|
-
}
|
|
12644
|
-
) }),
|
|
12645
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12646
|
-
"rect",
|
|
12647
|
-
{
|
|
12648
|
-
width: "12",
|
|
12649
|
-
height: "12",
|
|
12650
|
-
fill: "white",
|
|
12651
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
|
|
12652
|
-
}
|
|
12653
|
-
) }),
|
|
12654
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12655
|
-
"rect",
|
|
12656
|
-
{
|
|
12657
|
-
width: "12",
|
|
12658
|
-
height: "12",
|
|
12659
|
-
fill: "white",
|
|
12660
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
|
|
12661
|
-
}
|
|
12662
|
-
) }),
|
|
12663
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12664
|
-
"rect",
|
|
12665
|
-
{
|
|
12666
|
-
width: "12",
|
|
12667
|
-
height: "12",
|
|
12668
|
-
fill: "white",
|
|
12669
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
|
|
12670
|
-
}
|
|
12671
|
-
) }),
|
|
12672
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12673
|
-
"rect",
|
|
12674
|
-
{
|
|
12675
|
-
width: "12",
|
|
12676
|
-
height: "12",
|
|
12677
|
-
fill: "white",
|
|
12678
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
|
|
12679
|
-
}
|
|
12680
|
-
) }),
|
|
12681
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12682
|
-
"rect",
|
|
12683
|
-
{
|
|
12684
|
-
width: "12",
|
|
12685
|
-
height: "12",
|
|
12686
|
-
fill: "white",
|
|
12687
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
|
|
12688
|
-
}
|
|
12689
|
-
) })
|
|
12690
|
-
] })
|
|
12691
|
-
]
|
|
12692
|
-
}
|
|
12693
|
-
);
|
|
12694
|
-
};
|
|
12695
|
-
const schema = objectType({
|
|
12696
|
-
customer_id: stringType().min(1)
|
|
12697
|
-
});
|
|
12698
|
-
const InlineTip = React.forwardRef(
|
|
12699
|
-
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
12700
|
-
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
12701
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12702
|
-
"div",
|
|
12703
|
-
{
|
|
12704
|
-
ref,
|
|
12705
|
-
className: ui.clx(
|
|
12706
|
-
"bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
|
|
12707
|
-
className
|
|
12708
|
-
),
|
|
12709
|
-
...props,
|
|
12710
|
-
children: [
|
|
12711
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12712
|
-
"div",
|
|
12713
|
-
{
|
|
12714
|
-
role: "presentation",
|
|
12715
|
-
className: ui.clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
|
|
12716
|
-
"bg-ui-tag-orange-icon": variant === "warning"
|
|
12717
|
-
})
|
|
12718
|
-
}
|
|
12719
|
-
),
|
|
12720
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-pretty", children: [
|
|
12721
|
-
/* @__PURE__ */ jsxRuntime.jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
|
|
12722
|
-
labelValue,
|
|
12723
|
-
":"
|
|
12724
|
-
] }),
|
|
12725
|
-
" ",
|
|
12726
|
-
children
|
|
12727
|
-
] })
|
|
12728
|
-
]
|
|
12729
|
-
}
|
|
12730
|
-
);
|
|
12731
|
-
}
|
|
12732
|
-
);
|
|
12733
|
-
InlineTip.displayName = "InlineTip";
|
|
12734
|
-
const MetadataFieldSchema = objectType({
|
|
12735
|
-
key: stringType(),
|
|
12736
|
-
disabled: booleanType().optional(),
|
|
12737
|
-
value: anyType()
|
|
12738
|
-
});
|
|
12739
|
-
const MetadataSchema = objectType({
|
|
12740
|
-
metadata: arrayType(MetadataFieldSchema)
|
|
12741
|
-
});
|
|
12742
|
-
const Metadata = () => {
|
|
12743
|
-
const { id } = reactRouterDom.useParams();
|
|
12744
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
12745
|
-
fields: "metadata"
|
|
12746
|
-
});
|
|
12747
|
-
if (isError) {
|
|
12748
|
-
throw error;
|
|
12749
|
-
}
|
|
12750
|
-
const isReady = !isPending && !!order;
|
|
12751
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12752
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12753
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Metadata" }) }),
|
|
12754
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
|
|
12755
|
-
] }),
|
|
12756
|
-
!isReady ? /* @__PURE__ */ jsxRuntime.jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsxRuntime.jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
|
|
12757
|
-
] });
|
|
12758
|
-
};
|
|
12759
|
-
const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
|
|
12760
|
-
const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
|
|
12761
|
-
const MetadataForm = ({ orderId, metadata }) => {
|
|
12762
|
-
const { handleSuccess } = useRouteModal();
|
|
12763
|
-
const hasUneditableRows = getHasUneditableRows(metadata);
|
|
12764
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
|
|
12765
|
-
const form = reactHookForm.useForm({
|
|
12766
|
-
defaultValues: {
|
|
12767
|
-
metadata: getDefaultValues(metadata)
|
|
12768
|
-
},
|
|
12769
|
-
resolver: zod.zodResolver(MetadataSchema)
|
|
12770
|
-
});
|
|
12771
|
-
const handleSubmit = form.handleSubmit(async (data) => {
|
|
12772
|
-
const parsedData = parseValues(data);
|
|
12773
|
-
await mutateAsync(
|
|
12774
|
-
{
|
|
12775
|
-
metadata: parsedData
|
|
12776
|
-
},
|
|
12777
|
-
{
|
|
12778
|
-
onSuccess: () => {
|
|
12779
|
-
ui.toast.success("Metadata updated");
|
|
12780
|
-
handleSuccess();
|
|
12781
|
-
},
|
|
12782
|
-
onError: (error) => {
|
|
12783
|
-
ui.toast.error(error.message);
|
|
12784
|
-
}
|
|
12785
|
-
}
|
|
12786
|
-
);
|
|
12787
|
-
});
|
|
12788
|
-
const { fields, insert, remove } = reactHookForm.useFieldArray({
|
|
12789
|
-
control: form.control,
|
|
12790
|
-
name: "metadata"
|
|
12791
|
-
});
|
|
12792
|
-
function deleteRow(index) {
|
|
12793
|
-
remove(index);
|
|
12794
|
-
if (fields.length === 1) {
|
|
12795
|
-
insert(0, {
|
|
12796
|
-
key: "",
|
|
12797
|
-
value: "",
|
|
12798
|
-
disabled: false
|
|
12799
|
-
});
|
|
12800
|
-
}
|
|
12801
|
-
}
|
|
12802
|
-
function insertRow(index, position) {
|
|
12803
|
-
insert(index + (position === "above" ? 0 : 1), {
|
|
12804
|
-
key: "",
|
|
12805
|
-
value: "",
|
|
12806
|
-
disabled: false
|
|
12807
|
-
});
|
|
12808
|
-
}
|
|
12809
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12810
|
-
KeyboundForm,
|
|
12811
|
-
{
|
|
12812
|
-
onSubmit: handleSubmit,
|
|
12813
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12814
|
-
children: [
|
|
12815
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: [
|
|
12816
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-1 divide-y rounded-lg", children: [
|
|
12817
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle grid grid-cols-2 divide-x rounded-t-lg", children: [
|
|
12818
|
-
/* @__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" }) }),
|
|
12819
|
-
/* @__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" }) })
|
|
12820
|
-
] }),
|
|
12821
|
-
fields.map((field, index) => {
|
|
12822
|
-
const isDisabled = field.disabled || false;
|
|
12823
|
-
let placeholder = "-";
|
|
12824
|
-
if (typeof field.value === "object") {
|
|
12825
|
-
placeholder = "{ ... }";
|
|
12826
|
-
}
|
|
12827
|
-
if (Array.isArray(field.value)) {
|
|
12828
|
-
placeholder = "[ ... ]";
|
|
12829
|
-
}
|
|
12830
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12831
|
-
ConditionalTooltip,
|
|
12832
|
-
{
|
|
12833
|
-
showTooltip: isDisabled,
|
|
12834
|
-
content: "This row is disabled because it contains non-primitive data.",
|
|
12835
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "group/table relative", children: [
|
|
12836
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
12837
|
-
"div",
|
|
12838
|
-
{
|
|
12839
|
-
className: ui.clx("grid grid-cols-2 divide-x", {
|
|
12840
|
-
"overflow-hidden rounded-b-lg": index === fields.length - 1
|
|
12841
|
-
}),
|
|
12842
|
-
children: [
|
|
12843
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12844
|
-
Form$2.Field,
|
|
12845
|
-
{
|
|
12846
|
-
control: form.control,
|
|
12847
|
-
name: `metadata.${index}.key`,
|
|
12848
|
-
render: ({ field: field2 }) => {
|
|
12849
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12850
|
-
GridInput,
|
|
12851
|
-
{
|
|
12852
|
-
"aria-labelledby": METADATA_KEY_LABEL_ID,
|
|
12853
|
-
...field2,
|
|
12854
|
-
disabled: isDisabled,
|
|
12855
|
-
placeholder: "Key"
|
|
12856
|
-
}
|
|
12857
|
-
) }) });
|
|
12858
|
-
}
|
|
12859
|
-
}
|
|
12860
|
-
),
|
|
12861
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12862
|
-
Form$2.Field,
|
|
12863
|
-
{
|
|
12864
|
-
control: form.control,
|
|
12865
|
-
name: `metadata.${index}.value`,
|
|
12866
|
-
render: ({ field: { value, ...field2 } }) => {
|
|
12867
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12868
|
-
GridInput,
|
|
12869
|
-
{
|
|
12870
|
-
"aria-labelledby": METADATA_VALUE_LABEL_ID,
|
|
12871
|
-
...field2,
|
|
12872
|
-
value: isDisabled ? placeholder : value,
|
|
12873
|
-
disabled: isDisabled,
|
|
12874
|
-
placeholder: "Value"
|
|
12875
|
-
}
|
|
12876
|
-
) }) });
|
|
12877
|
-
}
|
|
12878
|
-
}
|
|
12879
|
-
)
|
|
12880
|
-
]
|
|
12881
|
-
}
|
|
12882
|
-
),
|
|
12883
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu, { children: [
|
|
12884
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12885
|
-
ui.DropdownMenu.Trigger,
|
|
12886
|
-
{
|
|
12887
|
-
className: ui.clx(
|
|
12888
|
-
"invisible absolute inset-y-0 -right-2.5 my-auto group-hover/table:visible data-[state='open']:visible",
|
|
12889
|
-
{
|
|
12890
|
-
hidden: isDisabled
|
|
12891
|
-
}
|
|
12892
|
-
),
|
|
12893
|
-
disabled: isDisabled,
|
|
12894
|
-
asChild: true,
|
|
12895
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { size: "2xsmall", children: /* @__PURE__ */ jsxRuntime.jsx(icons.EllipsisVertical, {}) })
|
|
12896
|
-
}
|
|
12897
|
-
),
|
|
12898
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu.Content, { children: [
|
|
12899
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
12900
|
-
ui.DropdownMenu.Item,
|
|
12901
|
-
{
|
|
12902
|
-
className: "gap-x-2",
|
|
12903
|
-
onClick: () => insertRow(index, "above"),
|
|
12904
|
-
children: [
|
|
12905
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowUpMini, { className: "text-ui-fg-subtle" }),
|
|
12906
|
-
"Insert row above"
|
|
12907
|
-
]
|
|
12908
|
-
}
|
|
12909
|
-
),
|
|
12910
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
12911
|
-
ui.DropdownMenu.Item,
|
|
12912
|
-
{
|
|
12913
|
-
className: "gap-x-2",
|
|
12914
|
-
onClick: () => insertRow(index, "below"),
|
|
12915
|
-
children: [
|
|
12916
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowDownMini, { className: "text-ui-fg-subtle" }),
|
|
12917
|
-
"Insert row below"
|
|
12918
|
-
]
|
|
12919
|
-
}
|
|
12920
|
-
),
|
|
12921
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenu.Separator, {}),
|
|
12922
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
12923
|
-
ui.DropdownMenu.Item,
|
|
12924
|
-
{
|
|
12925
|
-
className: "gap-x-2",
|
|
12926
|
-
onClick: () => deleteRow(index),
|
|
12927
|
-
children: [
|
|
12928
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.Trash, { className: "text-ui-fg-subtle" }),
|
|
12929
|
-
"Delete row"
|
|
12930
|
-
]
|
|
12931
|
-
}
|
|
12932
|
-
)
|
|
12933
|
-
] })
|
|
12934
|
-
] })
|
|
12935
|
-
] })
|
|
12936
|
-
},
|
|
12937
|
-
field.id
|
|
12938
|
-
);
|
|
12939
|
-
})
|
|
12940
|
-
] }),
|
|
12941
|
-
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." })
|
|
12942
|
-
] }),
|
|
12943
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
12944
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
12945
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12946
|
-
] }) })
|
|
12905
|
+
fill: "#A1A1AA"
|
|
12906
|
+
}
|
|
12907
|
+
),
|
|
12908
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12909
|
+
"rect",
|
|
12910
|
+
{
|
|
12911
|
+
width: "12",
|
|
12912
|
+
height: "3",
|
|
12913
|
+
rx: "1.5",
|
|
12914
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 105.4 62.5457)",
|
|
12915
|
+
fill: "#A1A1AA"
|
|
12916
|
+
}
|
|
12917
|
+
),
|
|
12918
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12919
|
+
"path",
|
|
12920
|
+
{
|
|
12921
|
+
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",
|
|
12922
|
+
fill: "#52525B"
|
|
12923
|
+
}
|
|
12924
|
+
),
|
|
12925
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip0_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12926
|
+
"path",
|
|
12927
|
+
{
|
|
12928
|
+
d: "M133.106 81.8022L140.49 81.8447L140.515 77.6349",
|
|
12929
|
+
stroke: "#A1A1AA",
|
|
12930
|
+
strokeWidth: "1.5",
|
|
12931
|
+
strokeLinecap: "round",
|
|
12932
|
+
strokeLinejoin: "round"
|
|
12933
|
+
}
|
|
12934
|
+
) }),
|
|
12935
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip1_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12936
|
+
"path",
|
|
12937
|
+
{
|
|
12938
|
+
d: "M143.496 87.8055L150.881 87.8481L150.905 83.6383",
|
|
12939
|
+
stroke: "#A1A1AA",
|
|
12940
|
+
strokeWidth: "1.5",
|
|
12941
|
+
strokeLinecap: "round",
|
|
12942
|
+
strokeLinejoin: "round"
|
|
12943
|
+
}
|
|
12944
|
+
) }),
|
|
12945
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip2_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12946
|
+
"path",
|
|
12947
|
+
{
|
|
12948
|
+
d: "M153.887 93.8088L161.271 93.8514L161.295 89.6416",
|
|
12949
|
+
stroke: "#A1A1AA",
|
|
12950
|
+
strokeWidth: "1.5",
|
|
12951
|
+
strokeLinecap: "round",
|
|
12952
|
+
strokeLinejoin: "round"
|
|
12953
|
+
}
|
|
12954
|
+
) }),
|
|
12955
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip3_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12956
|
+
"path",
|
|
12957
|
+
{
|
|
12958
|
+
d: "M126.114 89.1912L118.729 89.1486L118.705 93.3584",
|
|
12959
|
+
stroke: "#A1A1AA",
|
|
12960
|
+
strokeWidth: "1.5",
|
|
12961
|
+
strokeLinecap: "round",
|
|
12962
|
+
strokeLinejoin: "round"
|
|
12963
|
+
}
|
|
12964
|
+
) }),
|
|
12965
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip4_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12966
|
+
"path",
|
|
12967
|
+
{
|
|
12968
|
+
d: "M136.504 95.1945L129.12 95.1519L129.095 99.3617",
|
|
12969
|
+
stroke: "#A1A1AA",
|
|
12970
|
+
strokeWidth: "1.5",
|
|
12971
|
+
strokeLinecap: "round",
|
|
12972
|
+
strokeLinejoin: "round"
|
|
12973
|
+
}
|
|
12974
|
+
) }),
|
|
12975
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip5_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12976
|
+
"path",
|
|
12977
|
+
{
|
|
12978
|
+
d: "M146.894 101.198L139.51 101.155L139.486 105.365",
|
|
12979
|
+
stroke: "#A1A1AA",
|
|
12980
|
+
strokeWidth: "1.5",
|
|
12981
|
+
strokeLinecap: "round",
|
|
12982
|
+
strokeLinejoin: "round"
|
|
12983
|
+
}
|
|
12984
|
+
) }),
|
|
12985
|
+
/* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
|
|
12986
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12987
|
+
"rect",
|
|
12988
|
+
{
|
|
12989
|
+
width: "12",
|
|
12990
|
+
height: "12",
|
|
12991
|
+
fill: "white",
|
|
12992
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
|
|
12993
|
+
}
|
|
12994
|
+
) }),
|
|
12995
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12996
|
+
"rect",
|
|
12997
|
+
{
|
|
12998
|
+
width: "12",
|
|
12999
|
+
height: "12",
|
|
13000
|
+
fill: "white",
|
|
13001
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
|
|
13002
|
+
}
|
|
13003
|
+
) }),
|
|
13004
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13005
|
+
"rect",
|
|
13006
|
+
{
|
|
13007
|
+
width: "12",
|
|
13008
|
+
height: "12",
|
|
13009
|
+
fill: "white",
|
|
13010
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
|
|
13011
|
+
}
|
|
13012
|
+
) }),
|
|
13013
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13014
|
+
"rect",
|
|
13015
|
+
{
|
|
13016
|
+
width: "12",
|
|
13017
|
+
height: "12",
|
|
13018
|
+
fill: "white",
|
|
13019
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
|
|
13020
|
+
}
|
|
13021
|
+
) }),
|
|
13022
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13023
|
+
"rect",
|
|
13024
|
+
{
|
|
13025
|
+
width: "12",
|
|
13026
|
+
height: "12",
|
|
13027
|
+
fill: "white",
|
|
13028
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
|
|
13029
|
+
}
|
|
13030
|
+
) }),
|
|
13031
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13032
|
+
"rect",
|
|
13033
|
+
{
|
|
13034
|
+
width: "12",
|
|
13035
|
+
height: "12",
|
|
13036
|
+
fill: "white",
|
|
13037
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
|
|
13038
|
+
}
|
|
13039
|
+
) })
|
|
13040
|
+
] })
|
|
12947
13041
|
]
|
|
12948
13042
|
}
|
|
12949
|
-
) });
|
|
12950
|
-
};
|
|
12951
|
-
const GridInput = React.forwardRef(({ className, ...props }, ref) => {
|
|
12952
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12953
|
-
"input",
|
|
12954
|
-
{
|
|
12955
|
-
ref,
|
|
12956
|
-
...props,
|
|
12957
|
-
autoComplete: "off",
|
|
12958
|
-
className: ui.clx(
|
|
12959
|
-
"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",
|
|
12960
|
-
className
|
|
12961
|
-
)
|
|
12962
|
-
}
|
|
12963
13043
|
);
|
|
12964
|
-
});
|
|
12965
|
-
GridInput.displayName = "MetadataForm.GridInput";
|
|
12966
|
-
const PlaceholderInner = () => {
|
|
12967
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
12968
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-[148ox] w-full rounded-lg" }) }),
|
|
12969
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
12970
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" }),
|
|
12971
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" })
|
|
12972
|
-
] }) })
|
|
12973
|
-
] });
|
|
12974
13044
|
};
|
|
12975
|
-
const
|
|
12976
|
-
|
|
12977
|
-
|
|
12978
|
-
return [
|
|
12979
|
-
{
|
|
12980
|
-
key: "",
|
|
12981
|
-
value: "",
|
|
12982
|
-
disabled: false
|
|
12983
|
-
}
|
|
12984
|
-
];
|
|
12985
|
-
}
|
|
12986
|
-
return Object.entries(metadata).map(([key, value]) => {
|
|
12987
|
-
if (!EDITABLE_TYPES.includes(typeof value)) {
|
|
12988
|
-
return {
|
|
12989
|
-
key,
|
|
12990
|
-
value,
|
|
12991
|
-
disabled: true
|
|
12992
|
-
};
|
|
12993
|
-
}
|
|
12994
|
-
let stringValue = value;
|
|
12995
|
-
if (typeof value !== "string") {
|
|
12996
|
-
stringValue = JSON.stringify(value);
|
|
12997
|
-
}
|
|
12998
|
-
return {
|
|
12999
|
-
key,
|
|
13000
|
-
value: stringValue,
|
|
13001
|
-
original_key: key
|
|
13002
|
-
};
|
|
13003
|
-
});
|
|
13004
|
-
}
|
|
13005
|
-
function parseValues(values) {
|
|
13006
|
-
const metadata = values.metadata;
|
|
13007
|
-
const isEmpty = !metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value;
|
|
13008
|
-
if (isEmpty) {
|
|
13009
|
-
return null;
|
|
13010
|
-
}
|
|
13011
|
-
const update = {};
|
|
13012
|
-
metadata.forEach((field) => {
|
|
13013
|
-
let key = field.key;
|
|
13014
|
-
let value = field.value;
|
|
13015
|
-
const disabled = field.disabled;
|
|
13016
|
-
if (!key || !value) {
|
|
13017
|
-
return;
|
|
13018
|
-
}
|
|
13019
|
-
if (disabled) {
|
|
13020
|
-
update[key] = value;
|
|
13021
|
-
return;
|
|
13022
|
-
}
|
|
13023
|
-
key = key.trim();
|
|
13024
|
-
value = value.trim();
|
|
13025
|
-
if (value === "true") {
|
|
13026
|
-
update[key] = true;
|
|
13027
|
-
} else if (value === "false") {
|
|
13028
|
-
update[key] = false;
|
|
13029
|
-
} else {
|
|
13030
|
-
const parsedNumber = parseFloat(value);
|
|
13031
|
-
if (!isNaN(parsedNumber)) {
|
|
13032
|
-
update[key] = parsedNumber;
|
|
13033
|
-
} else {
|
|
13034
|
-
update[key] = value;
|
|
13035
|
-
}
|
|
13036
|
-
}
|
|
13037
|
-
});
|
|
13038
|
-
return update;
|
|
13039
|
-
}
|
|
13040
|
-
function getHasUneditableRows(metadata) {
|
|
13041
|
-
if (!metadata) {
|
|
13042
|
-
return false;
|
|
13043
|
-
}
|
|
13044
|
-
return Object.values(metadata).some(
|
|
13045
|
-
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
13046
|
-
);
|
|
13047
|
-
}
|
|
13045
|
+
const schema = objectType({
|
|
13046
|
+
customer_id: stringType().min(1)
|
|
13047
|
+
});
|
|
13048
13048
|
const widgetModule = { widgets: [] };
|
|
13049
13049
|
const routeModule = {
|
|
13050
13050
|
routes: [
|
|
@@ -13065,25 +13065,29 @@ const routeModule = {
|
|
|
13065
13065
|
handle,
|
|
13066
13066
|
loader,
|
|
13067
13067
|
children: [
|
|
13068
|
+
{
|
|
13069
|
+
Component: CustomItems,
|
|
13070
|
+
path: "/draft-orders/:id/custom-items"
|
|
13071
|
+
},
|
|
13068
13072
|
{
|
|
13069
13073
|
Component: BillingAddress,
|
|
13070
13074
|
path: "/draft-orders/:id/billing-address"
|
|
13071
13075
|
},
|
|
13072
13076
|
{
|
|
13073
|
-
Component:
|
|
13074
|
-
path: "/draft-orders/:id/
|
|
13077
|
+
Component: Email,
|
|
13078
|
+
path: "/draft-orders/:id/email"
|
|
13075
13079
|
},
|
|
13076
13080
|
{
|
|
13077
13081
|
Component: Items,
|
|
13078
13082
|
path: "/draft-orders/:id/items"
|
|
13079
13083
|
},
|
|
13080
13084
|
{
|
|
13081
|
-
Component:
|
|
13082
|
-
path: "/draft-orders/:id/
|
|
13085
|
+
Component: Metadata,
|
|
13086
|
+
path: "/draft-orders/:id/metadata"
|
|
13083
13087
|
},
|
|
13084
13088
|
{
|
|
13085
|
-
Component:
|
|
13086
|
-
path: "/draft-orders/:id/
|
|
13089
|
+
Component: Promotions,
|
|
13090
|
+
path: "/draft-orders/:id/promotions"
|
|
13087
13091
|
},
|
|
13088
13092
|
{
|
|
13089
13093
|
Component: SalesChannel,
|
|
@@ -13100,10 +13104,6 @@ const routeModule = {
|
|
|
13100
13104
|
{
|
|
13101
13105
|
Component: TransferOwnership,
|
|
13102
13106
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13103
|
-
},
|
|
13104
|
-
{
|
|
13105
|
-
Component: Metadata,
|
|
13106
|
-
path: "/draft-orders/:id/metadata"
|
|
13107
13107
|
}
|
|
13108
13108
|
]
|
|
13109
13109
|
}
|