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.
TypeScript ai-agentai-resume-analyzerapplication-trackerapplication-tracking-systematscareerjob-applicationjob-automationjob-huntingjob-searchjob-seeker-toolsjob-trackerjob-trackingjobsearchjobseekersmcpollamaresumeresume-reviewself-hosted
Update job status
Khuram Niaz111532c96972
diff --git a/src/actions/job.actions.ts b/src/actions/job.actions.tsindex 38ea826..d75bdb0 100644--- a/src/actions/job.actions.ts+++ b/src/actions/job.actions.ts@@ -1,6 +1,7 @@"use server";import prisma from "@/lib/db";import { AddJobFormSchema } from "@/models/addJobForm.schema";+import { JobStatus } from "@/models/job.model";import { getCurrentUser } from "@/utils/user.utils";import { z } from "zod";@@ -66,6 +67,7 @@ export const getJobsList = async (description: false,},orderBy: {+ createdAt: "desc",appliedDate: "desc",},}),@@ -251,6 +253,51 @@ export const updateJob = async (}};+export const updateJobStatus = async (+ jobId: string,+ status: JobStatus+): Promise<any | undefined> => {+ try {+ const user = await getCurrentUser();++ if (!user) {+ throw new Error("Not authenticated");+ }+ const dataToUpdate = () => {+ switch (status.value) {+ case "applied":+ return {+ statusId: status.id,+ applied: true,+ appliedDate: new Date(),+ };+ case "interview":+ return {+ statusId: status.id,+ applied: true,+ };+ default:+ return {+ statusId: status.id,+ };+ }+ };++ const job = prisma.job.update({+ where: {+ id: jobId,+ userId: user.id,+ },+ data: dataToUpdate(),+ });+ return job;+ } catch (error) {+ const msg = "Failed to update job status.";+ console.error(msg, error);+ throw new Error(msg);+ }+};+export const deleteJobById = async (jobId: string): Promise<any | undefined> => {diff --git a/src/components/AddJob.tsx b/src/components/AddJob.tsxindex 2e3dbeb..fd9158c 100644--- a/src/components/AddJob.tsx+++ b/src/components/AddJob.tsx@@ -67,7 +67,6 @@ export function AddJob({}: AddJobProps) {const [dialogOpen, setDialogOpen] = useState(false);const [isPending, startTransition] = useTransition();- console.log("add job");const form = useForm<z.infer<typeof AddJobFormSchema>>({resolver: zodResolver(AddJobFormSchema),defaultValues: {diff --git a/src/components/JobsContainer.tsx b/src/components/JobsContainer.tsxindex c382a61..67f0834 100644--- a/src/components/JobsContainer.tsx+++ b/src/components/JobsContainer.tsx@@ -15,6 +15,7 @@ import {deleteJobById,getJobDetails,getJobsList,+ updateJobStatus,} from "@/actions/job.actions";import { toast } from "./ui/use-toast";import {@@ -100,6 +101,7 @@ function JobsContainer({const res = await deleteJobById(jobId);if (res) {toast({+ variant: "success",description: `Job has been deleted successfully`,});}@@ -111,6 +113,17 @@ function JobsContainer({setEditJob(job);};+ const onChangeJobStatus = async (jobId: string, jobStatus: JobStatus) => {+ const job = await updateJobStatus(jobId, jobStatus);+ if (job) {+ toast({+ variant: "success",+ description: `Job has been updated successfully`,+ });+ }+ reloadJobs();+ };+const resetEditJob = () => {setEditJob(null);};@@ -175,6 +188,7 @@ function JobsContainer({{!loading ? (<MyJobsTablejobs={jobs}+ jobStatuses={statuses}currentPage={currentPage}totalPages={totalPages}jobsPerPage={jobsPerPage}@@ -182,6 +196,7 @@ function JobsContainer({onPageChange={onPageChange}deleteJob={onDeleteJob}editJob={onEditJob}+ onChangeJobStatus={onChangeJobStatus}/>) : (<Loading />diff --git a/src/components/MyJobsTable.tsx b/src/components/MyJobsTable.tsxindex d21394a..c581374 100644--- a/src/components/MyJobsTable.tsx+++ b/src/components/MyJobsTable.tsx@@ -24,6 +24,7 @@ import {DropdownMenuGroup,DropdownMenuItem,DropdownMenuLabel,+ DropdownMenuPortal,DropdownMenuSeparator,DropdownMenuSub,DropdownMenuSubContent,@@ -31,14 +32,6 @@ import {DropdownMenuTrigger,} from "./ui/dropdown-menu";import { Button, buttonVariants } from "./ui/button";-import {- Command,- CommandEmpty,- CommandGroup,- CommandInput,- CommandItem,- CommandList,-} from "./ui/command";import { useState } from "react";import { TablePagination } from "./TablePagination";import { Dialog, DialogContent, DialogTrigger } from "./ui/dialog";@@ -53,10 +46,11 @@ import {AlertDialogHeader,AlertDialogTitle,} from "./ui/alert-dialog";-import { JobResponse } from "@/models/job.model";+import { JobResponse, JobStatus } from "@/models/job.model";type MyJobsTableProps = {jobs: JobResponse[];+ jobStatuses: JobStatus[];currentPage: number;totalPages: number;totalJobs: number;@@ -64,10 +58,12 @@ type MyJobsTableProps = {onPageChange: (n: number) => void;deleteJob: (id: string) => void;editJob: (id: string) => void;+ onChangeJobStatus: (id: string, status: JobStatus) => void;};function MyJobsTable({jobs,+ jobStatuses,currentPage,totalPages,totalJobs,@@ -75,18 +71,8 @@ function MyJobsTable({onPageChange,deleteJob,editJob,+ onChangeJobStatus,}: MyJobsTableProps) {- const labels = [- "draft",- "applied",- "interview",- "expired",- "rejected",- "offer",- "archived",- ];- const [label, setLabel] = useState("feature");- const [open, setOpen] = useState(false);const [dialogOpen, setDialogOpen] = useState(false);const [alertOpen, setAlertOpen] = useState(false);const [curJobId, setCurJobId] = useState("");@@ -202,31 +188,40 @@ function MyJobsTable({<Tags className="mr-2 h-4 w-4" />Change status</DropdownMenuSubTrigger>- <DropdownMenuSubContent className="p-0">- <Command>- <CommandInput- placeholder="Filter label..."- autoFocus={true}- />+ <DropdownMenuPortal>+ <DropdownMenuSubContent className="p-0">+ {jobStatuses.map((status) => (+ <DropdownMenuItem+ className="cursor-pointer"+ key={status.id}+ onSelect={(_) => {+ onChangeJobStatus(job.id, status);+ }}+ disabled={status.id === job.Status.id}+ >+ <span>{status.label}</span>+ </DropdownMenuItem>+ ))}+ </DropdownMenuSubContent>+ </DropdownMenuPortal>+ {/* <Command><CommandList>- <CommandEmpty>No label found.</CommandEmpty><CommandGroup>- {labels.map((label) => (+ {jobStatuses.map((status) => (<CommandItem- key={label}- value={label}+ className="cursor-pointer"+ key={status.id}+ value={status.label}onSelect={(value) => {- setLabel(value);- setOpen(false);+ onChangeJobStatus(value);}}>- {label}+ {status.label}</CommandItem>))}</CommandGroup></CommandList>- </Command>- </DropdownMenuSubContent>+ </Command> */}</DropdownMenuSub><DropdownMenuSeparator /><DropdownMenuItem