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 { Textarea } from "/components/ui/textarea"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; import { Calendar, Clock, Check, X, Plus, Edit, Trash, User, Settings, Bell } from "lucide-react"; interface Task { id: string; title: string; description: string; status: "todo" | "in-progress" | "completed"; priority: "low" | "medium" | "high"; dueDate: string; assignee: string; } const TaskManagerApp = () => { const [tasks, setTasks] = useState([ { id: "1", title: "Design Homepage Layout", description: "Create wireframes and mockups for the new homepage design", status: "in-progress", priority: "high", dueDate: "2024-01-15", assignee: "Sarah Johnson" }, { id: "2", title: "Fix Login Bug", description: "Investigate and fix the authentication issue on mobile devices", status: "todo", priority: "medium", dueDate: "2024-01-10", assignee: "Mike Chen" }, { id: "3", title: "Write Documentation", description: "Complete API documentation for the new features", status: "completed", priority: "low", dueDate: "2024-01-05", assignee: "Emily Davis" } ]); const [newTask, setNewTask] = useState({ title: "", description: "", status: "todo" as const, priority: "medium" as const, dueDate: "", assignee: "" }); const [editingTaskId, setEditingTaskId] = useState(null); const [notification, setNotification] = useState(""); const handleAddTask = () => { if (newTask.title.trim()) { const task: Task = { id: Date.now().toString(), ...newTask }; setTasks([...tasks, task]); setNewTask({ title: "", description: "", status: "todo", priority: "medium", dueDate: "", assignee: "" }); setNotification("Task added successfully!"); setTimeout(() => setNotification(""), 3000); } }; const handleEditTask = (id: string) => { setEditingTaskId(id); const task = tasks.find(t => t.id === id); if (task) { setNewTask({ title: task.title, description: task.description, status: task.status, priority: task.priority, dueDate: task.dueDate, assignee: task.assignee }); } }; const handleUpdateTask = () => { if (editingTaskId && newTask.title.trim()) { setTasks(tasks.map(task => task.id === editingTaskId ? { ...task, ...newTask } : task )); setEditingTaskId(null); setNewTask({ title: "", description: "", status: "todo", priority: "medium", dueDate: "", assignee: "" }); setNotification("Task updated successfully!"); setTimeout(() => setNotification(""), 3000); } }; const handleDeleteTask = (id: string) => { setTasks(tasks.filter(task => task.id !== id)); setNotification("Task deleted successfully!"); setTimeout(() => setNotification(""), 3000); }; const getStatusColor = (status: string) => { switch (status) { case "todo": return "bg-gray-200 text-gray-800"; case "in-progress": return "bg-blue-200 text-blue-800"; case "completed": return "bg-green-200 text-green-800"; default: return "bg-gray-200 text-gray-800"; } }; const getPriorityColor = (priority: string) => { switch (priority) { case "low": return "bg-green-100 text-green-800"; case "medium": return "bg-yellow-100 text-yellow-800"; case "high": return "bg-red-100 text-red-800"; default: return "bg-gray-100 text-gray-800"; } }; const completedTasks = tasks.filter(task => task.status === "completed").length; const pendingTasks = tasks.filter(task => task.status !== "completed").length; return (
{/* Header */}

Task Manager

Manage your team's tasks efficiently

{pendingTasks} pending tasks
{/* Notification */} {notification && (
{notification}
)} {/* Stats Cards */}
Total Tasks
{tasks.length}

All tasks in the system

Completed
{completedTasks}

Tasks marked as done

Pending
{pendingTasks}

Tasks to be completed

{/* Add/Edit Task Form */} {editingTaskId ? "Edit Task" : "Add New Task"}
setNewTask({...newTask, title: e.target.value})} />