// Sidebar with brand, navigation, projects list, user card. const SBIcons = window.Icons; const { parseDateKey: sbDate } = window.PMStore; const VIEWS = [ { id: 'dashboard', label: 'Panel', icon: 'Dashboard' }, { id: 'all-tasks', label: 'Tüm Görevler', icon: 'CheckSquare' }, { id: 'calendar', label: 'Takvim', icon: 'Calendar' }, ]; const projectAbbr = (name) => name.split(/\s+/).filter(Boolean).map(w => w[0]).join('').slice(0, 2).toUpperCase(); function Sidebar({ state, user, setActiveView, setActiveProject, addProject, updateProject, deleteProject, openNewTask, onLogout }) { const [newProjectOpen, setNewProjectOpen] = React.useState(false); const [newProjectName, setNewProjectName] = React.useState(''); const [editingProjectId, setEditingProjectId] = React.useState(null); const [editingProjectName, setEditingProjectName] = React.useState(''); const inputRef = React.useRef(null); React.useEffect(() => { if (newProjectOpen) setTimeout(() => inputRef.current?.focus(), 50); }, [newProjectOpen]); const handleAddProject = () => { const name = newProjectName.trim(); if (!name) { setNewProjectOpen(false); return; } const colors = ['#047857','#1d4ed8','#b45309','#6d28d9','#be185d','#0e7490']; const id = window.PMStore.uid(); addProject({ id, name, color: colors[Math.floor(Math.random()*colors.length)] }); setActiveProject(id); setActiveView('kanban'); setNewProjectName(''); setNewProjectOpen(false); }; const beginEditProject = (project) => { setEditingProjectId(project.id); setEditingProjectName(project.name); }; const saveProjectEdit = () => { const name = editingProjectName.trim(); if (!editingProjectId) return; if (name) updateProject(editingProjectId, { name }); setEditingProjectId(null); setEditingProjectName(''); }; const removeProject = (project) => { const ok = window.confirm(`"${project.name}" projesi ve bu projedeki görevler silinsin mi?`); if (!ok) return; deleteProject(project.id); if (editingProjectId === project.id) { setEditingProjectId(null); setEditingProjectName(''); } }; const inboxCount = state.tasks.filter(t => t.status !== 'done').length; const todayCount = state.tasks.filter(t => { if (!t.due || t.status === 'done') return false; const d = sbDate(t.due); d.setHours(0,0,0,0); const n = new Date(); n.setHours(0,0,0,0); return d.getTime() === n.getTime(); }).length; const counts = { dashboard: todayCount, 'all-tasks': inboxCount, calendar: 0 }; const isProjectActive = (id) => state.activeProjectId === id && (state.activeView === 'kanban' || state.activeView === 'list'); return ( ); } window.Sidebar = Sidebar; window.projectAbbr = projectAbbr;