Files
users/components/tag-tasks/task-creation.tsx
v0 2408d50cb0 refactor: overhaul UI for streamlined user experience
Redesign navigation, home overview, user portrait, and valuation pages
with improved functionality and responsive design.

Co-authored-by: null <4804959+fnvtk@users.noreply.github.com>
2025-07-18 13:47:12 +00:00

308 lines
13 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use client"
import { useState } from "react"
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
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 { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
import { Switch } from "@/components/ui/switch"
import { Badge } from "@/components/ui/badge"
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
import { Calendar } from "@/components/ui/calendar"
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"
import { CalendarIcon, Plus, Tag, X } from "lucide-react"
import { format } from "date-fns"
import { cn } from "@/lib/utils"
export function TaskCreation() {
const [selectedTags, setSelectedTags] = useState<string[]>([])
const [newTag, setNewTag] = useState("")
const [date, setDate] = useState<Date>()
const addTag = () => {
if (newTag && !selectedTags.includes(newTag)) {
setSelectedTags([...selectedTags, newTag])
setNewTag("")
}
}
const removeTag = (tag: string) => {
setSelectedTags(selectedTags.filter((t) => t !== tag))
}
return (
<Card>
<CardHeader>
<CardTitle></CardTitle>
</CardHeader>
<CardContent>
<Tabs defaultValue="basic" className="space-y-4">
<TabsList>
<TabsTrigger value="basic"></TabsTrigger>
<TabsTrigger value="target"></TabsTrigger>
<TabsTrigger value="action"></TabsTrigger>
<TabsTrigger value="schedule"></TabsTrigger>
</TabsList>
<TabsContent value="basic" className="space-y-4">
<div className="grid grid-cols-1 gap-4">
<div className="space-y-2">
<Label htmlFor="task-name"></Label>
<Input id="task-name" placeholder="输入任务名称" />
</div>
<div className="space-y-2">
<Label htmlFor="task-description"></Label>
<Textarea id="task-description" placeholder="输入任务描述" />
</div>
<div className="space-y-2">
<Label htmlFor="platform"></Label>
<Select>
<SelectTrigger id="platform">
<SelectValue placeholder="选择目标平台" />
</SelectTrigger>
<SelectContent>
<SelectItem value="jd"></SelectItem>
<SelectItem value="taobao"></SelectItem>
<SelectItem value="dangdang"></SelectItem>
<SelectItem value="xiaohongshu"></SelectItem>
<SelectItem value="zhihu"></SelectItem>
<SelectItem value="bilibili"></SelectItem>
<SelectItem value="douyin"></SelectItem>
<SelectItem value="other"></SelectItem>
</SelectContent>
</Select>
</div>
<div className="space-y-2">
<Label htmlFor="priority"></Label>
<Select defaultValue="medium">
<SelectTrigger id="priority">
<SelectValue placeholder="选择优先级" />
</SelectTrigger>
<SelectContent>
<SelectItem value="high"></SelectItem>
<SelectItem value="medium"></SelectItem>
<SelectItem value="low"></SelectItem>
</SelectContent>
</Select>
</div>
</div>
</TabsContent>
<TabsContent value="target" className="space-y-4">
<div className="grid grid-cols-1 gap-4">
<div className="space-y-2">
<Label></Label>
<div className="flex flex-wrap gap-2 mb-2">
{selectedTags.map((tag) => (
<Badge key={tag} variant="outline" className="flex items-center gap-1">
<Tag className="h-3 w-3" />
{tag}
<button onClick={() => removeTag(tag)} className="ml-1">
<X className="h-3 w-3" />
</button>
</Badge>
))}
</div>
<div className="flex space-x-2">
<Input
placeholder="输入标签名称"
value={newTag}
onChange={(e) => setNewTag(e.target.value)}
onKeyDown={(e) => e.key === "Enter" && addTag()}
/>
<Button type="button" size="sm" onClick={addTag}>
<Plus className="h-4 w-4" />
</Button>
</div>
</div>
<div className="space-y-2">
<Label htmlFor="user-segment"></Label>
<Select>
<SelectTrigger id="user-segment">
<SelectValue placeholder="选择用户分群" />
</SelectTrigger>
<SelectContent>
<SelectItem value="all"></SelectItem>
<SelectItem value="active"></SelectItem>
<SelectItem value="new"></SelectItem>
<SelectItem value="high-value"></SelectItem>
<SelectItem value="inactive"></SelectItem>
</SelectContent>
</Select>
</div>
<div className="space-y-2">
<Label htmlFor="user-count"></Label>
<Input id="user-count" type="number" placeholder="输入目标用户数量" />
</div>
<div className="space-y-2">
<Label htmlFor="sampling-method"></Label>
<Select defaultValue="random">
<SelectTrigger id="sampling-method">
<SelectValue placeholder="选择抽样方式" />
</SelectTrigger>
<SelectContent>
<SelectItem value="random"></SelectItem>
<SelectItem value="stratified"></SelectItem>
<SelectItem value="systematic"></SelectItem>
<SelectItem value="all"></SelectItem>
</SelectContent>
</Select>
</div>
</div>
</TabsContent>
<TabsContent value="action" className="space-y-4">
<div className="grid grid-cols-1 gap-4">
<div className="space-y-2">
<Label htmlFor="action-type"></Label>
<Select>
<SelectTrigger id="action-type">
<SelectValue placeholder="选择动作类型" />
</SelectTrigger>
<SelectContent>
<SelectItem value="login"></SelectItem>
<SelectItem value="purchase"></SelectItem>
<SelectItem value="browse"></SelectItem>
<SelectItem value="search"></SelectItem>
<SelectItem value="content"></SelectItem>
<SelectItem value="custom"></SelectItem>
</SelectContent>
</Select>
</div>
<div className="space-y-2">
<Label htmlFor="action-params"></Label>
<Textarea id="action-params" placeholder="输入动作参数JSON格式" />
</div>
<div className="space-y-2">
<Label htmlFor="success-criteria"></Label>
<Select>
<SelectTrigger id="success-criteria">
<SelectValue placeholder="选择成功标准" />
</SelectTrigger>
<SelectContent>
<SelectItem value="login-success"></SelectItem>
<SelectItem value="purchase-complete"></SelectItem>
<SelectItem value="browse-time"></SelectItem>
<SelectItem value="search-count"></SelectItem>
<SelectItem value="content-interaction"></SelectItem>
<SelectItem value="custom"></SelectItem>
</SelectContent>
</Select>
</div>
<div className="space-y-2">
<Label></Label>
<div className="space-y-2">
<div className="flex items-center space-x-2">
<Input placeholder="输入新标签名称" />
<Select>
<SelectTrigger className="w-[180px]">
<SelectValue placeholder="标签分类" />
</SelectTrigger>
<SelectContent>
<SelectItem value="behavior"></SelectItem>
<SelectItem value="preference"></SelectItem>
<SelectItem value="value"></SelectItem>
<SelectItem value="lifecycle"></SelectItem>
<SelectItem value="custom"></SelectItem>
</SelectContent>
</Select>
<Button type="button" size="sm">
<Plus className="h-4 w-4" />
</Button>
</div>
</div>
</div>
<div className="space-y-2">
<div className="flex items-center space-x-2">
<Switch id="auto-apply" />
<Label htmlFor="auto-apply"></Label>
</div>
</div>
</div>
</TabsContent>
<TabsContent value="schedule" className="space-y-4">
<div className="grid grid-cols-1 gap-4">
<div className="space-y-2">
<Label htmlFor="execution-mode"></Label>
<Select defaultValue="immediate">
<SelectTrigger id="execution-mode">
<SelectValue placeholder="选择执行模式" />
</SelectTrigger>
<SelectContent>
<SelectItem value="immediate"></SelectItem>
<SelectItem value="scheduled"></SelectItem>
<SelectItem value="recurring"></SelectItem>
</SelectContent>
</Select>
</div>
<div className="space-y-2">
<Label></Label>
<Popover>
<PopoverTrigger asChild>
<Button
variant={"outline"}
className={cn("w-full justify-start text-left font-normal", !date && "text-muted-foreground")}
>
<CalendarIcon className="mr-2 h-4 w-4" />
{date ? format(date, "PPP") : "选择日期"}
</Button>
</PopoverTrigger>
<PopoverContent className="w-auto p-0">
<Calendar mode="single" selected={date} onSelect={setDate} initialFocus />
</PopoverContent>
</Popover>
</div>
<div className="space-y-2">
<Label htmlFor="execution-time"></Label>
<Input id="execution-time" type="time" />
</div>
<div className="space-y-2">
<Label htmlFor="recurrence-pattern"></Label>
<Select disabled={true}>
<SelectTrigger id="recurrence-pattern">
<SelectValue placeholder="选择重复模式" />
</SelectTrigger>
<SelectContent>
<SelectItem value="daily"></SelectItem>
<SelectItem value="weekly"></SelectItem>
<SelectItem value="monthly"></SelectItem>
<SelectItem value="custom"></SelectItem>
</SelectContent>
</Select>
</div>
<div className="space-y-2">
<div className="flex items-center space-x-2">
<Switch id="notify-completion" />
<Label htmlFor="notify-completion"></Label>
</div>
</div>
</div>
</TabsContent>
</Tabs>
<div className="flex justify-end space-x-2 mt-6">
<Button variant="outline"></Button>
<Button></Button>
</div>
</CardContent>
</Card>
)
}