import { useState, useRef } from 'react' import { importApi } from '../api' import { useProject } from '../contexts/ProjectContext' const TABS = [ { id: 'csv', label: '📄 CSV File', desc: 'Import any CSV with company/contact data' }, { id: 'excel', label: '📊 Excel File', desc: 'Import .xlsx or .xls spreadsheets' }, { id: 'linkedin', label: '🔗 LinkedIn Export', desc: 'Import LinkedIn connections or Sales Navigator CSV export' }, ] function DropZone({ accept, onFile }) { const [dragging, setDragging] = useState(false) const inputRef = useRef() const handleDrop = (e) => { e.preventDefault() setDragging(false) const file = e.dataTransfer.files[0] if (file) onFile(file) } return (
inputRef.current.click()} onDragOver={e => { e.preventDefault(); setDragging(true) }} onDragLeave={() => setDragging(false)} onDrop={handleDrop} style={{ border: `2px dashed ${dragging ? 'var(--accent)' : 'var(--border)'}`, borderRadius: 'var(--radius)', padding: '40px 24px', textAlign: 'center', cursor: 'pointer', background: dragging ? 'rgba(108,99,255,0.05)' : 'transparent', transition: 'all 0.15s', }} >
Drop file here or click to browse
{accept}
e.target.files[0] && onFile(e.target.files[0])} />
) } function LinkedInTip() { return (
How to export from LinkedIn:
  1. Go to LinkedIn Settings → Data Privacy → Get a copy of your data
  2. Select "Connections" and request the archive
  3. Download and upload the Connections.csv file here
  4. For Sales Navigator: Export leads directly as CSV from your lead lists
) } export default function ImportWizard() { const { activeProject } = useProject() const [tab, setTab] = useState('csv') const [file, setFile] = useState(null) const [result, setResult] = useState(null) const [error, setError] = useState(null) const [loading, setLoading] = useState(false) const handleFile = (f) => { setFile(f) setResult(null) setError(null) } const handleImport = async () => { if (!file) return setLoading(true) setResult(null) setError(null) try { const pid = activeProject?.id ?? null let res if (tab === 'csv') res = await importApi.csv(file, 'csv', pid) else if (tab === 'excel') res = await importApi.excel(file, 'excel', pid) else res = await importApi.linkedin(file, pid) setResult(res) setFile(null) } catch (e) { setError(e.message) } finally { setLoading(false) } } const currentTab = TABS.find(t => t.id === tab) return (

Import Leads

{activeProject &&
Importing into: {activeProject.name}
}
{/* Tabs */}
{TABS.map(t => ( ))}

{currentTab.desc}

{tab === 'linkedin' && } {result && (
✅ Successfully imported {result.imported} leads from {result.total_rows} rows. {' '}View all leads →
)} {error &&
❌ {error}
} {file && (
{tab === 'excel' ? '📊' : '📄'}
{file.name}
{(file.size / 1024).toFixed(1)} KB
)}
{result && ( )}
{/* Column mapping guide */}
Supported Column Names
The importer auto-detects these column headers (case-insensitive):
{[ ['Company / Organization / Account Name', '→ company_name'], ['Name / Full Name / Contact Name', '→ contact_name'], ['First Name + Last Name', '→ combined contact_name'], ['Email / Email Address', '→ email'], ['Phone / Mobile / Telephone', '→ phone'], ['Website / URL', '→ website'], ['Industry / Sector / Vertical', '→ industry'], ['Company Size / Employees', '→ company_size'], ['Location / City / Country', '→ location'], ['LinkedIn / LinkedIn URL', '→ linkedin_url'], ['Notes / Comments / Description', '→ notes'], ].map(([k, v]) => (
{k} {v}
))}
Any other columns will be saved as custom fields.
) }