"use client" import { useState } from "react" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { Checkbox } from "@/components/ui/checkbox" import { AlertCircle } from "lucide-react" import { Alert, AlertDescription } from "@/components/ui/alert" interface BasicSettingsProps { formData: { taskName: string analysisTypes: string[] } updateFormData: ( data: Partial<{ taskName: string analysisTypes: string[] }>, ) => void onNext: () => void } const analysisTypeOptions = [ { id: "comprehensive", label: "综合分析" }, { id: "friends", label: "好友信息分析" }, { id: "behavior", label: "用户行为分析" }, { id: "moments", label: "朋友圈内容分析" }, { id: "interaction", label: "互动频率分析" }, ] export function BasicSettings({ formData, updateFormData, onNext }: BasicSettingsProps) { const [errors, setErrors] = useState<{ taskName?: string; analysisTypes?: string }>({}) const validateForm = () => { const newErrors: { taskName?: string; analysisTypes?: string } = {} if (!formData.taskName?.trim()) { newErrors.taskName = "请输入任务名称" } if (formData.analysisTypes.length === 0) { newErrors.analysisTypes = "请至少选择一种分析类型" } setErrors(newErrors) return Object.keys(newErrors).length === 0 } const handleNext = () => { if (validateForm()) { onNext() } } const handleTypeChange = (typeId: string, checked: boolean) => { const newTypes = checked ? [...formData.analysisTypes, typeId] : formData.analysisTypes.filter((id) => id !== typeId) updateFormData({ analysisTypes: newTypes }) } return (
设置分析计划的基本信息和分析类型
{errors.taskName}
}{errors.analysisTypes}
}