const PRIORITY_TONE = { High: 'red', Medium: 'amber', Low: 'grey' }; const NEXT_STATUS = { todo: 'in_progress', in_progress: 'done', done: 'todo' }; function assignableFor(S, me) { const admin = ['hr_admin', 'super_admin'].includes(me.role); return S.users.filter((u) => u.status === 'active' && u.id !== me.id && (admin || u.managerId === me.id)); } function AssignTaskModal({ open, onClose, preset }) { const S = useStore(); const { me, toast } = useApp(); const people = assignableFor(S, me); const blank = () => ({ assigneeId: preset || (people[0] || {}).id || '', title: '', desc: '', due: AKH.iso(AKH.addDays(AKH.today(), 2)), priority: 'Medium' }); const [f, setF] = React.useState(blank); const [err, setErr] = React.useState(''); React.useEffect(() => { setF(blank()); setErr(''); }, [open, preset]); const submit = () => { if (!f.assigneeId) return setErr('Choose who this is for.'); if (!f.title.trim()) return setErr('Give the task a title.'); AKStore.act.addTask(me.id, f); onClose(); toast('Task assigned · email sent to ' + AKH.user(f.assigneeId).name); }; return (
setF({ ...f, title: e.target.value })} placeholder="e.g. Shortlist 5 profiles for TechNova" />