import React, { useState } from 'react'; import { ChevronLeft, ChevronRight, X, Plus, Trash2, BookOpen, Home } from 'lucide-react'; const Calendar2026 = () => { const [currentMonth, setCurrentMonth] = useState(0); const [selectedDay, setSelectedDay] = useState(null); const [tasks, setTasks] = useState({}); const [showStudyForm, setShowStudyForm] = useState(false); const [newPersonalTask, setNewPersonalTask] = useState(''); const [newStudyTask, setNewStudyTask] = useState({ subject: '', topic: '', type: 'teoria', understanding: 0 }); const months = [ 'Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro' ]; const daysOfWeek = ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb']; const getDaysInMonth = (month, year) => { return new Date(year, month + 1, 0).getDate(); }; const getFirstDayOfMonth = (month, year) => { return new Date(year, month, 1).getDay(); }; const generateCalendarDays = (month) => { const year = 2026; const daysInMonth = getDaysInMonth(month, year); const firstDay = getFirstDayOfMonth(month, year); const days = []; for (let i = 0; i < firstDay; i++) { days.push(null); } for (let i = 1; i <= daysInMonth; i++) { days.push(i); } return days; }; const isToday = (day, month) => { const today = new Date(); return day === today.getDate() && month === today.getMonth() && today.getFullYear() === 2026; }; const nextMonth = () => { setCurrentMonth((prev) => (prev + 1) % 12); }; const prevMonth = () => { setCurrentMonth((prev) => (prev - 1 + 12) % 12); }; const openDayModal = (day) => { if (day) { setSelectedDay({ day, month: currentMonth }); setShowStudyForm(false); } }; const closeDayModal = () => { setSelectedDay(null); setShowStudyForm(false); setNewPersonalTask(''); setNewStudyTask({ subject: '', topic: '', type: 'teoria', understanding: 0 }); }; const getTaskKey = (month, day) => `${month}-${day}`; const addStudyTask = () => { if (newStudyTask.subject.trim() && newStudyTask.topic.trim() && selectedDay) { const key = getTaskKey(selectedDay.month, selectedDay.day); const updatedTasks = { ...tasks }; if (!updatedTasks[key]) { updatedTasks[key] = []; } updatedTasks[key].push({ id: Date.now(), category: 'study', subject: newStudyTask.subject, topic: newStudyTask.topic, type: newStudyTask.type, understanding: newStudyTask.understanding, completed: false }); setTasks(updatedTasks); setNewStudyTask({ subject: '', topic: '', type: 'teoria', understanding: 0 }); setShowStudyForm(false); } }; const addPersonalTask = () => { if (newPersonalTask.trim() && selectedDay) { const key = getTaskKey(selectedDay.month, selectedDay.day); const updatedTasks = { ...tasks }; if (!updatedTasks[key]) { updatedTasks[key] = []; } updatedTasks[key].push({ id: Date.now(), category: 'personal', text: newPersonalTask, completed: false }); setTasks(updatedTasks); setNewPersonalTask(''); } }; const deleteTask = (taskId) => { if (selectedDay) { const key = getTaskKey(selectedDay.month, selectedDay.day); const updatedTasks = { ...tasks }; updatedTasks[key] = updatedTasks[key].filter(task => task.id !== taskId); setTasks(updatedTasks); } }; const toggleTask = (taskId) => { if (selectedDay) { const key = getTaskKey(selectedDay.month, selectedDay.day); const updatedTasks = { ...tasks }; updatedTasks[key] = updatedTasks[key].map(task => task.id === taskId ? { ...task, completed: !task.completed } : task ); setTasks(updatedTasks); } }; const updateUnderstanding = (taskId, value) => { if (selectedDay) { const key = getTaskKey(selectedDay.month, selectedDay.day); const updatedTasks = { ...tasks }; updatedTasks[key] = updatedTasks[key].map(task => task.id === taskId ? { ...task, understanding: value } : task ); setTasks(updatedTasks); } }; const getDayTasks = (month, day) => { const key = getTaskKey(month, day); return tasks[key] || []; }; const hasTasks = (month, day) => { return getDayTasks(month, day).length > 0; }; const getUnderstandingColor = (value) => { if (value >= 80) return 'from-green-500 to-emerald-500'; if (value >= 60) return 'from-blue-500 to-cyan-500'; if (value >= 40) return 'from-yellow-500 to-orange-500'; return 'from-red-500 to-pink-500'; }; const getUnderstandingText = (value) => { if (value >= 80) return 'Excelente'; if (value >= 60) return 'Bom'; if (value >= 40) return 'Regular'; return 'Precisa melhorar'; }; const calendarDays = generateCalendarDays(currentMonth); const gradients = [ 'from-purple-600 to-pink-600', 'from-blue-600 to-cyan-600', 'from-green-600 to-emerald-600', 'from-orange-600 to-red-600', 'from-indigo-600 to-purple-600', 'from-teal-600 to-blue-600', 'from-rose-600 to-pink-600', 'from-amber-600 to-orange-600', 'from-violet-600 to-fuchsia-600', 'from-sky-600 to-indigo-600', 'from-lime-600 to-green-600', 'from-red-600 to-rose-600' ]; const currentDayTasks = selectedDay ? getDayTasks(selectedDay.month, selectedDay.day) : []; const studyTasks = currentDayTasks.filter(t => t.category === 'study'); const personalTasks = currentDayTasks.filter(t => t.category === 'personal'); return (
{/* Header */}

2026

Organize seus estudos e vida pessoal

{/* Calendar Card */}
{/* Month Navigation */}

{months[currentMonth]}

{months.map((_, idx) => (
))}
{/* Calendar Grid */}
{/* Days of Week */}
{daysOfWeek.map((day, idx) => (
{day}
))}
{/* Days Grid */}
{calendarDays.map((day, idx) => (
openDayModal(day)} className={`aspect-square flex flex-col items-center justify-center rounded-2xl text-lg font-semibold transition-all duration-300 relative ${ day === null ? 'bg-transparent cursor-default' : isToday(day, currentMonth) ? `bg-gradient-to-br ${gradients[currentMonth]} text-white shadow-lg shadow-cyan-500/50 scale-105 cursor-pointer hover:scale-110` : idx % 7 === 0 || idx % 7 === 6 ? 'bg-slate-800/50 text-cyan-400 hover:bg-slate-700/50 hover:scale-105 cursor-pointer' : 'bg-slate-800/30 text-slate-200 hover:bg-slate-700/50 hover:scale-105 cursor-pointer' }`} > {day} {day && hasTasks(currentMonth, day) && (
{getDayTasks(currentMonth, day).slice(0, 3).map((task, i) => (
))}
)}
))}
{/* Footer Stats */}
{getDaysInMonth(currentMonth, 2026)}
Dias no mês
{Math.ceil(getDaysInMonth(currentMonth, 2026) / 7)}
Semanas
{currentMonth + 1}/12
Progresso
{/* Quick Month Selector */}
{months.map((month, idx) => ( ))}
{/* Modal de Tarefas */} {selectedDay && (
{/* Modal Header */}

{selectedDay.day} de {months[selectedDay.month]}

{studyTasks.length} estudo(s) • {personalTasks.length} tarefa(s) pessoal(is)

{/* Modal Content */}
{/* COLUNA ESTUDOS */}

Estudos

{/* Formulário de Estudo */} {showStudyForm && (
setNewStudyTask({ ...newStudyTask, subject: e.target.value })} placeholder="Matéria (ex: Matemática)" className="w-full px-4 py-2 bg-slate-700 border border-slate-600 rounded-xl text-white placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500" /> setNewStudyTask({ ...newStudyTask, topic: e.target.value })} placeholder="Assunto (ex: Derivadas)" className="w-full px-4 py-2 bg-slate-700 border border-slate-600 rounded-xl text-white placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500" />
{newStudyTask.understanding}%
setNewStudyTask({ ...newStudyTask, understanding: parseInt(e.target.value) })} className="w-full h-2 bg-slate-700 rounded-lg appearance-none cursor-pointer" style={{ background: `linear-gradient(to right, rgb(59, 130, 246) 0%, rgb(59, 130, 246) ${newStudyTask.understanding}%, rgb(51, 65, 85) ${newStudyTask.understanding}%, rgb(51, 65, 85) 100%)` }} />
{getUnderstandingText(newStudyTask.understanding)}
)} {/* Lista de Estudos */}
{studyTasks.length === 0 ? (

Nenhum estudo cadastrado

) : ( studyTasks.map((task) => (
toggleTask(task.id)} className="w-5 h-5 rounded cursor-pointer mt-1" />
{task.type === 'teoria' ? 'TEORIA' : 'QUESTÃO'}
{task.subject}

{task.topic}

{!task.completed && (
Entendimento {task.understanding}%
updateUnderstanding(task.id, parseInt(e.target.value))} className="w-full h-1.5 rounded-lg appearance-none cursor-pointer" style={{ background: `linear-gradient(to right, rgb(59, 130, 246) 0%, rgb(59, 130, 246) ${task.understanding}%, rgb(51, 65, 85) ${task.understanding}%, rgb(51, 65, 85) 100%)` }} />
{getUnderstandingText(task.understanding)}
)}
)) )}
{/* COLUNA VIDA PESSOAL */}

Vida Pessoal

{/* Formulário Pessoal */}
setNewPersonalTask(e.target.value)} onKeyPress={(e) => e.key === 'Enter' && addPersonalTask()} placeholder="Digite sua tarefa pessoal..." className="flex-1 px-4 py-3 bg-slate-700 border border-slate-600 rounded-xl text-white placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-pink-500" />
{/* Lista Pessoal */}
{personalTasks.length === 0 ? (

Nenhuma tarefa pessoal

) : ( personalTasks.map((task) => (
toggleTask(task.id)} className="w-5 h-5 rounded cursor-pointer" />

{task.text}

)) )}
)}
); }; export default Calendar2026;