/* AAU CRM — Pipeline Table · Sales Activity (Working Process) · Pipeline Config (Playbook) */ function PipelineTable() { const leads = useLeads(); const viewer = useViewer(); const canEdit = SalesAccess.canEdit(viewer); const isLeader = viewer.buScope === 'all'; const [adv, setAdv] = useState(false); const [fStage, setFStage] = useState('all'); const [fFunnel, setFFunnel] = useState('all'); const [fSource, setFSource] = useState('all'); const [fGrade, setFGrade] = useState('all'); const [fBranch, setFBranch] = useState('all'); const [fGroup, setFGroup] = useState('all'); const [fAssignee, setFAssignee] = useState('all'); const [fHot, setFHot] = useState(false); const [assign, setAssign] = useState(null); let rows = SalesAccess.scoped(leads, viewer); if (fFunnel !== 'all') rows = rows.filter(l => (AAU.stageById(l.stage) || {}).funnel === fFunnel); if (fStage !== 'all') rows = rows.filter(l => l.stage === fStage); if (fSource !== 'all') rows = rows.filter(l => l.source === fSource); if (fGrade !== 'all') rows = rows.filter(l => l.grade === fGrade); if (fBranch !== 'all') rows = rows.filter(l => l.branch === fBranch); if (fGroup !== 'all') rows = rows.filter(l => l.courseInterest === fGroup); if (fAssignee !== 'all') rows = rows.filter(l => fAssignee === 'none' ? !l.assignedTo : l.assignedTo === fAssignee); if (fHot) rows = rows.filter(l => l.hot); const cols = [ { key: 'company', label: 'Khách hàng', render: l =>