@medusajs/draft-order 2.10.4-preview-20250923210152 → 2.10.4-preview-20250924031247
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 +966 -966
- package/.medusa/server/src/admin/index.mjs +967 -967
- package/package.json +16 -16
|
@@ -9763,6 +9763,27 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9763
9763
|
) });
|
|
9764
9764
|
};
|
|
9765
9765
|
const schema$5 = addressSchema;
|
|
9766
|
+
const CustomItems = () => {
|
|
9767
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9768
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
9769
|
+
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
9770
|
+
] });
|
|
9771
|
+
};
|
|
9772
|
+
const CustomItemsForm = () => {
|
|
9773
|
+
const form = reactHookForm.useForm({
|
|
9774
|
+
resolver: zod.zodResolver(schema$4)
|
|
9775
|
+
});
|
|
9776
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9777
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
9778
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9779
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9780
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
9781
|
+
] }) })
|
|
9782
|
+
] }) });
|
|
9783
|
+
};
|
|
9784
|
+
const schema$4 = objectType({
|
|
9785
|
+
email: stringType().email()
|
|
9786
|
+
});
|
|
9766
9787
|
const Email = () => {
|
|
9767
9788
|
const { id } = reactRouterDom.useParams();
|
|
9768
9789
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -9785,7 +9806,7 @@ const EmailForm = ({ order }) => {
|
|
|
9785
9806
|
defaultValues: {
|
|
9786
9807
|
email: order.email ?? ""
|
|
9787
9808
|
},
|
|
9788
|
-
resolver: zod.zodResolver(schema$
|
|
9809
|
+
resolver: zod.zodResolver(schema$3)
|
|
9789
9810
|
});
|
|
9790
9811
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9791
9812
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9828,223 +9849,573 @@ const EmailForm = ({ order }) => {
|
|
|
9828
9849
|
}
|
|
9829
9850
|
) });
|
|
9830
9851
|
};
|
|
9831
|
-
const schema$
|
|
9852
|
+
const schema$3 = objectType({
|
|
9832
9853
|
email: stringType().email()
|
|
9833
9854
|
});
|
|
9834
|
-
const
|
|
9835
|
-
({
|
|
9836
|
-
|
|
9837
|
-
onChange,
|
|
9838
|
-
size = "base",
|
|
9839
|
-
min = 0,
|
|
9840
|
-
max = 100,
|
|
9841
|
-
step = 1,
|
|
9842
|
-
className,
|
|
9843
|
-
disabled,
|
|
9844
|
-
...props
|
|
9845
|
-
}, ref) => {
|
|
9846
|
-
const handleChange = (event) => {
|
|
9847
|
-
const newValue = event.target.value === "" ? min : Number(event.target.value);
|
|
9848
|
-
if (!isNaN(newValue) && (max === void 0 || newValue <= max) && (min === void 0 || newValue >= min)) {
|
|
9849
|
-
onChange(newValue);
|
|
9850
|
-
}
|
|
9851
|
-
};
|
|
9852
|
-
const handleIncrement = () => {
|
|
9853
|
-
const newValue = value + step;
|
|
9854
|
-
if (max === void 0 || newValue <= max) {
|
|
9855
|
-
onChange(newValue);
|
|
9856
|
-
}
|
|
9857
|
-
};
|
|
9858
|
-
const handleDecrement = () => {
|
|
9859
|
-
const newValue = value - step;
|
|
9860
|
-
if (min === void 0 || newValue >= min) {
|
|
9861
|
-
onChange(newValue);
|
|
9862
|
-
}
|
|
9863
|
-
};
|
|
9855
|
+
const InlineTip = React.forwardRef(
|
|
9856
|
+
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
9857
|
+
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
9864
9858
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9865
9859
|
"div",
|
|
9866
9860
|
{
|
|
9861
|
+
ref,
|
|
9867
9862
|
className: ui.clx(
|
|
9868
|
-
"
|
|
9869
|
-
"[&:has(input:focus)]:shadow-borders-interactive-with-active",
|
|
9870
|
-
{
|
|
9871
|
-
"h-7": size === "small",
|
|
9872
|
-
"h-8": size === "base"
|
|
9873
|
-
},
|
|
9863
|
+
"bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
|
|
9874
9864
|
className
|
|
9875
9865
|
),
|
|
9866
|
+
...props,
|
|
9876
9867
|
children: [
|
|
9877
9868
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9878
|
-
"
|
|
9879
|
-
{
|
|
9880
|
-
ref,
|
|
9881
|
-
type: "number",
|
|
9882
|
-
value,
|
|
9883
|
-
onChange: handleChange,
|
|
9884
|
-
min,
|
|
9885
|
-
max,
|
|
9886
|
-
step,
|
|
9887
|
-
className: ui.clx(
|
|
9888
|
-
"flex-1 px-2 py-1 bg-transparent txt-compact-small text-ui-fg-base outline-none [appearance:textfield]",
|
|
9889
|
-
"[&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none",
|
|
9890
|
-
"placeholder:text-ui-fg-muted"
|
|
9891
|
-
),
|
|
9892
|
-
...props
|
|
9893
|
-
}
|
|
9894
|
-
),
|
|
9895
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
9896
|
-
"button",
|
|
9869
|
+
"div",
|
|
9897
9870
|
{
|
|
9898
|
-
|
|
9899
|
-
|
|
9900
|
-
"
|
|
9901
|
-
|
|
9902
|
-
"hover:bg-ui-bg-field-component-hover",
|
|
9903
|
-
{
|
|
9904
|
-
"size-7": size === "small",
|
|
9905
|
-
"size-8": size === "base"
|
|
9906
|
-
}
|
|
9907
|
-
),
|
|
9908
|
-
type: "button",
|
|
9909
|
-
onClick: handleDecrement,
|
|
9910
|
-
disabled: min !== void 0 && value <= min || disabled,
|
|
9911
|
-
children: [
|
|
9912
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.Minus, {}),
|
|
9913
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: `Decrease by ${step}` })
|
|
9914
|
-
]
|
|
9871
|
+
role: "presentation",
|
|
9872
|
+
className: ui.clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
|
|
9873
|
+
"bg-ui-tag-orange-icon": variant === "warning"
|
|
9874
|
+
})
|
|
9915
9875
|
}
|
|
9916
9876
|
),
|
|
9917
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
9918
|
-
"
|
|
9919
|
-
|
|
9920
|
-
|
|
9921
|
-
|
|
9922
|
-
|
|
9923
|
-
|
|
9924
|
-
|
|
9925
|
-
{
|
|
9926
|
-
"size-7": size === "small",
|
|
9927
|
-
"size-8": size === "base"
|
|
9928
|
-
}
|
|
9929
|
-
),
|
|
9930
|
-
type: "button",
|
|
9931
|
-
onClick: handleIncrement,
|
|
9932
|
-
disabled: max !== void 0 && value >= max || disabled,
|
|
9933
|
-
children: [
|
|
9934
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.Plus, {}),
|
|
9935
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: `Increase by ${step}` })
|
|
9936
|
-
]
|
|
9937
|
-
}
|
|
9938
|
-
)
|
|
9877
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-pretty", children: [
|
|
9878
|
+
/* @__PURE__ */ jsxRuntime.jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
|
|
9879
|
+
labelValue,
|
|
9880
|
+
":"
|
|
9881
|
+
] }),
|
|
9882
|
+
" ",
|
|
9883
|
+
children
|
|
9884
|
+
] })
|
|
9939
9885
|
]
|
|
9940
9886
|
}
|
|
9941
9887
|
);
|
|
9942
9888
|
}
|
|
9943
9889
|
);
|
|
9944
|
-
|
|
9945
|
-
const
|
|
9946
|
-
|
|
9947
|
-
|
|
9948
|
-
|
|
9949
|
-
|
|
9950
|
-
|
|
9951
|
-
|
|
9952
|
-
|
|
9953
|
-
|
|
9954
|
-
queryFn: async () => await sdk.admin.productVariant.list(query2),
|
|
9955
|
-
...options
|
|
9956
|
-
});
|
|
9957
|
-
return { ...data, ...rest };
|
|
9958
|
-
};
|
|
9959
|
-
const useCancelOrderEdit = ({ preview }) => {
|
|
9960
|
-
const { mutateAsync: cancelOrderEdit } = useDraftOrderCancelEdit(preview == null ? void 0 : preview.id);
|
|
9961
|
-
const onCancel = React.useCallback(async () => {
|
|
9962
|
-
if (!preview) {
|
|
9963
|
-
return true;
|
|
9964
|
-
}
|
|
9965
|
-
let res = false;
|
|
9966
|
-
await cancelOrderEdit(void 0, {
|
|
9967
|
-
onError: (e) => {
|
|
9968
|
-
ui.toast.error(e.message);
|
|
9969
|
-
},
|
|
9970
|
-
onSuccess: () => {
|
|
9971
|
-
res = true;
|
|
9972
|
-
}
|
|
9973
|
-
});
|
|
9974
|
-
return res;
|
|
9975
|
-
}, [preview, cancelOrderEdit]);
|
|
9976
|
-
return { onCancel };
|
|
9977
|
-
};
|
|
9978
|
-
let IS_REQUEST_RUNNING = false;
|
|
9979
|
-
const useInitiateOrderEdit = ({
|
|
9980
|
-
preview
|
|
9981
|
-
}) => {
|
|
9982
|
-
const navigate = reactRouterDom.useNavigate();
|
|
9983
|
-
const { mutateAsync } = useDraftOrderBeginEdit(preview == null ? void 0 : preview.id);
|
|
9984
|
-
React.useEffect(() => {
|
|
9985
|
-
async function run() {
|
|
9986
|
-
if (IS_REQUEST_RUNNING || !preview) {
|
|
9987
|
-
return;
|
|
9988
|
-
}
|
|
9989
|
-
if (preview.order_change) {
|
|
9990
|
-
return;
|
|
9991
|
-
}
|
|
9992
|
-
IS_REQUEST_RUNNING = true;
|
|
9993
|
-
await mutateAsync(void 0, {
|
|
9994
|
-
onError: (e) => {
|
|
9995
|
-
ui.toast.error(e.message);
|
|
9996
|
-
navigate(`/draft-orders/${preview.id}`, { replace: true });
|
|
9997
|
-
return;
|
|
9998
|
-
}
|
|
9999
|
-
});
|
|
10000
|
-
IS_REQUEST_RUNNING = false;
|
|
10001
|
-
}
|
|
10002
|
-
run();
|
|
10003
|
-
}, [preview, navigate, mutateAsync]);
|
|
10004
|
-
};
|
|
10005
|
-
function convertNumber(value) {
|
|
10006
|
-
return typeof value === "string" ? Number(value.replace(",", ".")) : value;
|
|
10007
|
-
}
|
|
10008
|
-
const STACKED_MODAL_ID = "items_stacked_modal";
|
|
10009
|
-
const Items = () => {
|
|
9890
|
+
InlineTip.displayName = "InlineTip";
|
|
9891
|
+
const MetadataFieldSchema = objectType({
|
|
9892
|
+
key: stringType(),
|
|
9893
|
+
disabled: booleanType().optional(),
|
|
9894
|
+
value: anyType()
|
|
9895
|
+
});
|
|
9896
|
+
const MetadataSchema = objectType({
|
|
9897
|
+
metadata: arrayType(MetadataFieldSchema)
|
|
9898
|
+
});
|
|
9899
|
+
const Metadata = () => {
|
|
10010
9900
|
const { id } = reactRouterDom.useParams();
|
|
10011
|
-
const {
|
|
10012
|
-
|
|
10013
|
-
isPending: isPreviewPending,
|
|
10014
|
-
isError: isPreviewError,
|
|
10015
|
-
error: previewError
|
|
10016
|
-
} = useOrderPreview(id, void 0, {
|
|
10017
|
-
placeholderData: reactQuery.keepPreviousData
|
|
9901
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
9902
|
+
fields: "metadata"
|
|
10018
9903
|
});
|
|
10019
|
-
useInitiateOrderEdit({ preview });
|
|
10020
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
10021
|
-
id,
|
|
10022
|
-
{
|
|
10023
|
-
fields: "currency_code"
|
|
10024
|
-
},
|
|
10025
|
-
{
|
|
10026
|
-
enabled: !!id
|
|
10027
|
-
}
|
|
10028
|
-
);
|
|
10029
|
-
const { onCancel } = useCancelOrderEdit({ preview });
|
|
10030
9904
|
if (isError) {
|
|
10031
9905
|
throw error;
|
|
10032
9906
|
}
|
|
10033
|
-
|
|
10034
|
-
|
|
10035
|
-
|
|
10036
|
-
|
|
10037
|
-
|
|
10038
|
-
|
|
10039
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10040
|
-
] })
|
|
9907
|
+
const isReady = !isPending && !!order;
|
|
9908
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9909
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
9910
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Metadata" }) }),
|
|
9911
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
|
|
9912
|
+
] }),
|
|
9913
|
+
!isReady ? /* @__PURE__ */ jsxRuntime.jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsxRuntime.jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
|
|
9914
|
+
] });
|
|
10041
9915
|
};
|
|
10042
|
-
const
|
|
10043
|
-
|
|
10044
|
-
|
|
10045
|
-
const
|
|
10046
|
-
|
|
10047
|
-
);
|
|
9916
|
+
const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
|
|
9917
|
+
const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
|
|
9918
|
+
const MetadataForm = ({ orderId, metadata }) => {
|
|
9919
|
+
const { handleSuccess } = useRouteModal();
|
|
9920
|
+
const hasUneditableRows = getHasUneditableRows(metadata);
|
|
9921
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
|
|
9922
|
+
const form = reactHookForm.useForm({
|
|
9923
|
+
defaultValues: {
|
|
9924
|
+
metadata: getDefaultValues(metadata)
|
|
9925
|
+
},
|
|
9926
|
+
resolver: zod.zodResolver(MetadataSchema)
|
|
9927
|
+
});
|
|
9928
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
9929
|
+
const parsedData = parseValues(data);
|
|
9930
|
+
await mutateAsync(
|
|
9931
|
+
{
|
|
9932
|
+
metadata: parsedData
|
|
9933
|
+
},
|
|
9934
|
+
{
|
|
9935
|
+
onSuccess: () => {
|
|
9936
|
+
ui.toast.success("Metadata updated");
|
|
9937
|
+
handleSuccess();
|
|
9938
|
+
},
|
|
9939
|
+
onError: (error) => {
|
|
9940
|
+
ui.toast.error(error.message);
|
|
9941
|
+
}
|
|
9942
|
+
}
|
|
9943
|
+
);
|
|
9944
|
+
});
|
|
9945
|
+
const { fields, insert, remove } = reactHookForm.useFieldArray({
|
|
9946
|
+
control: form.control,
|
|
9947
|
+
name: "metadata"
|
|
9948
|
+
});
|
|
9949
|
+
function deleteRow(index) {
|
|
9950
|
+
remove(index);
|
|
9951
|
+
if (fields.length === 1) {
|
|
9952
|
+
insert(0, {
|
|
9953
|
+
key: "",
|
|
9954
|
+
value: "",
|
|
9955
|
+
disabled: false
|
|
9956
|
+
});
|
|
9957
|
+
}
|
|
9958
|
+
}
|
|
9959
|
+
function insertRow(index, position) {
|
|
9960
|
+
insert(index + (position === "above" ? 0 : 1), {
|
|
9961
|
+
key: "",
|
|
9962
|
+
value: "",
|
|
9963
|
+
disabled: false
|
|
9964
|
+
});
|
|
9965
|
+
}
|
|
9966
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9967
|
+
KeyboundForm,
|
|
9968
|
+
{
|
|
9969
|
+
onSubmit: handleSubmit,
|
|
9970
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
9971
|
+
children: [
|
|
9972
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: [
|
|
9973
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-1 divide-y rounded-lg", children: [
|
|
9974
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle grid grid-cols-2 divide-x rounded-t-lg", children: [
|
|
9975
|
+
/* @__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" }) }),
|
|
9976
|
+
/* @__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" }) })
|
|
9977
|
+
] }),
|
|
9978
|
+
fields.map((field, index) => {
|
|
9979
|
+
const isDisabled = field.disabled || false;
|
|
9980
|
+
let placeholder = "-";
|
|
9981
|
+
if (typeof field.value === "object") {
|
|
9982
|
+
placeholder = "{ ... }";
|
|
9983
|
+
}
|
|
9984
|
+
if (Array.isArray(field.value)) {
|
|
9985
|
+
placeholder = "[ ... ]";
|
|
9986
|
+
}
|
|
9987
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
9988
|
+
ConditionalTooltip,
|
|
9989
|
+
{
|
|
9990
|
+
showTooltip: isDisabled,
|
|
9991
|
+
content: "This row is disabled because it contains non-primitive data.",
|
|
9992
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "group/table relative", children: [
|
|
9993
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
9994
|
+
"div",
|
|
9995
|
+
{
|
|
9996
|
+
className: ui.clx("grid grid-cols-2 divide-x", {
|
|
9997
|
+
"overflow-hidden rounded-b-lg": index === fields.length - 1
|
|
9998
|
+
}),
|
|
9999
|
+
children: [
|
|
10000
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10001
|
+
Form$2.Field,
|
|
10002
|
+
{
|
|
10003
|
+
control: form.control,
|
|
10004
|
+
name: `metadata.${index}.key`,
|
|
10005
|
+
render: ({ field: field2 }) => {
|
|
10006
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10007
|
+
GridInput,
|
|
10008
|
+
{
|
|
10009
|
+
"aria-labelledby": METADATA_KEY_LABEL_ID,
|
|
10010
|
+
...field2,
|
|
10011
|
+
disabled: isDisabled,
|
|
10012
|
+
placeholder: "Key"
|
|
10013
|
+
}
|
|
10014
|
+
) }) });
|
|
10015
|
+
}
|
|
10016
|
+
}
|
|
10017
|
+
),
|
|
10018
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10019
|
+
Form$2.Field,
|
|
10020
|
+
{
|
|
10021
|
+
control: form.control,
|
|
10022
|
+
name: `metadata.${index}.value`,
|
|
10023
|
+
render: ({ field: { value, ...field2 } }) => {
|
|
10024
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10025
|
+
GridInput,
|
|
10026
|
+
{
|
|
10027
|
+
"aria-labelledby": METADATA_VALUE_LABEL_ID,
|
|
10028
|
+
...field2,
|
|
10029
|
+
value: isDisabled ? placeholder : value,
|
|
10030
|
+
disabled: isDisabled,
|
|
10031
|
+
placeholder: "Value"
|
|
10032
|
+
}
|
|
10033
|
+
) }) });
|
|
10034
|
+
}
|
|
10035
|
+
}
|
|
10036
|
+
)
|
|
10037
|
+
]
|
|
10038
|
+
}
|
|
10039
|
+
),
|
|
10040
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu, { children: [
|
|
10041
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10042
|
+
ui.DropdownMenu.Trigger,
|
|
10043
|
+
{
|
|
10044
|
+
className: ui.clx(
|
|
10045
|
+
"invisible absolute inset-y-0 -right-2.5 my-auto group-hover/table:visible data-[state='open']:visible",
|
|
10046
|
+
{
|
|
10047
|
+
hidden: isDisabled
|
|
10048
|
+
}
|
|
10049
|
+
),
|
|
10050
|
+
disabled: isDisabled,
|
|
10051
|
+
asChild: true,
|
|
10052
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { size: "2xsmall", children: /* @__PURE__ */ jsxRuntime.jsx(icons.EllipsisVertical, {}) })
|
|
10053
|
+
}
|
|
10054
|
+
),
|
|
10055
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu.Content, { children: [
|
|
10056
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10057
|
+
ui.DropdownMenu.Item,
|
|
10058
|
+
{
|
|
10059
|
+
className: "gap-x-2",
|
|
10060
|
+
onClick: () => insertRow(index, "above"),
|
|
10061
|
+
children: [
|
|
10062
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowUpMini, { className: "text-ui-fg-subtle" }),
|
|
10063
|
+
"Insert row above"
|
|
10064
|
+
]
|
|
10065
|
+
}
|
|
10066
|
+
),
|
|
10067
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10068
|
+
ui.DropdownMenu.Item,
|
|
10069
|
+
{
|
|
10070
|
+
className: "gap-x-2",
|
|
10071
|
+
onClick: () => insertRow(index, "below"),
|
|
10072
|
+
children: [
|
|
10073
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowDownMini, { className: "text-ui-fg-subtle" }),
|
|
10074
|
+
"Insert row below"
|
|
10075
|
+
]
|
|
10076
|
+
}
|
|
10077
|
+
),
|
|
10078
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenu.Separator, {}),
|
|
10079
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10080
|
+
ui.DropdownMenu.Item,
|
|
10081
|
+
{
|
|
10082
|
+
className: "gap-x-2",
|
|
10083
|
+
onClick: () => deleteRow(index),
|
|
10084
|
+
children: [
|
|
10085
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.Trash, { className: "text-ui-fg-subtle" }),
|
|
10086
|
+
"Delete row"
|
|
10087
|
+
]
|
|
10088
|
+
}
|
|
10089
|
+
)
|
|
10090
|
+
] })
|
|
10091
|
+
] })
|
|
10092
|
+
] })
|
|
10093
|
+
},
|
|
10094
|
+
field.id
|
|
10095
|
+
);
|
|
10096
|
+
})
|
|
10097
|
+
] }),
|
|
10098
|
+
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." })
|
|
10099
|
+
] }),
|
|
10100
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
10101
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
10102
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
10103
|
+
] }) })
|
|
10104
|
+
]
|
|
10105
|
+
}
|
|
10106
|
+
) });
|
|
10107
|
+
};
|
|
10108
|
+
const GridInput = React.forwardRef(({ className, ...props }, ref) => {
|
|
10109
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10110
|
+
"input",
|
|
10111
|
+
{
|
|
10112
|
+
ref,
|
|
10113
|
+
...props,
|
|
10114
|
+
autoComplete: "off",
|
|
10115
|
+
className: ui.clx(
|
|
10116
|
+
"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",
|
|
10117
|
+
className
|
|
10118
|
+
)
|
|
10119
|
+
}
|
|
10120
|
+
);
|
|
10121
|
+
});
|
|
10122
|
+
GridInput.displayName = "MetadataForm.GridInput";
|
|
10123
|
+
const PlaceholderInner = () => {
|
|
10124
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
10125
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-[148ox] w-full rounded-lg" }) }),
|
|
10126
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
10127
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" }),
|
|
10128
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" })
|
|
10129
|
+
] }) })
|
|
10130
|
+
] });
|
|
10131
|
+
};
|
|
10132
|
+
const EDITABLE_TYPES = ["string", "number", "boolean"];
|
|
10133
|
+
function getDefaultValues(metadata) {
|
|
10134
|
+
if (!metadata || !Object.keys(metadata).length) {
|
|
10135
|
+
return [
|
|
10136
|
+
{
|
|
10137
|
+
key: "",
|
|
10138
|
+
value: "",
|
|
10139
|
+
disabled: false
|
|
10140
|
+
}
|
|
10141
|
+
];
|
|
10142
|
+
}
|
|
10143
|
+
return Object.entries(metadata).map(([key, value]) => {
|
|
10144
|
+
if (!EDITABLE_TYPES.includes(typeof value)) {
|
|
10145
|
+
return {
|
|
10146
|
+
key,
|
|
10147
|
+
value,
|
|
10148
|
+
disabled: true
|
|
10149
|
+
};
|
|
10150
|
+
}
|
|
10151
|
+
let stringValue = value;
|
|
10152
|
+
if (typeof value !== "string") {
|
|
10153
|
+
stringValue = JSON.stringify(value);
|
|
10154
|
+
}
|
|
10155
|
+
return {
|
|
10156
|
+
key,
|
|
10157
|
+
value: stringValue,
|
|
10158
|
+
original_key: key
|
|
10159
|
+
};
|
|
10160
|
+
});
|
|
10161
|
+
}
|
|
10162
|
+
function parseValues(values) {
|
|
10163
|
+
const metadata = values.metadata;
|
|
10164
|
+
const isEmpty = !metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value;
|
|
10165
|
+
if (isEmpty) {
|
|
10166
|
+
return null;
|
|
10167
|
+
}
|
|
10168
|
+
const update = {};
|
|
10169
|
+
metadata.forEach((field) => {
|
|
10170
|
+
let key = field.key;
|
|
10171
|
+
let value = field.value;
|
|
10172
|
+
const disabled = field.disabled;
|
|
10173
|
+
if (!key || !value) {
|
|
10174
|
+
return;
|
|
10175
|
+
}
|
|
10176
|
+
if (disabled) {
|
|
10177
|
+
update[key] = value;
|
|
10178
|
+
return;
|
|
10179
|
+
}
|
|
10180
|
+
key = key.trim();
|
|
10181
|
+
value = value.trim();
|
|
10182
|
+
if (value === "true") {
|
|
10183
|
+
update[key] = true;
|
|
10184
|
+
} else if (value === "false") {
|
|
10185
|
+
update[key] = false;
|
|
10186
|
+
} else {
|
|
10187
|
+
const parsedNumber = parseFloat(value);
|
|
10188
|
+
if (!isNaN(parsedNumber)) {
|
|
10189
|
+
update[key] = parsedNumber;
|
|
10190
|
+
} else {
|
|
10191
|
+
update[key] = value;
|
|
10192
|
+
}
|
|
10193
|
+
}
|
|
10194
|
+
});
|
|
10195
|
+
return update;
|
|
10196
|
+
}
|
|
10197
|
+
function getHasUneditableRows(metadata) {
|
|
10198
|
+
if (!metadata) {
|
|
10199
|
+
return false;
|
|
10200
|
+
}
|
|
10201
|
+
return Object.values(metadata).some(
|
|
10202
|
+
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
10203
|
+
);
|
|
10204
|
+
}
|
|
10205
|
+
const NumberInput = React.forwardRef(
|
|
10206
|
+
({
|
|
10207
|
+
value,
|
|
10208
|
+
onChange,
|
|
10209
|
+
size = "base",
|
|
10210
|
+
min = 0,
|
|
10211
|
+
max = 100,
|
|
10212
|
+
step = 1,
|
|
10213
|
+
className,
|
|
10214
|
+
disabled,
|
|
10215
|
+
...props
|
|
10216
|
+
}, ref) => {
|
|
10217
|
+
const handleChange = (event) => {
|
|
10218
|
+
const newValue = event.target.value === "" ? min : Number(event.target.value);
|
|
10219
|
+
if (!isNaN(newValue) && (max === void 0 || newValue <= max) && (min === void 0 || newValue >= min)) {
|
|
10220
|
+
onChange(newValue);
|
|
10221
|
+
}
|
|
10222
|
+
};
|
|
10223
|
+
const handleIncrement = () => {
|
|
10224
|
+
const newValue = value + step;
|
|
10225
|
+
if (max === void 0 || newValue <= max) {
|
|
10226
|
+
onChange(newValue);
|
|
10227
|
+
}
|
|
10228
|
+
};
|
|
10229
|
+
const handleDecrement = () => {
|
|
10230
|
+
const newValue = value - step;
|
|
10231
|
+
if (min === void 0 || newValue >= min) {
|
|
10232
|
+
onChange(newValue);
|
|
10233
|
+
}
|
|
10234
|
+
};
|
|
10235
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10236
|
+
"div",
|
|
10237
|
+
{
|
|
10238
|
+
className: ui.clx(
|
|
10239
|
+
"inline-flex rounded-md bg-ui-bg-field shadow-borders-base overflow-hidden divide-x transition-fg",
|
|
10240
|
+
"[&:has(input:focus)]:shadow-borders-interactive-with-active",
|
|
10241
|
+
{
|
|
10242
|
+
"h-7": size === "small",
|
|
10243
|
+
"h-8": size === "base"
|
|
10244
|
+
},
|
|
10245
|
+
className
|
|
10246
|
+
),
|
|
10247
|
+
children: [
|
|
10248
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10249
|
+
"input",
|
|
10250
|
+
{
|
|
10251
|
+
ref,
|
|
10252
|
+
type: "number",
|
|
10253
|
+
value,
|
|
10254
|
+
onChange: handleChange,
|
|
10255
|
+
min,
|
|
10256
|
+
max,
|
|
10257
|
+
step,
|
|
10258
|
+
className: ui.clx(
|
|
10259
|
+
"flex-1 px-2 py-1 bg-transparent txt-compact-small text-ui-fg-base outline-none [appearance:textfield]",
|
|
10260
|
+
"[&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none",
|
|
10261
|
+
"placeholder:text-ui-fg-muted"
|
|
10262
|
+
),
|
|
10263
|
+
...props
|
|
10264
|
+
}
|
|
10265
|
+
),
|
|
10266
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10267
|
+
"button",
|
|
10268
|
+
{
|
|
10269
|
+
className: ui.clx(
|
|
10270
|
+
"flex items-center justify-center outline-none transition-fg",
|
|
10271
|
+
"disabled:cursor-not-allowed disabled:text-ui-fg-muted",
|
|
10272
|
+
"focus:bg-ui-bg-field-component-hover",
|
|
10273
|
+
"hover:bg-ui-bg-field-component-hover",
|
|
10274
|
+
{
|
|
10275
|
+
"size-7": size === "small",
|
|
10276
|
+
"size-8": size === "base"
|
|
10277
|
+
}
|
|
10278
|
+
),
|
|
10279
|
+
type: "button",
|
|
10280
|
+
onClick: handleDecrement,
|
|
10281
|
+
disabled: min !== void 0 && value <= min || disabled,
|
|
10282
|
+
children: [
|
|
10283
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.Minus, {}),
|
|
10284
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: `Decrease by ${step}` })
|
|
10285
|
+
]
|
|
10286
|
+
}
|
|
10287
|
+
),
|
|
10288
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10289
|
+
"button",
|
|
10290
|
+
{
|
|
10291
|
+
className: ui.clx(
|
|
10292
|
+
"flex items-center justify-center outline-none transition-fg",
|
|
10293
|
+
"disabled:cursor-not-allowed disabled:text-ui-fg-muted",
|
|
10294
|
+
"focus:bg-ui-bg-field-hover",
|
|
10295
|
+
"hover:bg-ui-bg-field-hover",
|
|
10296
|
+
{
|
|
10297
|
+
"size-7": size === "small",
|
|
10298
|
+
"size-8": size === "base"
|
|
10299
|
+
}
|
|
10300
|
+
),
|
|
10301
|
+
type: "button",
|
|
10302
|
+
onClick: handleIncrement,
|
|
10303
|
+
disabled: max !== void 0 && value >= max || disabled,
|
|
10304
|
+
children: [
|
|
10305
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.Plus, {}),
|
|
10306
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: `Increase by ${step}` })
|
|
10307
|
+
]
|
|
10308
|
+
}
|
|
10309
|
+
)
|
|
10310
|
+
]
|
|
10311
|
+
}
|
|
10312
|
+
);
|
|
10313
|
+
}
|
|
10314
|
+
);
|
|
10315
|
+
const PRODUCT_VARIANTS_QUERY_KEY = "product-variants";
|
|
10316
|
+
const productVariantsQueryKeys = {
|
|
10317
|
+
list: (query2) => [
|
|
10318
|
+
PRODUCT_VARIANTS_QUERY_KEY,
|
|
10319
|
+
query2 ? query2 : void 0
|
|
10320
|
+
]
|
|
10321
|
+
};
|
|
10322
|
+
const useProductVariants = (query2, options) => {
|
|
10323
|
+
const { data, ...rest } = reactQuery.useQuery({
|
|
10324
|
+
queryKey: productVariantsQueryKeys.list(query2),
|
|
10325
|
+
queryFn: async () => await sdk.admin.productVariant.list(query2),
|
|
10326
|
+
...options
|
|
10327
|
+
});
|
|
10328
|
+
return { ...data, ...rest };
|
|
10329
|
+
};
|
|
10330
|
+
const useCancelOrderEdit = ({ preview }) => {
|
|
10331
|
+
const { mutateAsync: cancelOrderEdit } = useDraftOrderCancelEdit(preview == null ? void 0 : preview.id);
|
|
10332
|
+
const onCancel = React.useCallback(async () => {
|
|
10333
|
+
if (!preview) {
|
|
10334
|
+
return true;
|
|
10335
|
+
}
|
|
10336
|
+
let res = false;
|
|
10337
|
+
await cancelOrderEdit(void 0, {
|
|
10338
|
+
onError: (e) => {
|
|
10339
|
+
ui.toast.error(e.message);
|
|
10340
|
+
},
|
|
10341
|
+
onSuccess: () => {
|
|
10342
|
+
res = true;
|
|
10343
|
+
}
|
|
10344
|
+
});
|
|
10345
|
+
return res;
|
|
10346
|
+
}, [preview, cancelOrderEdit]);
|
|
10347
|
+
return { onCancel };
|
|
10348
|
+
};
|
|
10349
|
+
let IS_REQUEST_RUNNING = false;
|
|
10350
|
+
const useInitiateOrderEdit = ({
|
|
10351
|
+
preview
|
|
10352
|
+
}) => {
|
|
10353
|
+
const navigate = reactRouterDom.useNavigate();
|
|
10354
|
+
const { mutateAsync } = useDraftOrderBeginEdit(preview == null ? void 0 : preview.id);
|
|
10355
|
+
React.useEffect(() => {
|
|
10356
|
+
async function run() {
|
|
10357
|
+
if (IS_REQUEST_RUNNING || !preview) {
|
|
10358
|
+
return;
|
|
10359
|
+
}
|
|
10360
|
+
if (preview.order_change) {
|
|
10361
|
+
return;
|
|
10362
|
+
}
|
|
10363
|
+
IS_REQUEST_RUNNING = true;
|
|
10364
|
+
await mutateAsync(void 0, {
|
|
10365
|
+
onError: (e) => {
|
|
10366
|
+
ui.toast.error(e.message);
|
|
10367
|
+
navigate(`/draft-orders/${preview.id}`, { replace: true });
|
|
10368
|
+
return;
|
|
10369
|
+
}
|
|
10370
|
+
});
|
|
10371
|
+
IS_REQUEST_RUNNING = false;
|
|
10372
|
+
}
|
|
10373
|
+
run();
|
|
10374
|
+
}, [preview, navigate, mutateAsync]);
|
|
10375
|
+
};
|
|
10376
|
+
function convertNumber(value) {
|
|
10377
|
+
return typeof value === "string" ? Number(value.replace(",", ".")) : value;
|
|
10378
|
+
}
|
|
10379
|
+
const STACKED_MODAL_ID = "items_stacked_modal";
|
|
10380
|
+
const Items = () => {
|
|
10381
|
+
const { id } = reactRouterDom.useParams();
|
|
10382
|
+
const {
|
|
10383
|
+
order: preview,
|
|
10384
|
+
isPending: isPreviewPending,
|
|
10385
|
+
isError: isPreviewError,
|
|
10386
|
+
error: previewError
|
|
10387
|
+
} = useOrderPreview(id, void 0, {
|
|
10388
|
+
placeholderData: reactQuery.keepPreviousData
|
|
10389
|
+
});
|
|
10390
|
+
useInitiateOrderEdit({ preview });
|
|
10391
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
10392
|
+
id,
|
|
10393
|
+
{
|
|
10394
|
+
fields: "currency_code"
|
|
10395
|
+
},
|
|
10396
|
+
{
|
|
10397
|
+
enabled: !!id
|
|
10398
|
+
}
|
|
10399
|
+
);
|
|
10400
|
+
const { onCancel } = useCancelOrderEdit({ preview });
|
|
10401
|
+
if (isError) {
|
|
10402
|
+
throw error;
|
|
10403
|
+
}
|
|
10404
|
+
if (isPreviewError) {
|
|
10405
|
+
throw previewError;
|
|
10406
|
+
}
|
|
10407
|
+
const ready = !!preview && !isPreviewPending && !!draft_order && !isPending;
|
|
10408
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: ready ? /* @__PURE__ */ jsxRuntime.jsx(ItemsForm, { preview, currencyCode: draft_order.currency_code }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
10409
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit Items" }) }),
|
|
10410
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
10411
|
+
] }) });
|
|
10412
|
+
};
|
|
10413
|
+
const ItemsForm = ({ preview, currencyCode }) => {
|
|
10414
|
+
var _a;
|
|
10415
|
+
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
10416
|
+
const [modalContent, setModalContent] = React.useState(
|
|
10417
|
+
null
|
|
10418
|
+
);
|
|
10048
10419
|
const { handleSuccess } = useRouteModal();
|
|
10049
10420
|
const { searchValue, onSearchValueChange, query: query2 } = useDebouncedSearch();
|
|
10050
10421
|
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
@@ -10332,151 +10703,9 @@ const VariantItem = ({ item, preview, currencyCode }) => {
|
|
|
10332
10703
|
render: ({ field }) => {
|
|
10333
10704
|
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(NumberInput, { ...field }) }) });
|
|
10334
10705
|
}
|
|
10335
|
-
}
|
|
10336
|
-
) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: item.quantity }) }),
|
|
10337
|
-
editing ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10338
|
-
Form$2.Field,
|
|
10339
|
-
{
|
|
10340
|
-
control: form.control,
|
|
10341
|
-
name: "unit_price",
|
|
10342
|
-
render: ({ field: { onChange, ...field } }) => {
|
|
10343
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10344
|
-
ui.CurrencyInput,
|
|
10345
|
-
{
|
|
10346
|
-
...field,
|
|
10347
|
-
symbol: getNativeSymbol(currencyCode),
|
|
10348
|
-
code: currencyCode,
|
|
10349
|
-
onValueChange: (_value, _name, values) => onChange(values == null ? void 0 : values.value)
|
|
10350
|
-
}
|
|
10351
|
-
) }) });
|
|
10352
|
-
}
|
|
10353
|
-
}
|
|
10354
|
-
) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex w-full flex-1 items-center justify-end", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: getLocaleAmount(item.unit_price, currencyCode) }) }),
|
|
10355
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10356
|
-
ui.IconButton,
|
|
10357
|
-
{
|
|
10358
|
-
type: "button",
|
|
10359
|
-
size: "small",
|
|
10360
|
-
onClick: editing ? onSubmit : () => {
|
|
10361
|
-
setEditing(true);
|
|
10362
|
-
},
|
|
10363
|
-
disabled: isPending,
|
|
10364
|
-
children: editing ? /* @__PURE__ */ jsxRuntime.jsx(icons.Check, {}) : /* @__PURE__ */ jsxRuntime.jsx(icons.PencilSquare, {})
|
|
10365
|
-
}
|
|
10366
|
-
)
|
|
10367
|
-
] }) }) });
|
|
10368
|
-
};
|
|
10369
|
-
const variantItemSchema = objectType({
|
|
10370
|
-
quantity: numberType(),
|
|
10371
|
-
unit_price: unionType([numberType(), stringType()])
|
|
10372
|
-
});
|
|
10373
|
-
const CustomItem = ({ item, preview, currencyCode }) => {
|
|
10374
|
-
const [editing, setEditing] = React.useState(false);
|
|
10375
|
-
const { quantity, unit_price, title } = item;
|
|
10376
|
-
const form = reactHookForm.useForm({
|
|
10377
|
-
defaultValues: {
|
|
10378
|
-
title,
|
|
10379
|
-
quantity,
|
|
10380
|
-
unit_price
|
|
10381
|
-
},
|
|
10382
|
-
resolver: zod.zodResolver(customItemSchema)
|
|
10383
|
-
});
|
|
10384
|
-
React.useEffect(() => {
|
|
10385
|
-
form.reset({
|
|
10386
|
-
title,
|
|
10387
|
-
quantity,
|
|
10388
|
-
unit_price
|
|
10389
|
-
});
|
|
10390
|
-
}, [form, title, quantity, unit_price]);
|
|
10391
|
-
const actionId = React.useMemo(() => {
|
|
10392
|
-
var _a, _b;
|
|
10393
|
-
return (_b = (_a = item.actions) == null ? void 0 : _a.find((a) => a.action === "ITEM_ADD")) == null ? void 0 : _b.id;
|
|
10394
|
-
}, [item]);
|
|
10395
|
-
const { mutateAsync: updateActionItem, isPending: isUpdatingActionItem } = useDraftOrderUpdateActionItem(preview.id);
|
|
10396
|
-
const { mutateAsync: removeActionItem, isPending: isRemovingActionItem } = useDraftOrderRemoveActionItem(preview.id);
|
|
10397
|
-
const { mutateAsync: updateOriginalItem, isPending: isUpdatingOriginalItem } = useDraftOrderUpdateItem(preview.id);
|
|
10398
|
-
const isPending = isUpdatingActionItem || isUpdatingOriginalItem;
|
|
10399
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
10400
|
-
if (convertNumber(data.unit_price) === item.unit_price && data.quantity === item.quantity && data.title === item.title) {
|
|
10401
|
-
setEditing(false);
|
|
10402
|
-
return;
|
|
10403
|
-
}
|
|
10404
|
-
if (!actionId) {
|
|
10405
|
-
await updateOriginalItem(
|
|
10406
|
-
{
|
|
10407
|
-
item_id: item.id,
|
|
10408
|
-
quantity: data.quantity,
|
|
10409
|
-
unit_price: convertNumber(data.unit_price)
|
|
10410
|
-
},
|
|
10411
|
-
{
|
|
10412
|
-
onSuccess: () => {
|
|
10413
|
-
setEditing(false);
|
|
10414
|
-
},
|
|
10415
|
-
onError: (e) => {
|
|
10416
|
-
ui.toast.error(e.message);
|
|
10417
|
-
}
|
|
10418
|
-
}
|
|
10419
|
-
);
|
|
10420
|
-
return;
|
|
10421
|
-
}
|
|
10422
|
-
if (data.quantity === 0) {
|
|
10423
|
-
await removeActionItem(actionId, {
|
|
10424
|
-
onSuccess: () => {
|
|
10425
|
-
setEditing(false);
|
|
10426
|
-
},
|
|
10427
|
-
onError: (e) => {
|
|
10428
|
-
ui.toast.error(e.message);
|
|
10429
|
-
}
|
|
10430
|
-
});
|
|
10431
|
-
return;
|
|
10432
|
-
}
|
|
10433
|
-
await updateActionItem(
|
|
10434
|
-
{
|
|
10435
|
-
action_id: actionId,
|
|
10436
|
-
quantity: data.quantity,
|
|
10437
|
-
unit_price: convertNumber(data.unit_price)
|
|
10438
|
-
},
|
|
10439
|
-
{
|
|
10440
|
-
onSuccess: () => {
|
|
10441
|
-
setEditing(false);
|
|
10442
|
-
},
|
|
10443
|
-
onError: (e) => {
|
|
10444
|
-
ui.toast.error(e.message);
|
|
10445
|
-
}
|
|
10446
|
-
}
|
|
10447
|
-
);
|
|
10448
|
-
});
|
|
10449
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2, { ...form, children: /* @__PURE__ */ jsxRuntime.jsx("form", { onSubmit, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-[minmax(0,2fr)_minmax(0,1fr)_minmax(0,2fr)_28px] items-center gap-3 rounded-lg px-4 py-2", children: [
|
|
10450
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3", children: [
|
|
10451
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10452
|
-
Thumbnail,
|
|
10453
|
-
{
|
|
10454
|
-
thumbnail: item.thumbnail,
|
|
10455
|
-
alt: item.title ?? void 0
|
|
10456
|
-
}
|
|
10457
|
-
),
|
|
10458
|
-
editing ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
10459
|
-
Form$2.Field,
|
|
10460
|
-
{
|
|
10461
|
-
control: form.control,
|
|
10462
|
-
name: "title",
|
|
10463
|
-
render: ({ field }) => {
|
|
10464
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }) });
|
|
10465
|
-
}
|
|
10466
|
-
}
|
|
10467
|
-
) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: item.title })
|
|
10468
|
-
] }),
|
|
10469
|
-
editing ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
10470
|
-
Form$2.Field,
|
|
10471
|
-
{
|
|
10472
|
-
control: form.control,
|
|
10473
|
-
name: "quantity",
|
|
10474
|
-
render: ({ field }) => {
|
|
10475
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(NumberInput, { ...field }) }) });
|
|
10476
|
-
}
|
|
10477
|
-
}
|
|
10478
|
-
) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: item.quantity }),
|
|
10479
|
-
editing ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
10706
|
+
}
|
|
10707
|
+
) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: item.quantity }) }),
|
|
10708
|
+
editing ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10480
10709
|
Form$2.Field,
|
|
10481
10710
|
{
|
|
10482
10711
|
control: form.control,
|
|
@@ -10493,7 +10722,7 @@ const CustomItem = ({ item, preview, currencyCode }) => {
|
|
|
10493
10722
|
) }) });
|
|
10494
10723
|
}
|
|
10495
10724
|
}
|
|
10496
|
-
) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 items-center justify-end", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: getLocaleAmount(item.unit_price, currencyCode) }) }),
|
|
10725
|
+
) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex w-full flex-1 items-center justify-end", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: getLocaleAmount(item.unit_price, currencyCode) }) }),
|
|
10497
10726
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10498
10727
|
ui.IconButton,
|
|
10499
10728
|
{
|
|
@@ -10508,215 +10737,79 @@ const CustomItem = ({ item, preview, currencyCode }) => {
|
|
|
10508
10737
|
)
|
|
10509
10738
|
] }) }) });
|
|
10510
10739
|
};
|
|
10511
|
-
const
|
|
10512
|
-
|
|
10513
|
-
|
|
10514
|
-
})
|
|
10515
|
-
|
|
10516
|
-
const
|
|
10517
|
-
|
|
10518
|
-
|
|
10519
|
-
|
|
10520
|
-
|
|
10521
|
-
|
|
10522
|
-
|
|
10523
|
-
|
|
10524
|
-
|
|
10525
|
-
|
|
10526
|
-
const [rowSelection, setRowSelection] = React.useState(
|
|
10527
|
-
items.reduce((acc, item) => {
|
|
10528
|
-
acc[item.variant_id] = true;
|
|
10529
|
-
return acc;
|
|
10530
|
-
}, {})
|
|
10531
|
-
);
|
|
10740
|
+
const variantItemSchema = objectType({
|
|
10741
|
+
quantity: numberType(),
|
|
10742
|
+
unit_price: unionType([numberType(), stringType()])
|
|
10743
|
+
});
|
|
10744
|
+
const CustomItem = ({ item, preview, currencyCode }) => {
|
|
10745
|
+
const [editing, setEditing] = React.useState(false);
|
|
10746
|
+
const { quantity, unit_price, title } = item;
|
|
10747
|
+
const form = reactHookForm.useForm({
|
|
10748
|
+
defaultValues: {
|
|
10749
|
+
title,
|
|
10750
|
+
quantity,
|
|
10751
|
+
unit_price
|
|
10752
|
+
},
|
|
10753
|
+
resolver: zod.zodResolver(customItemSchema)
|
|
10754
|
+
});
|
|
10532
10755
|
React.useEffect(() => {
|
|
10533
|
-
|
|
10534
|
-
|
|
10535
|
-
|
|
10536
|
-
|
|
10756
|
+
form.reset({
|
|
10757
|
+
title,
|
|
10758
|
+
quantity,
|
|
10759
|
+
unit_price
|
|
10760
|
+
});
|
|
10761
|
+
}, [form, title, quantity, unit_price]);
|
|
10762
|
+
const actionId = React.useMemo(() => {
|
|
10763
|
+
var _a, _b;
|
|
10764
|
+
return (_b = (_a = item.actions) == null ? void 0 : _a.find((a) => a.action === "ITEM_ADD")) == null ? void 0 : _b.id;
|
|
10765
|
+
}, [item]);
|
|
10766
|
+
const { mutateAsync: updateActionItem, isPending: isUpdatingActionItem } = useDraftOrderUpdateActionItem(preview.id);
|
|
10767
|
+
const { mutateAsync: removeActionItem, isPending: isRemovingActionItem } = useDraftOrderRemoveActionItem(preview.id);
|
|
10768
|
+
const { mutateAsync: updateOriginalItem, isPending: isUpdatingOriginalItem } = useDraftOrderUpdateItem(preview.id);
|
|
10769
|
+
const isPending = isUpdatingActionItem || isUpdatingOriginalItem;
|
|
10770
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
10771
|
+
if (convertNumber(data.unit_price) === item.unit_price && data.quantity === item.quantity && data.title === item.title) {
|
|
10772
|
+
setEditing(false);
|
|
10773
|
+
return;
|
|
10774
|
+
}
|
|
10775
|
+
if (!actionId) {
|
|
10776
|
+
await updateOriginalItem(
|
|
10777
|
+
{
|
|
10778
|
+
item_id: item.id,
|
|
10779
|
+
quantity: data.quantity,
|
|
10780
|
+
unit_price: convertNumber(data.unit_price)
|
|
10781
|
+
},
|
|
10782
|
+
{
|
|
10783
|
+
onSuccess: () => {
|
|
10784
|
+
setEditing(false);
|
|
10785
|
+
},
|
|
10786
|
+
onError: (e) => {
|
|
10787
|
+
ui.toast.error(e.message);
|
|
10788
|
+
}
|
|
10537
10789
|
}
|
|
10538
|
-
|
|
10539
|
-
|
|
10540
|
-
);
|
|
10541
|
-
}, [items]);
|
|
10542
|
-
const { q, order, offset } = useQueryParams(
|
|
10543
|
-
["q", "order", "offset"],
|
|
10544
|
-
VARIANT_PREFIX
|
|
10545
|
-
);
|
|
10546
|
-
const { variants, count, isPending, isError, error } = useProductVariants(
|
|
10547
|
-
{
|
|
10548
|
-
q,
|
|
10549
|
-
order,
|
|
10550
|
-
offset: offset ? parseInt(offset) : void 0,
|
|
10551
|
-
limit: LIMIT
|
|
10552
|
-
},
|
|
10553
|
-
{
|
|
10554
|
-
placeholderData: reactQuery.keepPreviousData
|
|
10790
|
+
);
|
|
10791
|
+
return;
|
|
10555
10792
|
}
|
|
10556
|
-
|
|
10557
|
-
|
|
10558
|
-
const { mutateAsync } = useDraftOrderAddItems(orderId);
|
|
10559
|
-
const onSubmit = async () => {
|
|
10560
|
-
const ids = Object.keys(rowSelection).filter(
|
|
10561
|
-
(id) => !items.find((i) => i.variant_id === id)
|
|
10562
|
-
);
|
|
10563
|
-
await mutateAsync(
|
|
10564
|
-
{
|
|
10565
|
-
items: ids.map((id) => ({
|
|
10566
|
-
variant_id: id,
|
|
10567
|
-
quantity: 1
|
|
10568
|
-
}))
|
|
10569
|
-
},
|
|
10570
|
-
{
|
|
10793
|
+
if (data.quantity === 0) {
|
|
10794
|
+
await removeActionItem(actionId, {
|
|
10571
10795
|
onSuccess: () => {
|
|
10572
|
-
|
|
10573
|
-
setIsOpen(STACKED_MODAL_ID, false);
|
|
10796
|
+
setEditing(false);
|
|
10574
10797
|
},
|
|
10575
10798
|
onError: (e) => {
|
|
10576
10799
|
ui.toast.error(e.message);
|
|
10577
10800
|
}
|
|
10578
|
-
}
|
|
10579
|
-
|
|
10580
|
-
|
|
10581
|
-
|
|
10582
|
-
|
|
10583
|
-
|
|
10584
|
-
|
|
10585
|
-
|
|
10586
|
-
{
|
|
10587
|
-
onOpenAutoFocus: (e) => {
|
|
10588
|
-
e.preventDefault();
|
|
10589
|
-
const searchInput = document.querySelector(
|
|
10590
|
-
"[data-modal-id='modal-search-input']"
|
|
10591
|
-
);
|
|
10592
|
-
if (searchInput) {
|
|
10593
|
-
searchInput.focus();
|
|
10594
|
-
}
|
|
10595
|
-
},
|
|
10596
|
-
children: [
|
|
10597
|
-
/* @__PURE__ */ jsxRuntime.jsxs(StackedFocusModal.Header, { children: [
|
|
10598
|
-
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Product Variants" }) }),
|
|
10599
|
-
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Choose product variants to add to the order." }) })
|
|
10600
|
-
] }),
|
|
10601
|
-
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Body, { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10602
|
-
DataTable,
|
|
10603
|
-
{
|
|
10604
|
-
data: variants,
|
|
10605
|
-
columns,
|
|
10606
|
-
isLoading: isPending,
|
|
10607
|
-
getRowId: (row) => row.id,
|
|
10608
|
-
rowCount: count,
|
|
10609
|
-
prefix: VARIANT_PREFIX,
|
|
10610
|
-
layout: "fill",
|
|
10611
|
-
rowSelection: {
|
|
10612
|
-
state: rowSelection,
|
|
10613
|
-
onRowSelectionChange: setRowSelection,
|
|
10614
|
-
enableRowSelection: (row) => {
|
|
10615
|
-
return !items.find((i) => i.variant_id === row.original.id);
|
|
10616
|
-
}
|
|
10617
|
-
},
|
|
10618
|
-
autoFocusSearch: true
|
|
10619
|
-
}
|
|
10620
|
-
) }),
|
|
10621
|
-
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
10622
|
-
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
10623
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "button", onClick: onSubmit, children: "Update items" })
|
|
10624
|
-
] }) })
|
|
10625
|
-
]
|
|
10626
|
-
}
|
|
10627
|
-
);
|
|
10628
|
-
};
|
|
10629
|
-
const columnHelper = ui.createDataTableColumnHelper();
|
|
10630
|
-
const useColumns = () => {
|
|
10631
|
-
return React.useMemo(() => {
|
|
10632
|
-
return [
|
|
10633
|
-
columnHelper.select(),
|
|
10634
|
-
columnHelper.accessor("product.title", {
|
|
10635
|
-
header: "Product",
|
|
10636
|
-
cell: ({ row }) => {
|
|
10637
|
-
var _a, _b, _c;
|
|
10638
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-2", children: [
|
|
10639
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10640
|
-
Thumbnail,
|
|
10641
|
-
{
|
|
10642
|
-
thumbnail: (_a = row.original.product) == null ? void 0 : _a.thumbnail,
|
|
10643
|
-
alt: (_b = row.original.product) == null ? void 0 : _b.title
|
|
10644
|
-
}
|
|
10645
|
-
),
|
|
10646
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: (_c = row.original.product) == null ? void 0 : _c.title })
|
|
10647
|
-
] });
|
|
10648
|
-
},
|
|
10649
|
-
enableSorting: true
|
|
10650
|
-
}),
|
|
10651
|
-
columnHelper.accessor("title", {
|
|
10652
|
-
header: "Variant",
|
|
10653
|
-
enableSorting: true
|
|
10654
|
-
}),
|
|
10655
|
-
columnHelper.accessor("sku", {
|
|
10656
|
-
header: "SKU",
|
|
10657
|
-
cell: ({ getValue }) => {
|
|
10658
|
-
return getValue() ?? "-";
|
|
10659
|
-
},
|
|
10660
|
-
enableSorting: true
|
|
10661
|
-
}),
|
|
10662
|
-
columnHelper.accessor("updated_at", {
|
|
10663
|
-
header: "Updated",
|
|
10664
|
-
cell: ({ getValue }) => {
|
|
10665
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10666
|
-
ui.Tooltip,
|
|
10667
|
-
{
|
|
10668
|
-
content: getFullDate({ date: getValue(), includeTime: true }),
|
|
10669
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: getFullDate({ date: getValue() }) })
|
|
10670
|
-
}
|
|
10671
|
-
);
|
|
10672
|
-
},
|
|
10673
|
-
enableSorting: true,
|
|
10674
|
-
sortAscLabel: "Oldest first",
|
|
10675
|
-
sortDescLabel: "Newest first"
|
|
10676
|
-
}),
|
|
10677
|
-
columnHelper.accessor("created_at", {
|
|
10678
|
-
header: "Created",
|
|
10679
|
-
cell: ({ getValue }) => {
|
|
10680
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10681
|
-
ui.Tooltip,
|
|
10682
|
-
{
|
|
10683
|
-
content: getFullDate({ date: getValue(), includeTime: true }),
|
|
10684
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: getFullDate({ date: getValue() }) })
|
|
10685
|
-
}
|
|
10686
|
-
);
|
|
10687
|
-
},
|
|
10688
|
-
enableSorting: true,
|
|
10689
|
-
sortAscLabel: "Oldest first",
|
|
10690
|
-
sortDescLabel: "Newest first"
|
|
10691
|
-
})
|
|
10692
|
-
];
|
|
10693
|
-
}, []);
|
|
10694
|
-
};
|
|
10695
|
-
const CustomItemForm = ({ orderId, currencyCode }) => {
|
|
10696
|
-
const { setIsOpen } = useStackedModal();
|
|
10697
|
-
const { mutateAsync: addItems } = useDraftOrderAddItems(orderId);
|
|
10698
|
-
const form = reactHookForm.useForm({
|
|
10699
|
-
defaultValues: {
|
|
10700
|
-
title: "",
|
|
10701
|
-
quantity: 1,
|
|
10702
|
-
unit_price: ""
|
|
10703
|
-
},
|
|
10704
|
-
resolver: zod.zodResolver(customItemSchema)
|
|
10705
|
-
});
|
|
10706
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
10707
|
-
await addItems(
|
|
10708
|
-
{
|
|
10709
|
-
items: [
|
|
10710
|
-
{
|
|
10711
|
-
title: data.title,
|
|
10712
|
-
quantity: data.quantity,
|
|
10713
|
-
unit_price: convertNumber(data.unit_price)
|
|
10714
|
-
}
|
|
10715
|
-
]
|
|
10801
|
+
});
|
|
10802
|
+
return;
|
|
10803
|
+
}
|
|
10804
|
+
await updateActionItem(
|
|
10805
|
+
{
|
|
10806
|
+
action_id: actionId,
|
|
10807
|
+
quantity: data.quantity,
|
|
10808
|
+
unit_price: convertNumber(data.unit_price)
|
|
10716
10809
|
},
|
|
10717
10810
|
{
|
|
10718
10811
|
onSuccess: () => {
|
|
10719
|
-
|
|
10812
|
+
setEditing(false);
|
|
10720
10813
|
},
|
|
10721
10814
|
onError: (e) => {
|
|
10722
10815
|
ui.toast.error(e.message);
|
|
@@ -10724,437 +10817,365 @@ const CustomItemForm = ({ orderId, currencyCode }) => {
|
|
|
10724
10817
|
}
|
|
10725
10818
|
);
|
|
10726
10819
|
});
|
|
10727
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2, { ...form, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10728
|
-
/* @__PURE__ */ jsxRuntime.
|
|
10729
|
-
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 px-2 py-16", children: [
|
|
10730
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
10731
|
-
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Add custom item" }) }),
|
|
10732
|
-
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Add a custom item to the order. This will add a new line item that is not associated with an existing product." }) })
|
|
10733
|
-
] }),
|
|
10734
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
10820
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2, { ...form, children: /* @__PURE__ */ jsxRuntime.jsx("form", { onSubmit, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-[minmax(0,2fr)_minmax(0,1fr)_minmax(0,2fr)_28px] items-center gap-3 rounded-lg px-4 py-2", children: [
|
|
10821
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-3", children: [
|
|
10735
10822
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10736
|
-
|
|
10823
|
+
Thumbnail,
|
|
10737
10824
|
{
|
|
10738
|
-
|
|
10739
|
-
|
|
10740
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
10741
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
10742
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Title" }),
|
|
10743
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Enter the title of the item" })
|
|
10744
|
-
] }),
|
|
10745
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
10746
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
10747
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
10748
|
-
] })
|
|
10749
|
-
] }) })
|
|
10825
|
+
thumbnail: item.thumbnail,
|
|
10826
|
+
alt: item.title ?? void 0
|
|
10750
10827
|
}
|
|
10751
10828
|
),
|
|
10752
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10753
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10829
|
+
editing ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
10754
10830
|
Form$2.Field,
|
|
10755
10831
|
{
|
|
10756
10832
|
control: form.control,
|
|
10757
|
-
name: "
|
|
10758
|
-
render: ({ field
|
|
10759
|
-
/* @__PURE__ */ jsxRuntime.
|
|
10760
|
-
|
|
10761
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Enter the unit price of the item" })
|
|
10762
|
-
] }),
|
|
10763
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
10764
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10765
|
-
ui.CurrencyInput,
|
|
10766
|
-
{
|
|
10767
|
-
symbol: getNativeSymbol(currencyCode),
|
|
10768
|
-
code: currencyCode,
|
|
10769
|
-
onValueChange: (_value, _name, values) => onChange(values == null ? void 0 : values.value),
|
|
10770
|
-
...field
|
|
10771
|
-
}
|
|
10772
|
-
) }),
|
|
10773
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
10774
|
-
] })
|
|
10775
|
-
] }) })
|
|
10833
|
+
name: "title",
|
|
10834
|
+
render: ({ field }) => {
|
|
10835
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }) });
|
|
10836
|
+
}
|
|
10776
10837
|
}
|
|
10777
|
-
),
|
|
10778
|
-
|
|
10779
|
-
|
|
10780
|
-
|
|
10781
|
-
|
|
10782
|
-
|
|
10783
|
-
|
|
10784
|
-
|
|
10785
|
-
|
|
10786
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Quantity" }),
|
|
10787
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Enter the quantity of the item" })
|
|
10788
|
-
] }),
|
|
10789
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full flex-1", children: [
|
|
10790
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(NumberInput, { ...field, className: "w-full" }) }) }),
|
|
10791
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
10792
|
-
] })
|
|
10793
|
-
] }) })
|
|
10838
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: item.title })
|
|
10839
|
+
] }),
|
|
10840
|
+
editing ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
10841
|
+
Form$2.Field,
|
|
10842
|
+
{
|
|
10843
|
+
control: form.control,
|
|
10844
|
+
name: "quantity",
|
|
10845
|
+
render: ({ field }) => {
|
|
10846
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(NumberInput, { ...field }) }) });
|
|
10794
10847
|
}
|
|
10795
|
-
|
|
10796
|
-
|
|
10797
|
-
|
|
10798
|
-
|
|
10799
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "button", onClick: onSubmit, children: "Add item" })
|
|
10800
|
-
] }) })
|
|
10801
|
-
] }) }) });
|
|
10802
|
-
};
|
|
10803
|
-
const customItemSchema = objectType({
|
|
10804
|
-
title: stringType().min(1),
|
|
10805
|
-
quantity: numberType(),
|
|
10806
|
-
unit_price: unionType([numberType(), stringType()])
|
|
10807
|
-
});
|
|
10808
|
-
const InlineTip = React.forwardRef(
|
|
10809
|
-
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
10810
|
-
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
10811
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10812
|
-
"div",
|
|
10848
|
+
}
|
|
10849
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: item.quantity }),
|
|
10850
|
+
editing ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
10851
|
+
Form$2.Field,
|
|
10813
10852
|
{
|
|
10814
|
-
|
|
10815
|
-
|
|
10816
|
-
|
|
10817
|
-
|
|
10818
|
-
|
|
10819
|
-
...props,
|
|
10820
|
-
children: [
|
|
10821
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10822
|
-
"div",
|
|
10853
|
+
control: form.control,
|
|
10854
|
+
name: "unit_price",
|
|
10855
|
+
render: ({ field: { onChange, ...field } }) => {
|
|
10856
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10857
|
+
ui.CurrencyInput,
|
|
10823
10858
|
{
|
|
10824
|
-
|
|
10825
|
-
|
|
10826
|
-
|
|
10827
|
-
|
|
10859
|
+
...field,
|
|
10860
|
+
symbol: getNativeSymbol(currencyCode),
|
|
10861
|
+
code: currencyCode,
|
|
10862
|
+
onValueChange: (_value, _name, values) => onChange(values == null ? void 0 : values.value)
|
|
10828
10863
|
}
|
|
10829
|
-
)
|
|
10830
|
-
|
|
10831
|
-
/* @__PURE__ */ jsxRuntime.jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
|
|
10832
|
-
labelValue,
|
|
10833
|
-
":"
|
|
10834
|
-
] }),
|
|
10835
|
-
" ",
|
|
10836
|
-
children
|
|
10837
|
-
] })
|
|
10838
|
-
]
|
|
10864
|
+
) }) });
|
|
10865
|
+
}
|
|
10839
10866
|
}
|
|
10840
|
-
)
|
|
10841
|
-
|
|
10842
|
-
|
|
10843
|
-
|
|
10844
|
-
|
|
10845
|
-
|
|
10846
|
-
|
|
10847
|
-
|
|
10848
|
-
}
|
|
10849
|
-
|
|
10850
|
-
|
|
10851
|
-
}
|
|
10852
|
-
|
|
10853
|
-
|
|
10854
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
10855
|
-
fields: "metadata"
|
|
10856
|
-
});
|
|
10857
|
-
if (isError) {
|
|
10858
|
-
throw error;
|
|
10859
|
-
}
|
|
10860
|
-
const isReady = !isPending && !!order;
|
|
10861
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
10862
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
10863
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Metadata" }) }),
|
|
10864
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
|
|
10865
|
-
] }),
|
|
10866
|
-
!isReady ? /* @__PURE__ */ jsxRuntime.jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsxRuntime.jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
|
|
10867
|
-
] });
|
|
10867
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 items-center justify-end", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: getLocaleAmount(item.unit_price, currencyCode) }) }),
|
|
10868
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10869
|
+
ui.IconButton,
|
|
10870
|
+
{
|
|
10871
|
+
type: "button",
|
|
10872
|
+
size: "small",
|
|
10873
|
+
onClick: editing ? onSubmit : () => {
|
|
10874
|
+
setEditing(true);
|
|
10875
|
+
},
|
|
10876
|
+
disabled: isPending,
|
|
10877
|
+
children: editing ? /* @__PURE__ */ jsxRuntime.jsx(icons.Check, {}) : /* @__PURE__ */ jsxRuntime.jsx(icons.PencilSquare, {})
|
|
10878
|
+
}
|
|
10879
|
+
)
|
|
10880
|
+
] }) }) });
|
|
10868
10881
|
};
|
|
10869
|
-
const
|
|
10870
|
-
|
|
10871
|
-
|
|
10872
|
-
|
|
10873
|
-
const
|
|
10874
|
-
const
|
|
10875
|
-
|
|
10876
|
-
|
|
10877
|
-
|
|
10882
|
+
const StackedModalTrigger$1 = ({
|
|
10883
|
+
type,
|
|
10884
|
+
setModalContent
|
|
10885
|
+
}) => {
|
|
10886
|
+
const { setIsOpen } = useStackedModal();
|
|
10887
|
+
const onClick = React.useCallback(() => {
|
|
10888
|
+
setModalContent(type);
|
|
10889
|
+
setIsOpen(STACKED_MODAL_ID, true);
|
|
10890
|
+
}, [setModalContent, setIsOpen, type]);
|
|
10891
|
+
return /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenu.Item, { onClick, children: type === "add-items" ? "Add items" : "Add custom item" }) });
|
|
10892
|
+
};
|
|
10893
|
+
const VARIANT_PREFIX = "items";
|
|
10894
|
+
const LIMIT = 50;
|
|
10895
|
+
const ExistingItemsForm = ({ orderId, items }) => {
|
|
10896
|
+
const { setIsOpen } = useStackedModal();
|
|
10897
|
+
const [rowSelection, setRowSelection] = React.useState(
|
|
10898
|
+
items.reduce((acc, item) => {
|
|
10899
|
+
acc[item.variant_id] = true;
|
|
10900
|
+
return acc;
|
|
10901
|
+
}, {})
|
|
10902
|
+
);
|
|
10903
|
+
React.useEffect(() => {
|
|
10904
|
+
setRowSelection(
|
|
10905
|
+
items.reduce((acc, item) => {
|
|
10906
|
+
if (item.variant_id) {
|
|
10907
|
+
acc[item.variant_id] = true;
|
|
10908
|
+
}
|
|
10909
|
+
return acc;
|
|
10910
|
+
}, {})
|
|
10911
|
+
);
|
|
10912
|
+
}, [items]);
|
|
10913
|
+
const { q, order, offset } = useQueryParams(
|
|
10914
|
+
["q", "order", "offset"],
|
|
10915
|
+
VARIANT_PREFIX
|
|
10916
|
+
);
|
|
10917
|
+
const { variants, count, isPending, isError, error } = useProductVariants(
|
|
10918
|
+
{
|
|
10919
|
+
q,
|
|
10920
|
+
order,
|
|
10921
|
+
offset: offset ? parseInt(offset) : void 0,
|
|
10922
|
+
limit: LIMIT
|
|
10878
10923
|
},
|
|
10879
|
-
|
|
10880
|
-
|
|
10881
|
-
|
|
10882
|
-
|
|
10924
|
+
{
|
|
10925
|
+
placeholderData: reactQuery.keepPreviousData
|
|
10926
|
+
}
|
|
10927
|
+
);
|
|
10928
|
+
const columns = useColumns();
|
|
10929
|
+
const { mutateAsync } = useDraftOrderAddItems(orderId);
|
|
10930
|
+
const onSubmit = async () => {
|
|
10931
|
+
const ids = Object.keys(rowSelection).filter(
|
|
10932
|
+
(id) => !items.find((i) => i.variant_id === id)
|
|
10933
|
+
);
|
|
10883
10934
|
await mutateAsync(
|
|
10884
10935
|
{
|
|
10885
|
-
|
|
10936
|
+
items: ids.map((id) => ({
|
|
10937
|
+
variant_id: id,
|
|
10938
|
+
quantity: 1
|
|
10939
|
+
}))
|
|
10886
10940
|
},
|
|
10887
10941
|
{
|
|
10888
10942
|
onSuccess: () => {
|
|
10889
|
-
|
|
10890
|
-
|
|
10943
|
+
setRowSelection({});
|
|
10944
|
+
setIsOpen(STACKED_MODAL_ID, false);
|
|
10891
10945
|
},
|
|
10892
|
-
onError: (
|
|
10893
|
-
ui.toast.error(
|
|
10946
|
+
onError: (e) => {
|
|
10947
|
+
ui.toast.error(e.message);
|
|
10894
10948
|
}
|
|
10895
10949
|
}
|
|
10896
10950
|
);
|
|
10897
|
-
}
|
|
10898
|
-
|
|
10899
|
-
|
|
10900
|
-
name: "metadata"
|
|
10901
|
-
});
|
|
10902
|
-
function deleteRow(index) {
|
|
10903
|
-
remove(index);
|
|
10904
|
-
if (fields.length === 1) {
|
|
10905
|
-
insert(0, {
|
|
10906
|
-
key: "",
|
|
10907
|
-
value: "",
|
|
10908
|
-
disabled: false
|
|
10909
|
-
});
|
|
10910
|
-
}
|
|
10911
|
-
}
|
|
10912
|
-
function insertRow(index, position) {
|
|
10913
|
-
insert(index + (position === "above" ? 0 : 1), {
|
|
10914
|
-
key: "",
|
|
10915
|
-
value: "",
|
|
10916
|
-
disabled: false
|
|
10917
|
-
});
|
|
10951
|
+
};
|
|
10952
|
+
if (isError) {
|
|
10953
|
+
throw error;
|
|
10918
10954
|
}
|
|
10919
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
10920
|
-
|
|
10955
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10956
|
+
StackedFocusModal.Content,
|
|
10921
10957
|
{
|
|
10922
|
-
|
|
10923
|
-
|
|
10958
|
+
onOpenAutoFocus: (e) => {
|
|
10959
|
+
e.preventDefault();
|
|
10960
|
+
const searchInput = document.querySelector(
|
|
10961
|
+
"[data-modal-id='modal-search-input']"
|
|
10962
|
+
);
|
|
10963
|
+
if (searchInput) {
|
|
10964
|
+
searchInput.focus();
|
|
10965
|
+
}
|
|
10966
|
+
},
|
|
10924
10967
|
children: [
|
|
10925
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10926
|
-
/* @__PURE__ */ jsxRuntime.
|
|
10927
|
-
|
|
10928
|
-
/* @__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" }) }),
|
|
10929
|
-
/* @__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" }) })
|
|
10930
|
-
] }),
|
|
10931
|
-
fields.map((field, index) => {
|
|
10932
|
-
const isDisabled = field.disabled || false;
|
|
10933
|
-
let placeholder = "-";
|
|
10934
|
-
if (typeof field.value === "object") {
|
|
10935
|
-
placeholder = "{ ... }";
|
|
10936
|
-
}
|
|
10937
|
-
if (Array.isArray(field.value)) {
|
|
10938
|
-
placeholder = "[ ... ]";
|
|
10939
|
-
}
|
|
10940
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10941
|
-
ConditionalTooltip,
|
|
10942
|
-
{
|
|
10943
|
-
showTooltip: isDisabled,
|
|
10944
|
-
content: "This row is disabled because it contains non-primitive data.",
|
|
10945
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "group/table relative", children: [
|
|
10946
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10947
|
-
"div",
|
|
10948
|
-
{
|
|
10949
|
-
className: ui.clx("grid grid-cols-2 divide-x", {
|
|
10950
|
-
"overflow-hidden rounded-b-lg": index === fields.length - 1
|
|
10951
|
-
}),
|
|
10952
|
-
children: [
|
|
10953
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10954
|
-
Form$2.Field,
|
|
10955
|
-
{
|
|
10956
|
-
control: form.control,
|
|
10957
|
-
name: `metadata.${index}.key`,
|
|
10958
|
-
render: ({ field: field2 }) => {
|
|
10959
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10960
|
-
GridInput,
|
|
10961
|
-
{
|
|
10962
|
-
"aria-labelledby": METADATA_KEY_LABEL_ID,
|
|
10963
|
-
...field2,
|
|
10964
|
-
disabled: isDisabled,
|
|
10965
|
-
placeholder: "Key"
|
|
10966
|
-
}
|
|
10967
|
-
) }) });
|
|
10968
|
-
}
|
|
10969
|
-
}
|
|
10970
|
-
),
|
|
10971
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10972
|
-
Form$2.Field,
|
|
10973
|
-
{
|
|
10974
|
-
control: form.control,
|
|
10975
|
-
name: `metadata.${index}.value`,
|
|
10976
|
-
render: ({ field: { value, ...field2 } }) => {
|
|
10977
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10978
|
-
GridInput,
|
|
10979
|
-
{
|
|
10980
|
-
"aria-labelledby": METADATA_VALUE_LABEL_ID,
|
|
10981
|
-
...field2,
|
|
10982
|
-
value: isDisabled ? placeholder : value,
|
|
10983
|
-
disabled: isDisabled,
|
|
10984
|
-
placeholder: "Value"
|
|
10985
|
-
}
|
|
10986
|
-
) }) });
|
|
10987
|
-
}
|
|
10988
|
-
}
|
|
10989
|
-
)
|
|
10990
|
-
]
|
|
10991
|
-
}
|
|
10992
|
-
),
|
|
10993
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu, { children: [
|
|
10994
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10995
|
-
ui.DropdownMenu.Trigger,
|
|
10996
|
-
{
|
|
10997
|
-
className: ui.clx(
|
|
10998
|
-
"invisible absolute inset-y-0 -right-2.5 my-auto group-hover/table:visible data-[state='open']:visible",
|
|
10999
|
-
{
|
|
11000
|
-
hidden: isDisabled
|
|
11001
|
-
}
|
|
11002
|
-
),
|
|
11003
|
-
disabled: isDisabled,
|
|
11004
|
-
asChild: true,
|
|
11005
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { size: "2xsmall", children: /* @__PURE__ */ jsxRuntime.jsx(icons.EllipsisVertical, {}) })
|
|
11006
|
-
}
|
|
11007
|
-
),
|
|
11008
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu.Content, { children: [
|
|
11009
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
11010
|
-
ui.DropdownMenu.Item,
|
|
11011
|
-
{
|
|
11012
|
-
className: "gap-x-2",
|
|
11013
|
-
onClick: () => insertRow(index, "above"),
|
|
11014
|
-
children: [
|
|
11015
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowUpMini, { className: "text-ui-fg-subtle" }),
|
|
11016
|
-
"Insert row above"
|
|
11017
|
-
]
|
|
11018
|
-
}
|
|
11019
|
-
),
|
|
11020
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
11021
|
-
ui.DropdownMenu.Item,
|
|
11022
|
-
{
|
|
11023
|
-
className: "gap-x-2",
|
|
11024
|
-
onClick: () => insertRow(index, "below"),
|
|
11025
|
-
children: [
|
|
11026
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowDownMini, { className: "text-ui-fg-subtle" }),
|
|
11027
|
-
"Insert row below"
|
|
11028
|
-
]
|
|
11029
|
-
}
|
|
11030
|
-
),
|
|
11031
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenu.Separator, {}),
|
|
11032
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
11033
|
-
ui.DropdownMenu.Item,
|
|
11034
|
-
{
|
|
11035
|
-
className: "gap-x-2",
|
|
11036
|
-
onClick: () => deleteRow(index),
|
|
11037
|
-
children: [
|
|
11038
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.Trash, { className: "text-ui-fg-subtle" }),
|
|
11039
|
-
"Delete row"
|
|
11040
|
-
]
|
|
11041
|
-
}
|
|
11042
|
-
)
|
|
11043
|
-
] })
|
|
11044
|
-
] })
|
|
11045
|
-
] })
|
|
11046
|
-
},
|
|
11047
|
-
field.id
|
|
11048
|
-
);
|
|
11049
|
-
})
|
|
11050
|
-
] }),
|
|
11051
|
-
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." })
|
|
10968
|
+
/* @__PURE__ */ jsxRuntime.jsxs(StackedFocusModal.Header, { children: [
|
|
10969
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Product Variants" }) }),
|
|
10970
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Choose product variants to add to the order." }) })
|
|
11052
10971
|
] }),
|
|
11053
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11054
|
-
|
|
11055
|
-
|
|
10972
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Body, { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10973
|
+
DataTable,
|
|
10974
|
+
{
|
|
10975
|
+
data: variants,
|
|
10976
|
+
columns,
|
|
10977
|
+
isLoading: isPending,
|
|
10978
|
+
getRowId: (row) => row.id,
|
|
10979
|
+
rowCount: count,
|
|
10980
|
+
prefix: VARIANT_PREFIX,
|
|
10981
|
+
layout: "fill",
|
|
10982
|
+
rowSelection: {
|
|
10983
|
+
state: rowSelection,
|
|
10984
|
+
onRowSelectionChange: setRowSelection,
|
|
10985
|
+
enableRowSelection: (row) => {
|
|
10986
|
+
return !items.find((i) => i.variant_id === row.original.id);
|
|
10987
|
+
}
|
|
10988
|
+
},
|
|
10989
|
+
autoFocusSearch: true
|
|
10990
|
+
}
|
|
10991
|
+
) }),
|
|
10992
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
10993
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
10994
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "button", onClick: onSubmit, children: "Update items" })
|
|
11056
10995
|
] }) })
|
|
11057
10996
|
]
|
|
11058
10997
|
}
|
|
11059
|
-
) });
|
|
11060
|
-
};
|
|
11061
|
-
const GridInput = React.forwardRef(({ className, ...props }, ref) => {
|
|
11062
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11063
|
-
"input",
|
|
11064
|
-
{
|
|
11065
|
-
ref,
|
|
11066
|
-
...props,
|
|
11067
|
-
autoComplete: "off",
|
|
11068
|
-
className: ui.clx(
|
|
11069
|
-
"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",
|
|
11070
|
-
className
|
|
11071
|
-
)
|
|
11072
|
-
}
|
|
11073
10998
|
);
|
|
11074
|
-
});
|
|
11075
|
-
GridInput.displayName = "MetadataForm.GridInput";
|
|
11076
|
-
const PlaceholderInner = () => {
|
|
11077
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
11078
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-[148ox] w-full rounded-lg" }) }),
|
|
11079
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
11080
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" }),
|
|
11081
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" })
|
|
11082
|
-
] }) })
|
|
11083
|
-
] });
|
|
11084
10999
|
};
|
|
11085
|
-
const
|
|
11086
|
-
|
|
11087
|
-
|
|
11000
|
+
const columnHelper = ui.createDataTableColumnHelper();
|
|
11001
|
+
const useColumns = () => {
|
|
11002
|
+
return React.useMemo(() => {
|
|
11088
11003
|
return [
|
|
11089
|
-
|
|
11090
|
-
|
|
11091
|
-
|
|
11092
|
-
|
|
11093
|
-
|
|
11004
|
+
columnHelper.select(),
|
|
11005
|
+
columnHelper.accessor("product.title", {
|
|
11006
|
+
header: "Product",
|
|
11007
|
+
cell: ({ row }) => {
|
|
11008
|
+
var _a, _b, _c;
|
|
11009
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-2", children: [
|
|
11010
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11011
|
+
Thumbnail,
|
|
11012
|
+
{
|
|
11013
|
+
thumbnail: (_a = row.original.product) == null ? void 0 : _a.thumbnail,
|
|
11014
|
+
alt: (_b = row.original.product) == null ? void 0 : _b.title
|
|
11015
|
+
}
|
|
11016
|
+
),
|
|
11017
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: (_c = row.original.product) == null ? void 0 : _c.title })
|
|
11018
|
+
] });
|
|
11019
|
+
},
|
|
11020
|
+
enableSorting: true
|
|
11021
|
+
}),
|
|
11022
|
+
columnHelper.accessor("title", {
|
|
11023
|
+
header: "Variant",
|
|
11024
|
+
enableSorting: true
|
|
11025
|
+
}),
|
|
11026
|
+
columnHelper.accessor("sku", {
|
|
11027
|
+
header: "SKU",
|
|
11028
|
+
cell: ({ getValue }) => {
|
|
11029
|
+
return getValue() ?? "-";
|
|
11030
|
+
},
|
|
11031
|
+
enableSorting: true
|
|
11032
|
+
}),
|
|
11033
|
+
columnHelper.accessor("updated_at", {
|
|
11034
|
+
header: "Updated",
|
|
11035
|
+
cell: ({ getValue }) => {
|
|
11036
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11037
|
+
ui.Tooltip,
|
|
11038
|
+
{
|
|
11039
|
+
content: getFullDate({ date: getValue(), includeTime: true }),
|
|
11040
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: getFullDate({ date: getValue() }) })
|
|
11041
|
+
}
|
|
11042
|
+
);
|
|
11043
|
+
},
|
|
11044
|
+
enableSorting: true,
|
|
11045
|
+
sortAscLabel: "Oldest first",
|
|
11046
|
+
sortDescLabel: "Newest first"
|
|
11047
|
+
}),
|
|
11048
|
+
columnHelper.accessor("created_at", {
|
|
11049
|
+
header: "Created",
|
|
11050
|
+
cell: ({ getValue }) => {
|
|
11051
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11052
|
+
ui.Tooltip,
|
|
11053
|
+
{
|
|
11054
|
+
content: getFullDate({ date: getValue(), includeTime: true }),
|
|
11055
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: getFullDate({ date: getValue() }) })
|
|
11056
|
+
}
|
|
11057
|
+
);
|
|
11058
|
+
},
|
|
11059
|
+
enableSorting: true,
|
|
11060
|
+
sortAscLabel: "Oldest first",
|
|
11061
|
+
sortDescLabel: "Newest first"
|
|
11062
|
+
})
|
|
11094
11063
|
];
|
|
11095
|
-
}
|
|
11096
|
-
|
|
11097
|
-
|
|
11098
|
-
|
|
11099
|
-
|
|
11100
|
-
|
|
11101
|
-
|
|
11102
|
-
|
|
11103
|
-
|
|
11104
|
-
|
|
11105
|
-
|
|
11106
|
-
|
|
11107
|
-
}
|
|
11108
|
-
return {
|
|
11109
|
-
key,
|
|
11110
|
-
value: stringValue,
|
|
11111
|
-
original_key: key
|
|
11112
|
-
};
|
|
11064
|
+
}, []);
|
|
11065
|
+
};
|
|
11066
|
+
const CustomItemForm = ({ orderId, currencyCode }) => {
|
|
11067
|
+
const { setIsOpen } = useStackedModal();
|
|
11068
|
+
const { mutateAsync: addItems } = useDraftOrderAddItems(orderId);
|
|
11069
|
+
const form = reactHookForm.useForm({
|
|
11070
|
+
defaultValues: {
|
|
11071
|
+
title: "",
|
|
11072
|
+
quantity: 1,
|
|
11073
|
+
unit_price: ""
|
|
11074
|
+
},
|
|
11075
|
+
resolver: zod.zodResolver(customItemSchema)
|
|
11113
11076
|
});
|
|
11114
|
-
|
|
11115
|
-
|
|
11116
|
-
|
|
11117
|
-
|
|
11118
|
-
|
|
11119
|
-
|
|
11120
|
-
|
|
11121
|
-
|
|
11122
|
-
|
|
11123
|
-
|
|
11124
|
-
|
|
11125
|
-
|
|
11126
|
-
|
|
11127
|
-
|
|
11128
|
-
|
|
11129
|
-
|
|
11130
|
-
|
|
11131
|
-
|
|
11132
|
-
}
|
|
11133
|
-
key = key.trim();
|
|
11134
|
-
value = value.trim();
|
|
11135
|
-
if (value === "true") {
|
|
11136
|
-
update[key] = true;
|
|
11137
|
-
} else if (value === "false") {
|
|
11138
|
-
update[key] = false;
|
|
11139
|
-
} else {
|
|
11140
|
-
const parsedNumber = parseFloat(value);
|
|
11141
|
-
if (!isNaN(parsedNumber)) {
|
|
11142
|
-
update[key] = parsedNumber;
|
|
11143
|
-
} else {
|
|
11144
|
-
update[key] = value;
|
|
11077
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11078
|
+
await addItems(
|
|
11079
|
+
{
|
|
11080
|
+
items: [
|
|
11081
|
+
{
|
|
11082
|
+
title: data.title,
|
|
11083
|
+
quantity: data.quantity,
|
|
11084
|
+
unit_price: convertNumber(data.unit_price)
|
|
11085
|
+
}
|
|
11086
|
+
]
|
|
11087
|
+
},
|
|
11088
|
+
{
|
|
11089
|
+
onSuccess: () => {
|
|
11090
|
+
setIsOpen(STACKED_MODAL_ID, false);
|
|
11091
|
+
},
|
|
11092
|
+
onError: (e) => {
|
|
11093
|
+
ui.toast.error(e.message);
|
|
11094
|
+
}
|
|
11145
11095
|
}
|
|
11146
|
-
|
|
11096
|
+
);
|
|
11147
11097
|
});
|
|
11148
|
-
return
|
|
11149
|
-
}
|
|
11150
|
-
|
|
11151
|
-
|
|
11152
|
-
|
|
11153
|
-
|
|
11154
|
-
|
|
11155
|
-
|
|
11156
|
-
|
|
11157
|
-
|
|
11098
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Form$2, { ...form, children: /* @__PURE__ */ jsxRuntime.jsx(KeyboundForm, { onSubmit, children: /* @__PURE__ */ jsxRuntime.jsxs(StackedFocusModal.Content, { children: [
|
|
11099
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Header, {}),
|
|
11100
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 px-2 py-16", children: [
|
|
11101
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11102
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Add custom item" }) }),
|
|
11103
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Add a custom item to the order. This will add a new line item that is not associated with an existing product." }) })
|
|
11104
|
+
] }),
|
|
11105
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
11106
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11107
|
+
Form$2.Field,
|
|
11108
|
+
{
|
|
11109
|
+
control: form.control,
|
|
11110
|
+
name: "title",
|
|
11111
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
11112
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11113
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Title" }),
|
|
11114
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Enter the title of the item" })
|
|
11115
|
+
] }),
|
|
11116
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11117
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11118
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11119
|
+
] })
|
|
11120
|
+
] }) })
|
|
11121
|
+
}
|
|
11122
|
+
),
|
|
11123
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
11124
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11125
|
+
Form$2.Field,
|
|
11126
|
+
{
|
|
11127
|
+
control: form.control,
|
|
11128
|
+
name: "unit_price",
|
|
11129
|
+
render: ({ field: { onChange, ...field } }) => /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
11130
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11131
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Unit price" }),
|
|
11132
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Enter the unit price of the item" })
|
|
11133
|
+
] }),
|
|
11134
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11135
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11136
|
+
ui.CurrencyInput,
|
|
11137
|
+
{
|
|
11138
|
+
symbol: getNativeSymbol(currencyCode),
|
|
11139
|
+
code: currencyCode,
|
|
11140
|
+
onValueChange: (_value, _name, values) => onChange(values == null ? void 0 : values.value),
|
|
11141
|
+
...field
|
|
11142
|
+
}
|
|
11143
|
+
) }),
|
|
11144
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11145
|
+
] })
|
|
11146
|
+
] }) })
|
|
11147
|
+
}
|
|
11148
|
+
),
|
|
11149
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
11150
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11151
|
+
Form$2.Field,
|
|
11152
|
+
{
|
|
11153
|
+
control: form.control,
|
|
11154
|
+
name: "quantity",
|
|
11155
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
11156
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11157
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Quantity" }),
|
|
11158
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Enter the quantity of the item" })
|
|
11159
|
+
] }),
|
|
11160
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full flex-1", children: [
|
|
11161
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(NumberInput, { ...field, className: "w-full" }) }) }),
|
|
11162
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11163
|
+
] })
|
|
11164
|
+
] }) })
|
|
11165
|
+
}
|
|
11166
|
+
)
|
|
11167
|
+
] }) }) }),
|
|
11168
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
11169
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
11170
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "button", onClick: onSubmit, children: "Add item" })
|
|
11171
|
+
] }) })
|
|
11172
|
+
] }) }) });
|
|
11173
|
+
};
|
|
11174
|
+
const customItemSchema = objectType({
|
|
11175
|
+
title: stringType().min(1),
|
|
11176
|
+
quantity: numberType(),
|
|
11177
|
+
unit_price: unionType([numberType(), stringType()])
|
|
11178
|
+
});
|
|
11158
11179
|
const PROMOTION_QUERY_KEY = "promotions";
|
|
11159
11180
|
const promotionsQueryKeys = {
|
|
11160
11181
|
list: (query2) => [
|
|
@@ -11460,7 +11481,7 @@ const SalesChannelForm = ({ order }) => {
|
|
|
11460
11481
|
defaultValues: {
|
|
11461
11482
|
sales_channel_id: order.sales_channel_id || ""
|
|
11462
11483
|
},
|
|
11463
|
-
resolver: zod.zodResolver(schema$
|
|
11484
|
+
resolver: zod.zodResolver(schema$2)
|
|
11464
11485
|
});
|
|
11465
11486
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11466
11487
|
const { handleSuccess } = useRouteModal();
|
|
@@ -11535,7 +11556,7 @@ const SalesChannelField = ({ control, order }) => {
|
|
|
11535
11556
|
}
|
|
11536
11557
|
);
|
|
11537
11558
|
};
|
|
11538
|
-
const schema$
|
|
11559
|
+
const schema$2 = objectType({
|
|
11539
11560
|
sales_channel_id: stringType().min(1)
|
|
11540
11561
|
});
|
|
11541
11562
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
@@ -12377,7 +12398,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12377
12398
|
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12378
12399
|
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12379
12400
|
},
|
|
12380
|
-
resolver: zod.zodResolver(schema$
|
|
12401
|
+
resolver: zod.zodResolver(schema$1)
|
|
12381
12402
|
});
|
|
12382
12403
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12383
12404
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12547,7 +12568,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12547
12568
|
}
|
|
12548
12569
|
) });
|
|
12549
12570
|
};
|
|
12550
|
-
const schema$
|
|
12571
|
+
const schema$1 = addressSchema;
|
|
12551
12572
|
const TransferOwnership = () => {
|
|
12552
12573
|
const { id } = reactRouterDom.useParams();
|
|
12553
12574
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -12571,7 +12592,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12571
12592
|
defaultValues: {
|
|
12572
12593
|
customer_id: order.customer_id || ""
|
|
12573
12594
|
},
|
|
12574
|
-
resolver: zod.zodResolver(schema
|
|
12595
|
+
resolver: zod.zodResolver(schema)
|
|
12575
12596
|
});
|
|
12576
12597
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12577
12598
|
const { handleSuccess } = useRouteModal();
|
|
@@ -13021,29 +13042,8 @@ const Illustration = () => {
|
|
|
13021
13042
|
}
|
|
13022
13043
|
);
|
|
13023
13044
|
};
|
|
13024
|
-
const schema$1 = objectType({
|
|
13025
|
-
customer_id: stringType().min(1)
|
|
13026
|
-
});
|
|
13027
|
-
const CustomItems = () => {
|
|
13028
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
13029
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
13030
|
-
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
13031
|
-
] });
|
|
13032
|
-
};
|
|
13033
|
-
const CustomItemsForm = () => {
|
|
13034
|
-
const form = reactHookForm.useForm({
|
|
13035
|
-
resolver: zod.zodResolver(schema)
|
|
13036
|
-
});
|
|
13037
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
13038
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
13039
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13040
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
13041
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
13042
|
-
] }) })
|
|
13043
|
-
] }) });
|
|
13044
|
-
};
|
|
13045
13045
|
const schema = objectType({
|
|
13046
|
-
|
|
13046
|
+
customer_id: stringType().min(1)
|
|
13047
13047
|
});
|
|
13048
13048
|
const widgetModule = { widgets: [] };
|
|
13049
13049
|
const routeModule = {
|
|
@@ -13070,17 +13070,21 @@ const routeModule = {
|
|
|
13070
13070
|
path: "/draft-orders/:id/billing-address"
|
|
13071
13071
|
},
|
|
13072
13072
|
{
|
|
13073
|
-
Component:
|
|
13074
|
-
path: "/draft-orders/:id/
|
|
13073
|
+
Component: CustomItems,
|
|
13074
|
+
path: "/draft-orders/:id/custom-items"
|
|
13075
13075
|
},
|
|
13076
13076
|
{
|
|
13077
|
-
Component:
|
|
13078
|
-
path: "/draft-orders/:id/
|
|
13077
|
+
Component: Email,
|
|
13078
|
+
path: "/draft-orders/:id/email"
|
|
13079
13079
|
},
|
|
13080
13080
|
{
|
|
13081
13081
|
Component: Metadata,
|
|
13082
13082
|
path: "/draft-orders/:id/metadata"
|
|
13083
13083
|
},
|
|
13084
|
+
{
|
|
13085
|
+
Component: Items,
|
|
13086
|
+
path: "/draft-orders/:id/items"
|
|
13087
|
+
},
|
|
13084
13088
|
{
|
|
13085
13089
|
Component: Promotions,
|
|
13086
13090
|
path: "/draft-orders/:id/promotions"
|
|
@@ -13100,10 +13104,6 @@ const routeModule = {
|
|
|
13100
13104
|
{
|
|
13101
13105
|
Component: TransferOwnership,
|
|
13102
13106
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13103
|
-
},
|
|
13104
|
-
{
|
|
13105
|
-
Component: CustomItems,
|
|
13106
|
-
path: "/draft-orders/:id/custom-items"
|
|
13107
13107
|
}
|
|
13108
13108
|
]
|
|
13109
13109
|
}
|