Skip to content

Commit

Permalink
copy resume
Browse files Browse the repository at this point in the history
  • Loading branch information
Palveet committed Nov 28, 2024
1 parent 5c9ff4b commit 687432c
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 14 deletions.
3 changes: 3 additions & 0 deletions src/assets/Copy.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/components/SignUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const SignUp = () => {
const [formData, setFormData] = useState({
username: "",
email: "",
name:"",
password: "",
age: "",
dob: "",
Expand All @@ -27,6 +28,7 @@ const SignUp = () => {

try {
const response = await axios.post("http://127.0.0.1:8000/api/register/", formData);
console.log(response)
setSuccess("User registered successfully! You can now log in.");
setTimeout(() => navigate("/"), 2000);
} catch (err) {
Expand Down
37 changes: 28 additions & 9 deletions src/components/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import React, { useEffect, useState } from "react";
import axiosInstance from "../api/axios";
import { useNavigate, Link } from "react-router-dom";
import ResumeForm from "./ResumeForm";
import { ReactComponent as Edit } from '../assets/Edit.svg';
import { ReactComponent as Delete } from '../assets/delete.svg';
import { ReactComponent as Download } from '../assets/Download.svg';
import { ReactComponent as Edit } from "../assets/Edit.svg";
import { ReactComponent as Delete } from "../assets/delete.svg";
import { ReactComponent as Download } from "../assets/Download.svg";
import { ReactComponent as Copy } from "../assets/Copy.svg";

const Dashboard = () => {
const navigate = useNavigate();
const [resumes, setResumes] = useState([]);
const [editingResume, setEditingResume] = useState(null);
const [isCreating, setIsCreating] = useState(false);


useEffect(() => {
const token = localStorage.getItem("access_token");
if (!token) {
Expand Down Expand Up @@ -71,6 +71,19 @@ const Dashboard = () => {
}
};

const handleCopyResume = async (resume) => {
try {
const copiedResume = { ...resume };
delete copiedResume.id;
copiedResume.title = `${copiedResume.title} - Copy`;

await axiosInstance.post("resumes/", copiedResume);
refreshResumes();
} catch (err) {
console.error("Error copying resume:", err);
}
};

const refreshResumes = async () => {
const response = await axiosInstance.get("resumes/");
setResumes(response.data);
Expand All @@ -97,31 +110,38 @@ const Dashboard = () => {
onClick={() => handleEditResume(resume)}
title="Edit Resume"
>
<Edit style={{ width: '16px', height: '16px' }} />
<Edit style={{ width: "16px", height: "16px" }} />
</button>
<button
className="action-button delete-button"
onClick={() => handleDeleteResume(resume.id)}
title="Delete Resume"
>
<Delete style={{ width: '16px', height: '16px' }} />
<Delete style={{ width: "16px", height: "16px" }} />
</button>
<button
className="action-button download-button"
onClick={() => handleDownload(resume.id, "pdf")}
title="Download PDF"
>
<Download style={{ width: '16px', height: '16px' }} />
<Download style={{ width: "16px", height: "16px" }} />
PDF
</button>
<button
className="action-button download-button"
onClick={() => handleDownload(resume.id, "docx")}
title="Download DOCX"
>
<Download style={{ width: '16px', height: '16px' }} />
<Download style={{ width: "16px", height: "16px" }} />
DOCX
</button>
<button
className="action-button copy-button"
onClick={() => handleCopyResume(resume)}
title="Copy Resume"
>
<Copy style={{ width: "16px", height: "16px" }} />
</button>
</div>
</div>
</li>
Expand All @@ -135,7 +155,6 @@ const Dashboard = () => {
/>
)}
</div>

);
};

Expand Down
10 changes: 5 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ const Header = () => {
return (
<div className="header">
<h1>Resume Builder</h1>
<Link to="/profile">Profile</Link>
<button className="logout-button" onClick={handleLogout}>
Logout
</button>
{/* <Link to="/profile">Profile</Link> */}
{/* <button className="logout-button" onClick={handleLogout}> */}
{/* Logout */}
{/* </button> */}
</div>
);
};

const App = () => (
<Router>
<Header />
{/* <Header /> */}
<AppRoutes />
</Router>
);
Expand Down

0 comments on commit 687432c

Please sign in to comment.