function useNow(ms = 1000) { const [n, setN] = React.useState(new Date()); React.useEffect(() => { const t = setInterval(() => setN(new Date()), ms); return () => clearInterval(t); }, [ms]); return n; } function ClockCard() { const S = useStore(); const { me, m, toast } = useApp(); const now = useNow(); const [mode, setMode] = React.useState('office'); const k = AKH.todayIso(); const rec = (S.attendance[me.id] || {})[k]; const hol = AKH.holidayOn(k); const weekend = AKH.isWeekend(AKH.today()); const onLeave = rec && rec.status === 'leave'; const nowHM = String(now.getHours()).padStart(2, '0') + ':' + String(now.getMinutes()).padStart(2, '0'); const worked = rec && rec.in ? Math.max(0, AKH.mins(rec.out || nowHM) - AKH.mins(rec.in)) : 0; let status = 'You haven\u2019t checked in yet'; if (hol) status = 'Holiday · ' + hol.name; else if (weekend) status = 'It\u2019s the weekend'; else if (onLeave) status = 'You\u2019re on ' + AKStore.LEAVE_TYPES[rec.type].toLowerCase() + ' today'; else if (rec && rec.out) status = 'Checked out at ' + fmt.t(rec.out); else if (rec && rec.in) status = 'Checked in at ' + fmt.t(rec.in) + ' · ' + (rec.status === 'wfh' ? 'Working from home' : 'Office'); const canIn = !hol && !weekend && !onLeave && !(rec && rec.in); const canOut = rec && rec.in && !rec.out; return (
Today · {now.toLocaleDateString('en-IN', { weekday: 'long', day: 'numeric', month: 'short' })}
{now.toLocaleTimeString('en-IN', { hour: 'numeric', minute: '2-digit', hour12: true }).replace(/\s?(am|pm)/i, '')} {String(now.getSeconds()).padStart(2, '0')} · {now.getHours() < 12 ? 'am' : 'pm'}
{status}
{rec && rec.in ? ({compact ? k : label}
{left} / {b.total}
{me.designation} · {me.dept} · {me.empId}
{x.title}
{over ? 'Overdue · ' : x.due === t ? 'Due today · ' : 'Due ' + fmt.dw(x.due) + ' · '}{AKH.user(x.byId).name}
Waiting for you
Approvals and access requests
{d.toLocaleDateString('en-IN', { month: 'short' })}
{d.getDate()}
{h.name}
{d.toLocaleDateString('en-IN', { weekday: 'long' })}{AKH.isWeekend(d) ? ' · falls on a weekend' : ''}
{n.title}
{n.body}
{m ? d[0] : d}
)} {cells.map((k, i) => { if (!k) return ; const di = dayInfo(S, me.id, k); const isT = k === AKH.todayIso(); const c = di.tone ? CELL[di.tone] : null; const weekend = di.kind === 'weekend'; return ( ); })}{fmt.dw(c.date)} · {fmt.t(c.in)} – {fmt.t(c.out)}
{c.reason}
{info.kind === 'holiday' ? 'Office closed for ' + info.hol.name + '.' : info.kind === 'leave' ? AKStore.LEAVE_TYPES[info.rec.type] + ' (approved).' : info.kind === 'absent' ? 'No check-in recorded for this day.' : info.kind === 'weekend' ? 'Weekend.' : 'Nothing recorded yet.'}
} {info.rec && info.rec.corrected ?{AKStore.LEAVE_TYPES[l.type]}
{fmt.range(l.from, l.to)} · {l.days} day{l.days > 1 ? 's' : ''}
{l.reason}
{l.note ?“{l.note}”
: null} {l.status === 'pending' ?| {AKStore.LEAVE_TYPES[l.type]} | {fmt.range(l.from, l.to)} | {l.days} | {l.reason}{l.note ? “{l.note}” : null} | {l.approverId ? AKH.user(l.approverId).name : '—'} | {l.status === 'pending' ? |