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
feat: add JobCard component for the jobs card view
Khuram Niaz982285079ace
diff --git a/__tests__/JobCard.spec.tsx b/__tests__/JobCard.spec.tsxnew file mode 100644index 0000000..750fb05--- /dev/null+++ b/__tests__/JobCard.spec.tsx@@ -0,0 +1,110 @@+import { render, screen } from "@testing-library/react";+import { JobCard } from "@/components/myjobs/JobCard";+import type { JobResponse, JobStatus } from "@/models/job.model";++vi.mock("next/navigation", () => ({+ useRouter: () => ({ push: vi.fn() }),+}));++const mockStatuses: JobStatus[] = [+ { id: "1", label: "Applied", value: "applied" },+ { id: "2", label: "Interview", value: "interview" },+ { id: "3", label: "Draft", value: "draft" },+];++function makeJob(overrides: Partial<JobResponse> = {}): JobResponse {+ return {+ id: "job-1",+ userId: "user-1",+ JobTitle: { id: "1", label: "Software Engineer", value: "software engineer" },+ Company: { id: "1", label: "Acme Corp", value: "acme corp", logoUrl: "" },+ Status: { id: "1", label: "Applied", value: "applied" },+ Location: { id: "1", label: "Remote", value: "remote" },+ JobSource: { id: "1", label: "Indeed", value: "indeed" },+ jobType: "FT",+ createdAt: new Date(2024, 5, 1),+ appliedDate: new Date(2024, 5, 1),+ dueDate: new Date("2099-01-01"),+ salaryRange: "",+ description: "",+ jobUrl: "",+ applied: true,+ ...overrides,+ } as JobResponse;+}++function renderCard(job: JobResponse) {+ return render(+ <JobCard+ job={job}+ jobStatuses={mockStatuses}+ editJob={vi.fn()}+ onChangeJobStatus={vi.fn()}+ onAddNote={vi.fn()}+ onDeleteJob={vi.fn()}+ />,+ );+}++describe("JobCard", () => {+ it("renders the title as a link to the job details page", () => {+ renderCard(makeJob());++ const link = screen.getByRole("link", { name: "Software Engineer" });+ expect(link).toHaveAttribute("href", "/dashboard/myjobs/job-1");+ expect(screen.getByText("Acme Corp")).toBeInTheDocument();+ expect(screen.getByText("Remote")).toBeInTheDocument();+ expect(screen.getByText("Indeed")).toBeInTheDocument();+ });++ it("shows the applied date when present and 'Not applied' otherwise", () => {+ const { unmount } = renderCard(makeJob());+ expect(screen.getByText("Jun 1, 2024")).toBeInTheDocument();+ unmount();++ renderCard(makeJob({ appliedDate: null as unknown as Date }));+ expect(screen.getByText("Not applied")).toBeInTheDocument();+ });++ it("renders the match score, or an empty ring when there is none", () => {+ const { unmount } = renderCard(makeJob({ matchScore: 87 }));+ expect(screen.getByText("87%")).toBeInTheDocument();+ unmount();++ renderCard(makeJob({ matchScore: null }));+ expect(screen.getByTitle("No match score")).toBeInTheDocument();+ });++ it("shows a Dismissed badge for dismissed discovered jobs", () => {+ renderCard(makeJob({ discoveryStatus: "dismissed" }));++ expect(screen.getByText("Dismissed")).toBeInTheDocument();+ expect(screen.queryByText("Applied")).not.toBeInTheDocument();+ });++ it("shows an Expired badge for past-due draft jobs", () => {+ renderCard(+ makeJob({+ dueDate: new Date("2000-01-01"),+ Status: { id: "3", label: "Draft", value: "draft" },+ }),+ );++ expect(screen.getByText("Expired")).toBeInTheDocument();+ });++ it("shows a notes count badge only when the job has notes", () => {+ const { unmount } = renderCard(makeJob({ _count: { Notes: 3 } }));+ expect(screen.getByText("3")).toBeInTheDocument();+ unmount();++ renderCard(makeJob({ _count: { Notes: 0 } }));+ expect(screen.queryByText("0")).not.toBeInTheDocument();+ });++ it("renders the shared actions menu trigger", () => {+ renderCard(makeJob());++ expect(screen.getByTestId("job-actions-menu-btn")).toBeInTheDocument();+ });+});diff --git a/src/components/myjobs/JobCard.tsx b/src/components/myjobs/JobCard.tsxnew file mode 100644index 0000000..6b29442--- /dev/null+++ b/src/components/myjobs/JobCard.tsx@@ -0,0 +1,109 @@+"use client";+import { Calendar, MapPin, PlusCircle, StickyNote } from "lucide-react";+import { format } from "date-fns";+import Link from "next/link";+import { Badge } from "../ui/badge";+import { CircularScore } from "@/components/CircularScore";+import { JobResponse, JobStatus } from "@/models/job.model";+import { JobStatusBadge } from "./JobStatusBadge";+import { JobActionsMenu } from "./JobActionsMenu";++type JobCardProps = {+ job: JobResponse;+ jobStatuses: JobStatus[];+ editJob: (id: string) => void;+ onChangeJobStatus: (id: string, status: JobStatus) => void;+ onAddNote: (jobId: string) => void;+ onDeleteJob: (jobId: string) => void;+};++export function JobCard({+ job,+ jobStatuses,+ editJob,+ onChangeJobStatus,+ onAddNote,+ onDeleteJob,+}: JobCardProps) {+ const notesCount = job._count?.Notes ?? 0;++ return (+ <div className="flex flex-col gap-3 rounded-lg border bg-card p-4">+ <div className="flex items-start gap-3">+ {/* eslint-disable-next-line @next/next/no-img-element */}+ <img+ alt="Company logo"+ className="h-10 w-10 min-w-10 rounded-md object-cover"+ src={job.Company?.logoUrl || "/images/jobsync-logo.svg"}+ onError={(e) => {+ e.currentTarget.onerror = null;+ e.currentTarget.src = "/images/jobsync-logo.svg";+ }}+ />+ <div className="min-w-0 flex-1">+ <div className="flex items-center gap-1.5">+ <Link+ href={`/dashboard/myjobs/${job?.id}`}+ className="truncate font-semibold"+ >+ {job.JobTitle?.label}+ </Link>+ {notesCount > 0 && (+ <Badge+ variant="secondary"+ className="h-5 shrink-0 px-1.5 py-0 text-xs"+ >+ <StickyNote className="mr-0.5 h-3 w-3" />+ {notesCount}+ </Badge>+ )}+ </div>+ <p className="truncate text-sm text-muted-foreground">+ {job.Company?.label}+ </p>+ </div>+ {job.matchScore != null ? (+ <CircularScore score={job.matchScore} size="sm" animate={false} />+ ) : (+ <div+ title="No match score"+ className="flex h-10 w-10 shrink-0 items-center justify-center rounded-full border-4 border-muted text-xs text-muted-foreground"+ >+ –+ </div>+ )}+ </div>++ <div className="flex flex-wrap items-center gap-x-4 gap-y-1 text-sm text-muted-foreground">+ {job.Location?.label && (+ <span className="flex min-w-0 items-center gap-1">+ <MapPin className="h-3.5 w-3.5 shrink-0" />+ <span className="truncate">{job.Location.label}</span>+ </span>+ )}+ <span className="flex items-center gap-1 whitespace-nowrap">+ <Calendar className="h-3.5 w-3.5 shrink-0" />+ {job.appliedDate ? format(job.appliedDate, "PP") : "Not applied"}+ </span>+ {job.JobSource?.label && (+ <span className="flex min-w-0 items-center gap-1">+ <PlusCircle className="h-3.5 w-3.5 shrink-0" />+ <span className="truncate">{job.JobSource.label}</span>+ </span>+ )}+ </div>++ <div className="mt-auto flex items-center justify-between border-t pt-3">+ <JobStatusBadge job={job} />+ <JobActionsMenu+ job={job}+ jobStatuses={jobStatuses}+ editJob={editJob}+ onChangeJobStatus={onChangeJobStatus}+ onAddNote={onAddNote}+ onDeleteJob={onDeleteJob}+ />+ </div>+ </div>+ );+}