Skip to content

Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.

Link job with resume

Khuram Niaz29a6205cad7b
diff --git a/src/actions/job.actions.ts b/src/actions/job.actions.ts
index 028e290..9080e70 100644
--- a/src/actions/job.actions.ts
+++ b/src/actions/job.actions.ts
@@ -65,6 +65,7 @@ export const getJobsList = async (
dueDate: true,
appliedDate: true,
description: false,
+ Resume: true,
},
orderBy: {
createdAt: "desc",
@@ -108,6 +109,11 @@ export const getJobDetails = async (
Company: true,
Status: true,
Location: true,
+ Resume: {
+ include: {
+ File: true,
+ },
+ },
},
});
return { job, success: true };
@@ -167,6 +173,7 @@ export const addJob = async (
jobDescription,
jobUrl,
applied,
+ resume,
} = data;
const job = await prisma.job.create({
@@ -185,6 +192,7 @@ export const addJob = async (
userId: user.id,
jobUrl,
applied,
+ resumeId: resume,
},
});
diff --git a/src/app/dashboard/myjobs/[id]/page.tsx b/src/app/dashboard/myjobs/[id]/page.tsx
index 03b4588..547ff5d 100644
--- a/src/app/dashboard/myjobs/[id]/page.tsx
+++ b/src/app/dashboard/myjobs/[id]/page.tsx
@@ -1,6 +1,5 @@
import { getJobDetails } from "@/actions/job.actions";
import JobDetails from "@/components/myjobs/JobDetails";
-import { toast } from "@/components/ui/use-toast";
async function JobDetailsPage({ params }: any) {
const { id } = params;
diff --git a/src/app/dashboard/myjobs/page.tsx b/src/app/dashboard/myjobs/page.tsx
index 90bf512..3a4deab 100644
--- a/src/app/dashboard/myjobs/page.tsx
+++ b/src/app/dashboard/myjobs/page.tsx
@@ -5,19 +5,22 @@ import JobsContainer from "@/components/myjobs/JobsContainer";
import { getAllCompanies } from "@/actions/company.actions";
import { getAllJobTitles } from "@/actions/jobtitle.actions";
import { getAllJobLocations } from "@/actions/jobLocation.actions";
+import { getResumeList } from "@/actions/profile.actions";
export const metadata: Metadata = {
title: "My Jobs | JobSync",
};
async function MyJobs() {
- const [statuses, companies, titles, locations, sources] = await Promise.all([
- getStatusList(),
- getAllCompanies(),
- getAllJobTitles(),
- getAllJobLocations(),
- getJobSourceList(),
- ]);
+ const [statuses, companies, titles, locations, sources, resumes] =
+ await Promise.all([
+ getStatusList(),
+ getAllCompanies(),
+ getAllJobTitles(),
+ getAllJobLocations(),
+ getJobSourceList(),
+ getResumeList(),
+ ]);
return (
<div className="col-span-3">
<JobsContainer
@@ -26,6 +29,7 @@ async function MyJobs() {
locations={locations}
sources={sources}
statuses={statuses}
+ resumes={resumes.data}
/>
</div>
);
diff --git a/src/components/Select.tsx b/src/components/Select.tsx
index c904f8f..3b98416 100644
--- a/src/components/Select.tsx
+++ b/src/components/Select.tsx
@@ -39,7 +39,7 @@ function SelectFormCtrl({ label, options, field }: SelectProps) {
value={option.id}
className="capitalize"
>
- {option.label ?? option.value}
+ {option.label ?? option.value ?? option.title}
</SelectItem>
);
})}
diff --git a/src/components/myjobs/AddJob.tsx b/src/components/myjobs/AddJob.tsx
index a0cc334..50c1c5d 100644
--- a/src/components/myjobs/AddJob.tsx
+++ b/src/components/myjobs/AddJob.tsx
@@ -43,6 +43,7 @@ import { Input } from "../ui/input";
import { Switch } from "../ui/switch";
import { redirect } from "next/navigation";
import { Combobox } from "../ComboBox";
+import { Resume } from "@/models/profile.model";
type AddJobProps = {
jobStatuses: JobStatus[];
@@ -50,6 +51,7 @@ type AddJobProps = {
jobTitles: JobTitle[];
locations: JobLocation[];
jobSources: JobSource[];
+ resumes: Resume[];
editJob?: JobResponse | null;
resetEditJob: () => void;
};
@@ -60,6 +62,7 @@ export function AddJob({
jobTitles,
locations,
jobSources,
+ resumes,
editJob,
resetEditJob,
}: AddJobProps) {
@@ -413,6 +416,25 @@ export function AddJob({
/>
</div>
+ {/* Resume */}
+ <div>
+ <FormField
+ control={form.control}
+ name="resume"
+ render={({ field }) => (
+ <FormItem className="flex flex-col [&>button]:capitalize">
+ <FormLabel>Resume</FormLabel>
+ <SelectFormCtrl
+ label="Resume"
+ options={resumes}
+ field={field}
+ />
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ </div>
+
{/* Job Description */}
<div className="md:col-span-2">
<FormField
diff --git a/src/components/myjobs/JobDetails.tsx b/src/components/myjobs/JobDetails.tsx
index 52e47ba..5c025f9 100644
--- a/src/components/myjobs/JobDetails.tsx
+++ b/src/components/myjobs/JobDetails.tsx
@@ -16,8 +16,10 @@ import { ArrowLeft, Sparkles } from "lucide-react";
import { useRouter } from "next/navigation";
import { AiJobMatchSection } from "../profile/AiJobMatchSection";
import { useState } from "react";
+import { DownloadFileButton } from "../profile/DownloadFileButton";
function JobDetails({ job }: { job: JobResponse }) {
+ console.log(job);
const [aiSectionOpen, setAiSectionOpen] = useState(false);
const router = useRouter();
const goBack = () => router.back();
@@ -57,12 +59,23 @@ function JobDetails({ job }: { job: JobResponse }) {
</div>
{job?.id && (
<Card className="col-span-3">
- <CardHeader>
- {job?.Company?.label}
- <CardTitle>{job?.JobTitle?.label}</CardTitle>
- <CardDescription>
- {job?.Location?.label} - {getJobType(job?.jobType)}
- </CardDescription>
+ <CardHeader className="flex-row justify-between relative">
+ <div>
+ {job?.Company?.label}
+ <CardTitle>{job?.JobTitle?.label}</CardTitle>
+ <CardDescription>
+ {job?.Location?.label} - {getJobType(job?.jobType)}
+ </CardDescription>
+ </div>
+ <div>
+ {job?.Resume && job?.Resume?.File && job.Resume?.File?.filePath
+ ? DownloadFileButton(
+ job?.Resume?.File?.filePath,
+ job?.Resume?.title,
+ job?.Resume?.File?.fileName
+ )
+ : null}
+ </div>
</CardHeader>
<h3 className="ml-4">
{new Date() > job.dueDate && job.Status?.value === "draft" ? (
diff --git a/src/components/myjobs/JobsContainer.tsx b/src/components/myjobs/JobsContainer.tsx
index 10f7f07..50c8228 100644
--- a/src/components/myjobs/JobsContainer.tsx
+++ b/src/components/myjobs/JobsContainer.tsx
@@ -39,6 +39,7 @@ import Loading from "../Loading";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { AddJob } from "./AddJob";
import MyJobsTable from "./MyJobsTable";
+import { Resume } from "@/models/profile.model";
type MyJobsProps = {
statuses: JobStatus[];
@@ -46,6 +47,7 @@ type MyJobsProps = {
titles: JobTitle[];
locations: JobLocation[];
sources: JobSource[];
+ resumes: Resume[];
};
function JobsContainer({
@@ -54,11 +56,11 @@ function JobsContainer({
titles,
locations,
sources,
+ resumes,
}: MyJobsProps) {
const router = useRouter();
const pathname = usePathname();
const queryParams = useSearchParams();
-
const createQueryString = useCallback(
(name: string, value: string) => {
const params = new URLSearchParams(queryParams.toString());
@@ -88,6 +90,7 @@ function JobsContainer({
jobsPerPage,
filter
);
+ console.log(data);
if (!success) {
toast({
variant: "destructive",
@@ -210,6 +213,7 @@ function JobsContainer({
jobTitles={titles}
locations={locations}
jobSources={sources}
+ resumes={resumes}
editJob={editJob}
resetEditJob={resetEditJob}
/>
diff --git a/src/components/profile/DownloadFileButton.tsx b/src/components/profile/DownloadFileButton.tsx
new file mode 100644
index 0000000..642a58a
--- /dev/null
+++ b/src/components/profile/DownloadFileButton.tsx
@@ -0,0 +1,43 @@
+import { Paperclip } from "lucide-react";
+
+export function DownloadFileButton(
+ filePath: any,
+ fileTitle: string,
+ fileName: string
+) {
+ const handleDownload = async () => {
+ const response = await fetch(
+ `/api/profile/resume?filePath=${encodeURIComponent(filePath)}`,
+ {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ }
+ );
+
+ if (response.ok) {
+ const blob = await response.blob();
+ const url = window.URL.createObjectURL(blob);
+ const link = document.createElement("a");
+ link.href = url;
+ link.download = filePath.split("/").pop(); // Get the file name
+ link.target = "_blank";
+ link.click();
+ window.URL.revokeObjectURL(url); // Clean up
+ } else {
+ console.error("Failed to download file");
+ }
+ };
+
+ return (
+ <button
+ className="flex items-center"
+ onClick={handleDownload}
+ title={`Download ${fileName}`}
+ >
+ <div>{fileTitle}</div>
+ <Paperclip className="h-3.5 w-3.5 ml-1" />
+ </button>
+ );
+}
diff --git a/src/components/profile/ResumeContainer.tsx b/src/components/profile/ResumeContainer.tsx
index 4d1b6cf..0da8f92 100644
--- a/src/components/profile/ResumeContainer.tsx
+++ b/src/components/profile/ResumeContainer.tsx
@@ -8,7 +8,7 @@ import SummarySectionCard from "./SummarySectionCard";
import ExperienceCard from "./ExperienceCard";
import EducationCard from "./EducationCard";
import AiResumeReviewSection from "./AiResumeReviewSection";
-import { Paperclip } from "lucide-react";
+import { DownloadFileButton } from "./DownloadFileButton";
function ResumeContainer({ resume }: { resume: Resume }) {
const resumeSectionRef = useRef<AddResumeSectionRef>(null);
@@ -47,44 +47,6 @@ function ResumeContainer({ resume }: { resume: Resume }) {
resumeSectionRef.current?.openEducationDialog(section);
};
- function DownloadFileButton(filePath: any, fileName: string) {
- const handleDownload = async () => {
- const response = await fetch(
- `/api/profile/resume?filePath=${encodeURIComponent(filePath)}`,
- {
- method: "GET",
- headers: {
- "Content-Type": "application/json",
- },
- }
- );
-
- if (response.ok) {
- const blob = await response.blob();
- const url = window.URL.createObjectURL(blob);
- const link = document.createElement("a");
- link.href = url;
- link.download = filePath.split("/").pop(); // Get the file name
- link.target = "_blank";
- link.click();
- window.URL.revokeObjectURL(url); // Clean up
- } else {
- console.error("Failed to download file");
- }
- };
-
- return (
- <button
- className="flex items-center"
- onClick={handleDownload}
- title="Download resume"
- >
- <div>{fileName}</div>
- <Paperclip className="h-3.5 w-3.5 ml-1" />
- </button>
- );
- }
-
return (
<>
<Card>
@@ -92,7 +54,11 @@ function ResumeContainer({ resume }: { resume: Resume }) {
<CardTitle>Resume</CardTitle>
<CardDescription>
{resume.FileId && resume.File?.filePath
- ? DownloadFileButton(resume.File?.filePath, title)
+ ? DownloadFileButton(
+ resume.File?.filePath,
+ title,
+ resume.File?.fileName
+ )
: title}
</CardDescription>
<div className="flex items-center">
diff --git a/src/models/addJobForm.schema.ts b/src/models/addJobForm.schema.ts
index 4d5e90e..64ebdeb 100644
--- a/src/models/addJobForm.schema.ts
+++ b/src/models/addJobForm.schema.ts
@@ -57,4 +57,5 @@ export const AddJobFormSchema = z.object({
}),
jobUrl: z.string().optional(),
applied: z.boolean().default(false),
+ resume: z.string().optional(),
});
diff --git a/src/models/job.model.ts b/src/models/job.model.ts
index 21a2280..5e78625 100644
--- a/src/models/job.model.ts
+++ b/src/models/job.model.ts
@@ -1,3 +1,5 @@
+import { Resume } from "./profile.model";
+
export interface JobForm {
id?: string;
userId?: string;
@@ -31,6 +33,8 @@ export interface JobResponse {
description: string;
jobUrl: string;
applied: boolean;
+ resumeId?: string;
+ Resume?: Resume;
}
export interface JobTitle {