Skip to content

Commit

Permalink
Merge branch 'newTool' of github.com:amanr-dev/WebDevTools into newTool
Browse files Browse the repository at this point in the history
  • Loading branch information
dipanshurdev committed Jul 29, 2024
2 parents 30fcb4d + 72a52f2 commit a1486ca
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 0 deletions.
72 changes: 72 additions & 0 deletions src/app/resume-builder/Form.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
"use client";

import { useForm } from "react-hook-form";

const Form = ({ onSubmit }) => {
const {
register,
handleSubmit,
formState: { errors },
} = useForm();

return (
<form onSubmit={handleSubmit(onSubmit)} className="space-y-4">
<div>
<label className="block">Name</label>
<input
className="border p-2 w-full"
{...register("name", { required: true })}
/>
{errors.name && (
<span className="text-red-500">This field is required</span>
)}
</div>
<div>
<label className="block">Email</label>
<input
className="border p-2 w-full"
type="email"
{...register("email", { required: true })}
/>
{errors.email && (
<span className="text-red-500">This field is required</span>
)}
</div>
<div>
<label className="block">Education</label>
<textarea
className="border p-2 w-full"
{...register("education", { required: true })}
></textarea>
{errors.education && (
<span className="text-red-500">This field is required</span>
)}
</div>
<div>
<label className="block">Experience</label>
<textarea
className="border p-2 w-full"
{...register("experience", { required: true })}
></textarea>
{errors.experience && (
<span className="text-red-500">This field is required</span>
)}
</div>
<div>
<label className="block">Skills</label>
<textarea
className="border p-2 w-full"
{...register("skills", { required: true })}
></textarea>
{errors.skills && (
<span className="text-red-500">This field is required</span>
)}
</div>
<button type="submit" className="bg-blue-500 text-white py-2 px-4">
Generate Resume
</button>
</form>
);
};

export default Form;
55 changes: 55 additions & 0 deletions src/app/resume-builder/Preview.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"use client";

import jsPDF from "jspdf";
import "jspdf-autotable";

const Preview = ({ data }) => {
const generatePDF = () => {
const doc = new jsPDF();
doc.text(data.name, 10, 10);
doc.text(data.email, 10, 20);
doc.autoTable({
startY: 30,
head: [["Education"]],
body: [[data.education]],
});
doc.autoTable({
startY: 50,
head: [["Experience"]],
body: [[data.experience]],
});
doc.autoTable({ startY: 70, head: [["Skills"]], body: [[data.skills]] });
doc.save("resume.pdf");
};

return (
<div>
<h2 className="text-xl">Preview</h2>
<div className="border p-4 mt-4">
<p>
<strong>Name:</strong> {data.name}
</p>
<p>
<strong>Email:</strong> {data.email}
</p>
<p>
<strong>Education:</strong> {data.education}
</p>
<p>
<strong>Experience:</strong> {data.experience}
</p>
<p>
<strong>Skills:</strong> {data.skills}
</p>
</div>
<button
onClick={generatePDF}
className="bg-green-500 text-white py-2 px-4 mt-4"
>
Download PDF
</button>
</div>
);
};

export default Preview;
23 changes: 23 additions & 0 deletions src/app/resume-builder/page.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"use client";

import { useState } from "react";
import Form from "./Form";
import Preview from "./Preview";

const Home = () => {
const [formData, setFormData] = useState(null);

const handleFormSubmit = (data) => {
setFormData(data);
};

return (
<div className="container mx-auto p-4">
<h1 className="text-2xl mb-4">Resume Builder</h1>
<Form onSubmit={handleFormSubmit} />
{formData && <Preview data={formData} />}
</div>
);
};

export default Home;

0 comments on commit a1486ca

Please sign in to comment.