feat: deal attributes with select and options

This commit is contained in:
2025-10-29 19:36:58 +04:00
parent 8019fa566c
commit 4cc6360bb4
14 changed files with 489 additions and 20 deletions

View File

@ -1,11 +1,12 @@
import { Checkbox, NumberInput, TextInput } from "@mantine/core";
import { DatePickerInput, DateTimePicker } from "@mantine/dates";
import { UseFormReturnType } from "@mantine/form";
import { UpdateAttributeSchema } from "@/lib/client";
import AttrOptionSelect from "@/app/module-editor/[moduleId]/components/shared/AttrOptionSelect/AttrOptionSelect";
import { AttributeSchema } from "@/lib/client";
import { naiveDateTimeStringToUtc } from "@/utils/datetime";
type Props = {
form: UseFormReturnType<Partial<UpdateAttributeSchema>>;
form: UseFormReturnType<Partial<AttributeSchema>>;
};
const DefaultAttributeValueInput = ({ form }: Props) => {
@ -87,8 +88,18 @@ const DefaultAttributeValueInput = ({ form }: Props) => {
}
/>
);
} else if (type === "select") {
if (!form.values.select?.id) return <></>;
return (
<AttrOptionSelect
label={"Значение по умолчанию"}
{...form.getInputProps("defaultValue")}
value={form.values.defaultValue}
onChange={value => form.setFieldValue("defaultValue", value)}
selectId={form.values.select?.id}
/>
);
}
return <></>;
};