// Calendar / Agenda screen — week view + day timeline const CalendarScreen = ({ state, setState, navigate, showToast }) => { const [view, setView] = React.useState('dia'); const [selectedDay, setSelectedDay] = React.useState(3); // index of week const [showNew, setShowNew] = React.useState(false); const events = (state && state.events) || eventsToday; const addEvent = (ev) => { setState && setState(s => ({ ...s, events: [...(s.events || eventsToday), { ...ev, id: 'ev' + Date.now() }] })); setShowNew(false); showToast && showToast('Evento criado'); }; const weekDays = [ { d: 'Seg', n: 16, today: false }, { d: 'Ter', n: 17, today: false }, { d: 'Qua', n: 18, today: false }, { d: 'Qui', n: 19, today: true }, { d: 'Sex', n: 20, today: false }, { d: 'Sáb', n: 21, today: false }, { d: 'Dom', n: 22, today: false }, ]; return (
navigate('dashboard')} right={ } /> {/* View switcher */}
{[{ id: 'dia', label: 'Dia' }, { id: 'semana', label: 'Semana' }, { id: 'mes', label: 'Mês' }].map(v => ( ))}
{/* Week strip */}
{weekDays.map((d, i) => { const active = selectedDay === i; return ( ); })}
{view === 'dia' && } {view === 'semana' && } {view === 'mes' && } setShowNew(false)} title="Novo evento">
); }; const NewEventForm = ({ onSubmit }) => { const [title, setTitle] = React.useState(''); const [start, setStart] = React.useState('14'); const [end, setEnd] = React.useState('15'); const [location, setLocation] = React.useState(''); const colors = [CDV.brand, CDV.mint, CDV.coral, CDV.amber, CDV.sky]; const [color, setColor] = React.useState(colors[0]); const canSave = title.trim() && Number(start) < Number(end); return (
setTitle(e.target.value)} placeholder="Título do evento" style={{ width: '100%', height: 54, borderRadius: 16, border: `1px solid ${CDV.stroke}`, background: CDV.surfaceHi, color: CDV.text, padding: '0 16px', fontSize: 15, outline: 'none', fontFamily: 'inherit', marginBottom: 12, }} />
Início (h)
setStart(e.target.value)} style={{ width: '100%', background: 'transparent', border: 'none', outline: 'none', color: CDV.text, fontSize: 16, fontWeight: 600, marginTop: 4, fontFamily: 'inherit' }} />
Fim (h)
setEnd(e.target.value)} style={{ width: '100%', background: 'transparent', border: 'none', outline: 'none', color: CDV.text, fontSize: 16, fontWeight: 600, marginTop: 4, fontFamily: 'inherit' }} />
setLocation(e.target.value)} placeholder="Local (opcional)" style={{ width: '100%', height: 50, borderRadius: 14, border: `1px solid ${CDV.stroke}`, background: CDV.surfaceHi, color: CDV.text, padding: '0 16px', fontSize: 14, outline: 'none', fontFamily: 'inherit', marginBottom: 12, }} />
Cor
{colors.map(c => (
); }; const DayView = ({ events }) => { const hours = Array.from({ length: 14 }, (_, i) => i + 7); // 7 to 20 const HOUR_HEIGHT = 56; const nowHour = 10.4; return (
{hours.map(h => (
{String(h).padStart(2, '0')}:00
))} {/* Events */} {events.map(ev => { const top = (ev.start - hours[0]) * HOUR_HEIGHT + 14; const height = (ev.end - ev.start) * HOUR_HEIGHT - 4; return (
{ev.title}
{fmtHour(ev.start)} – {fmtHour(ev.end)} · {ev.location}
); })} {/* Now indicator */}
); }; const fmtHour = (h) => { const hh = Math.floor(h); const mm = Math.round((h - hh) * 60); return `${String(hh).padStart(2, '0')}:${String(mm).padStart(2, '0')}`; }; const WeekView = ({ events }) => (
Semana de 16-22 Jun
{[...Array(7)].map((_, i) => (
{['S','T','Q','Q','S','S','D'][i]}
{16 + i}
{Array.from({ length: Math.floor(Math.random() * 4) + 1 }, (_, k) => (
))}
))}
{events.slice(0, 4).map(ev => (
{ev.title}
{fmtHour(ev.start)} - {fmtHour(ev.end)} · {ev.location}
))}
); const MonthView = () => { const dots = { 3: 4, 7: 2, 10: 3, 14: 1, 16: 2, 19: 5, 22: 2, 25: 3, 28: 1 }; return (
{['D','S','T','Q','Q','S','S'].map(d => (
{d}
))}
{[...Array(35)].map((_, i) => { const day = i - 2; if (day < 1 || day > 30) return
; const today = day === 19; return (
{day}
{Array.from({ length: dots[day] || 0 }, (_, k) => (
))}
); })}
); }; Object.assign(window, { CalendarScreen });