collect-system/apps/web/src/components/models/course/manage/CourseBasicForm.tsx

29 lines
1.4 KiB
TypeScript
Raw Normal View History

2024-12-31 15:57:32 +08:00
import { SubmitHandler, useFormContext } from 'react-hook-form';
2025-01-03 09:24:46 +08:00
import { CourseFormData, useCourseEditor } from './CourseEditorContext';
import { CourseLevel, CourseLevelLabel } from '@nicestack/common';
2024-12-31 15:57:32 +08:00
import { FormInput } from '@web/src/components/presentation/form/FormInput';
import { FormSelect } from '@web/src/components/presentation/form/FormSelect';
import { FormArrayField } from '@web/src/components/presentation/form/FormArrayField';
2025-01-03 09:24:46 +08:00
import { convertToOptions } from '@nicestack/client';
2024-12-31 15:57:32 +08:00
export function CourseBasicForm() {
const { register, formState: { errors }, watch, handleSubmit } = useFormContext<CourseFormData>();
return (
<form className="max-w-2xl mx-auto space-y-6 p-6">
<FormInput maxLength={20} name="title" label="课程标题" placeholder="请输入课程标题" />
<FormInput maxLength={10} name="subTitle" label="课程副标题" placeholder="请输入课程副标题" />
<FormInput
name="description"
label="课程描述"
type="textarea"
placeholder="请输入课程描述"
/>
2025-01-03 09:24:46 +08:00
<FormSelect name='level' label='难度等级' options={convertToOptions(CourseLevelLabel)}></FormSelect>
2024-12-31 15:57:32 +08:00
{/* <FormArrayField inputProps={{ maxLength: 10 }} name='requirements' label='课程要求'></FormArrayField> */}
</form>
);
}