diff --git a/src/app/(main)/problems/new/components/basic-form.tsx b/src/app/(main)/problems/new/components/basic-form.tsx new file mode 100644 index 0000000..1db700e --- /dev/null +++ b/src/app/(main)/problems/new/components/basic-form.tsx @@ -0,0 +1,119 @@ +"use client"; + +import { z } from "zod"; +import { + Form, + FormControl, + FormField, + FormItem, + FormLabel, + FormMessage, +} from "@/components/ui/form"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; +import { + Accordion, + AccordionContent, + AccordionItem, + AccordionTrigger, +} from "@/components/ui/accordion"; +import { useForm } from "react-hook-form"; +import { toast } from "@/hooks/use-toast"; +import { Input } from "@/components/ui/input"; +import { zodResolver } from "@hookform/resolvers/zod"; + +const basicFormSchema = z.object({ + title: z.string().min(1, { message: "题目标题不能为空" }), + difficulty: z.enum(["简单", "中等", "困难"], { + required_error: "请选择题目难度", + }), +}); + +type BasicFormValues = z.infer; + +export function BasicForm() { + const form = useForm({ + resolver: zodResolver(basicFormSchema), + defaultValues: { + title: "", + difficulty: undefined, + }, + }); + + function onSubmit(data: BasicFormValues) { + toast({ + title: "题目基本信息创建成功", + description: ( +
+

题目标题:{data.title}

+

题目难度:{data.difficulty}

+
+ ), + }); + } + + return ( +
+ + ( + + 题目标题 + + + + + + )} + /> + ( + + 题目难度 + + + + + 点击此处查看题目难度定义 + +
+

+ 简单:这类题目通常涉及基本的编程概念,如变量、循环、条件语句等。 +

+

+ 中等:这类题目可能需要一些基本的算法知识,如排序、搜索、简单的动态规划等。 +

+

+ 困难:这类题目通常涉及复杂的算法和数据结构,如高级动态规划、图论、网络流等。 +

+
+
+
+
+
+ )} + /> + + + ); +} diff --git a/src/app/(main)/problems/new/components/details-form.tsx b/src/app/(main)/problems/new/components/details-form.tsx new file mode 100644 index 0000000..73c4760 --- /dev/null +++ b/src/app/(main)/problems/new/components/details-form.tsx @@ -0,0 +1,61 @@ +"use client"; + +import { z } from "zod"; +import { + Form, + FormControl, + FormField, + FormItem, + FormLabel, + FormMessage, +} from "@/components/ui/form"; +import { toast } from "@/hooks/use-toast"; +import { useForm } from "react-hook-form"; +import { Textarea } from "@/components/ui/textarea"; +import { zodResolver } from "@hookform/resolvers/zod"; + +const detailsFormSchema = z.object({ + description: z.string().min(1, { message: "题目描述不能为空" }), +}); + +type DetailsFormValues = z.infer; + +export function DeatilsForm() { + const form = useForm({ + resolver: zodResolver(detailsFormSchema), + defaultValues: { + description: "", + }, + }); + + function onSubmit(data: DetailsFormValues) { + toast({ + title: "题目详细内容创建成功", + description: ( +
+

题目描述:{data.description}

+
+ ), + }); + } + + return ( +
+ + ( + + 题目描述 + +