Talent Pool: Export button beside All Departments filter (client-side CSV of filtered grid)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
pull/44/head
Talha Ahmed 2026-09-01 19:31:22 +05:00
parent cf40e43423
commit 88b6c96a11
1 changed files with 35 additions and 0 deletions

View File

@ -227,6 +227,38 @@ export default function TalentPool() {
toast(`${c.name} moved to ${stage}`, 'success')
}
/* CSV of the FILTERED grid, built client-side there is no /candidate export
endpoint (jobs and reports each own theirs). Exporting `list` rather than
`pool` means the file always matches what the recruiter is looking at,
search and department filter included. Company/skills are seed-overlay
values, same as the cards render. */
function exportCsv() {
if (!list.length) {
toast('Nothing to export — current filters match no candidates', 'warning')
return
}
const esc = (v) => {
const s = v == null ? '' : String(v)
return /[",\n]/.test(s) ? `"${s.replaceAll('"', '""')}"` : s
}
const header = ['Name', 'Email', 'Current Title', 'Company', 'Departments', 'Stage', 'Experience (yrs)', 'Source', 'AI Score', 'Skills']
const lines = list.map((c) => [
c.name, c.email, c.currentTitle, c.currentCompany,
(c.departments || []).join('; '), c.stage, c.experience,
c.source, c.aiScore ?? '', (c.skills || []).join('; '),
].map(esc).join(','))
const blob = new Blob([[header.join(','), ...lines].join('\n')], { type: 'text/csv;charset=utf-8' })
const url = URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = `talent-pool-${new Date().toISOString().slice(0, 10)}.csv`
document.body.appendChild(a)
a.click()
a.remove()
URL.revokeObjectURL(url)
toast(`Exported ${list.length} candidate${list.length === 1 ? '' : 's'} to CSV`, 'success')
}
return (
<div className="page">
<PageHeader
@ -250,6 +282,9 @@ export default function TalentPool() {
<option value="">All Departments</option>
{departments.map((d) => <option key={d} value={d}>{d}</option>)}
</select>
<button className="btn btn-secondary" onClick={exportCsv}>
<Icon name="download" /> Export
</button>
<PageSizeField
value={pageSize}
onChange={setPageSize}