import React, { useState, useEffect } from "react"; import { Card, CardContent } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea"; import { Calendar } from "@/components/ui/calendar"; import { format } from "date-fns"; import { motion } from "framer-motion"; import { Music, Sun, Moon, TimerReset } from "lucide-react";
export default function ProductivityApp() { const [task, setTask] = useState(""); const [tasks, setTasks] = useState([]); const [note, setNote] = useState(""); const [notesByDate, setNotesByDate] = useState({}); const [date, setDate] = useState(new Date()); const [timeLeft, setTimeLeft] = useState(1500); // 25 min Pomodoro const [isRunning, setIsRunning] = useState(false); const [darkMode, setDarkMode] = useState(false);
useEffect(() => { let timer; if (isRunning && timeLeft > 0) { timer = setInterval(() => setTimeLeft(t => t - 1), 1000); } return () => clearInterval(timer); }, [isRunning, timeLeft]);
const addTask = () => { if (task.trim()) { setTasks([...tasks, { text: task, completed: false }]); setTask(""); } };
const toggleTask = index => { const newTasks = [...tasks]; newTasks[index].completed = !newTasks[index].completed; setTasks(newTasks); };
const saveNote = () => { if (!note.trim()) return; const day = format(date, "yyyy-MM-dd"); setNotesByDate({ ...notesByDate, [day]: [...(notesByDate[day] || []), note], }); setNote(""); };
const formatTime = t => ${Math.floor(t / 60).toString().padStart(2, "0")}:${(t % 60).toString().padStart(2, "0")};
return (
); }
Super Productivity Dashboard
To-Do List
setTask(e.target.value)}
placeholder="Add new task..."
/>
-
{tasks.map((t, i) => (
- toggleTask(i)} className={`cursor-pointer ${t.completed ? "line-through text-green-500" : "text-black dark:text-white"}`} > • {t.text} ))}
Pomodoro Timer
{formatTime(timeLeft)}
Quick Notes
Digital Calendar
{Array.from({ length: 31 }, (_, i) => {
const day = format(new Date(2025, 4, i + 1), "yyyy-MM-dd");
return (
);
})}
{i + 1}
{(notesByDate[day] || []).map((n, ni) => (
{n.length > 40 ? n.slice(0, 40) + "..." : n}
))}
Motivation
“Success is the sum of small efforts, repeated day in and day out.” – R. Collier
Komentar
Posting Komentar