"use client" import { useState } from "react" import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { Textarea } from "@/components/ui/textarea" import { Badge } from "@/components/ui/badge" import { X, Plus } from "lucide-react" interface CreatePackageDialogProps { open: boolean onOpenChange: (open: boolean) => void } export function CreatePackageDialog({ open, onOpenChange }: CreatePackageDialogProps) { const [formData, setFormData] = useState({ name: "", description: "", conditions: [] as { field: string; operator: string; value: string }[], tags: [] as string[], }) const [newTag, setNewTag] = useState("") const addCondition = () => { setFormData({ ...formData, conditions: [...formData.conditions, { field: "", operator: "", value: "" }], }) } const removeCondition = (index: number) => { setFormData({ ...formData, conditions: formData.conditions.filter((_, i) => i !== index), }) } const addTag = () => { if (newTag && !formData.tags.includes(newTag)) { setFormData({ ...formData, tags: [...formData.tags, newTag] }) setNewTag("") } } const removeTag = (tag: string) => { setFormData({ ...formData, tags: formData.tags.filter((t) => t !== tag) }) } const handleSubmit = () => { console.log("创建流量包:", formData) onOpenChange(false) } return ( 创建流量包
setFormData({ ...formData, name: e.target.value })} />