Resume
import { useState } from 'react'
import { Button } from "/components/ui/button"
import { Input } from "/components/ui/input"
import { Textarea } from "/components/ui/textarea"
import { Card, CardContent, CardHeader, CardTitle } from "/components/ui/card"
import { Label } from "/components/ui/label"
type Education = {
institution: string
degree: string
startDate: string
endDate: string
}
type Experience = {
company: string
position: string
startDate: string
endDate: string
description: string
}
export default function ResumeGenerator() {
const [personalInfo, setPersonalInfo] = useState({
name: '',
email: '',
phone: '',
address: '',
summary: ''
})
const [educations, setEducations] = useState([{
institution: '',
degree: '',
startDate: '',
endDate: ''
}])
const [experiences, setExperiences] = useState([{
company: '',
position: '',
startDate: '',
endDate: '',
description: ''
}])
const [skills, setSkills] = useState([''])
const [showResume, setShowResume] = useState(false)
const handlePersonalInfoChange = (e: React.ChangeEvent) => {
const { name, value } = e.target
setPersonalInfo(prev => ({ ...prev, [name]: value }))
}
const handleEducationChange = (index: number, field: keyof Education, value: string) => {
const newEducations = [...educations]
newEducations[index][field] = value
setEducations(newEducations)
}
const handleExperienceChange = (index: number, field: keyof Experience, value: string) => {
const newExperiences = [...experiences]
newExperiences[index][field] = value
setExperiences(newExperiences)
}
const handleSkillChange = (index: number, value: string) => {
const newSkills = [...skills]
newSkills[index] = value
setSkills(newSkills)
}
const addEducation = () => {
setEducations([...educations, {
institution: '',
degree: '',
startDate: '',
endDate: ''
}])
}
const addExperience = () => {
setExperiences([...experiences, {
company: '',
position: '',
startDate: '',
endDate: '',
description: ''
}])
}
const addSkill = () => {
setSkills([...skills, ''])
}
const removeEducation = (index: number) => {
if (educations.length > 1) {
const newEducations = [...educations]
newEducations.splice(index, 1)
setEducations(newEducations)
}
}
const removeExperience = (index: number) => {
if (experiences.length > 1) {
const newExperiences = [...experiences]
newExperiences.splice(index, 1)
setExperiences(newExperiences)
}
}
const removeSkill = (index: number) => {
if (skills.length > 1) {
const newSkills = [...skills]
newSkills.splice(index, 1)
setSkills(newSkills)
}
}
return (
)
}
Resume Generator
{!showResume ? (
{/* Input Form */}
Enter Your Information
{/* Personal Info */}
{/* Education */}
))}
{/* Experience */}
))}
{/* Skills */}
{/* Preview */}
Resume Preview
{personalInfo.summary && (
)}
{educations.some(edu => edu.institution) && (
)
))}
)}
{experiences.some(exp => exp.company) && (
)
))}
)}
{skills.some(skill => skill) && (
)}
) : (
Personal Information
Education
{educations.map((edu, index) => (Education #{index + 1}
{educations.length > 1 && ( )}
handleEducationChange(index, 'institution', e.target.value)}
placeholder="University Name"
/>
handleEducationChange(index, 'degree', e.target.value)}
placeholder="Bachelor of Science"
/>
handleEducationChange(index, 'startDate', e.target.value)}
placeholder="MM/YYYY"
/>
handleEducationChange(index, 'endDate', e.target.value)}
placeholder="MM/YYYY or Present"
/>
Work Experience
{experiences.map((exp, index) => (Experience #{index + 1}
{experiences.length > 1 && ( )}
handleExperienceChange(index, 'company', e.target.value)}
placeholder="Company Name"
/>
handleExperienceChange(index, 'position', e.target.value)}
placeholder="Job Title"
/>
handleExperienceChange(index, 'startDate', e.target.value)}
placeholder="MM/YYYY"
/>
handleExperienceChange(index, 'endDate', e.target.value)}
placeholder="MM/YYYY or Present"
/>
Skills
{skills.map((skill, index) => (
handleSkillChange(index, e.target.value)}
placeholder="Skill (e.g., JavaScript, Project Management)"
/>
{skills.length > 1 && (
)}
))}
{personalInfo.name || 'Your Name'}
{personalInfo.email && {personalInfo.email}}
{personalInfo.phone && {personalInfo.phone}}
{personalInfo.address && {personalInfo.address}}
Summary
{personalInfo.summary}
Education
{educations.map((edu, index) => ( edu.institution && (
{edu.institution}
{edu.startDate} - {edu.endDate}
{edu.degree}
Experience
{experiences.map((exp, index) => ( exp.company && (
{exp.company}
{exp.startDate} - {exp.endDate}
{exp.position}
{exp.description && ({exp.description}
)}Skills
{skills.map((skill, index) => (
skill && (
{skill}
)
))}
{/* Generated Resume */}
{personalInfo.summary && (
)}
{educations.some(edu => edu.institution) && (
)
))}
)}
{experiences.some(exp => exp.company) && (
)
))}
)}
{skills.some(skill => skill) && (
)}
)}
{personalInfo.name || 'Your Name'}
{personalInfo.email && {personalInfo.email}}
{personalInfo.phone && {personalInfo.phone}}
{personalInfo.address && {personalInfo.address}}
Summary
{personalInfo.summary}
Education
{educations.map((edu, index) => ( edu.institution && (
{edu.institution}
{edu.startDate} - {edu.endDate}
{edu.degree}
Experience
{experiences.map((exp, index) => ( exp.company && (
{exp.company}
{exp.startDate} - {exp.endDate}
{exp.position}
{exp.description && ({exp.description}
)}Skills
{skills.map((skill, index) => (
skill && (
{skill}
)
))}
Comments
Post a Comment