feat: deal attributes with select and options
This commit is contained in:
@ -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 <></>;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user