tahamajs/IE / Projects /front /src /components /profile /CVGeneratorPanel.tsx
tahamajs's picture
download
raw
4.18 kB
import { useState } from "react";
import { useCVGenerator } from "@/hooks/useCVGenerator";
import { FileText, Download, Loader2 } from "lucide-react";
interface CVGeneratorPanelProps {
username: string;
}
const TEMPLATES = [
{ id: "academic", label: "Academic CV", description: "Full academic history, publications, teaching" },
{ id: "industry", label: "Industry Resume", description: "Skills-focused, project highlights" },
{ id: "funding", label: "Funding CV", description: "Grant-friendly, emphasizing impact and grants" },
];
const SECTIONS = [
{ key: "education", label: "Education", default: true },
{ key: "publications", label: "Publications", default: true },
{ key: "grants", label: "Grants & Funding", default: true },
{ key: "teaching", label: "Teaching", default: true },
{ key: "service", label: "Service", default: true },
{ key: "talks", label: "Invited Talks", default: false },
{ key: "awards", label: "Awards & Honors", default: false },
];
const FORMATS = [
{ id: "pdf", label: "PDF", icon: FileText },
{ id: "docx", label: "Word", icon: FileText },
{ id: "latex", label: "LaTeX", icon: FileText },
{ id: "html", label: "HTML", icon: FileText },
];
export function CVGeneratorPanel({ username }: CVGeneratorPanelProps) {
const { generating, generateCV } = useCVGenerator();
const [template, setTemplate] = useState("academic");
const [sections, setSections] = useState(SECTIONS.filter(s => s.default).map(s => s.key));
const [format, setFormat] = useState("pdf");
const toggleSection = (key: string) => {
setSections(prev => prev.includes(key) ? prev.filter(s => s !== key) : [...prev, key]);
};
return (
<div className="space-y-4">
<h2 className="text-xl font-bold gradient-text">CV Auto‑Generator</h2>
<p className="text-sm text-gray-500">AI builds your CV from your profile data. Export in your preferred format.</p>
{/* Template */}
<div>
<h4 className="font-semibold text-sm mb-2">Template</h4>
<div className="grid grid-cols-3 gap-2">
{TEMPLATES.map(t => (
<button
key={t.id}
onClick={() => setTemplate(t.id)}
className={`p-3 rounded-xl border-2 transition text-left ${
template === t.id ? "border-primary bg-primary/5" : "border-white/20 dark:border-white/10 hover:border-primary/50"
}`}
>
<p className="font-semibold text-sm">{t.label}</p>
<p className="text-[10px] text-gray-500 mt-0.5">{t.description}</p>
</button>
))}
</div>
</div>
{/* Sections */}
<div>
<h4 className="font-semibold text-sm mb-2">Sections to include</h4>
<div className="flex flex-wrap gap-2">
{SECTIONS.map(s => (
<button
key={s.key}
onClick={() => toggleSection(s.key)}
className={`text-xs px-3 py-1.5 rounded-full transition ${
sections.includes(s.key) ? "bg-primary text-white" : "bg-white/20 dark:bg-white/10"
}`}
>
{s.label}
</button>
))}
</div>
</div>
{/* Format */}
<div>
<h4 className="font-semibold text-sm mb-2">Format</h4>
<div className="flex gap-2">
{FORMATS.map(f => (
<button
key={f.id}
onClick={() => setFormat(f.id)}
className={`px-4 py-2 rounded-xl border-2 text-sm font-medium transition ${
format === f.id ? "border-primary bg-primary/5" : "border-white/20 dark:border-white/10"
}`}
>
{f.label}
</button>
))}
</div>
</div>
{/* Generate */}
<button
onClick={() => generateCV(format as any)} // adjust accordingly
disabled={generating}
className="btn btn-primary gap-2"
>
{generating ? <Loader2 className="w-4 h-4 animate-spin" /> : <Download className="w-4 h-4" />}
{generating ? "Generating..." : "Generate & Download CV"}
</button>
</div>
);
}

Xet Storage Details

Size:
4.18 kB
·
Xet hash:
d663138a4d328d48de876bb3746a428f5cd7257b715c3f8dde7c7e0f88976176

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.