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: Clickable number of jobs for locations
Khuram Niaz7074aec1a6ff
diff --git a/__tests__/JobsContainer.spec.tsx b/__tests__/JobsContainer.spec.tsxindex efc57ec..7559b26 100644--- a/__tests__/JobsContainer.spec.tsx+++ b/__tests__/JobsContainer.spec.tsx@@ -322,7 +322,7 @@ describe("JobsContainer Search Functionality", () => {});await waitFor(() => {- expect(getJobsList).toHaveBeenCalledWith(1, 25, undefined, "Amazon", undefined, undefined, undefined);+ expect(getJobsList).toHaveBeenCalledWith(1, 25, undefined, "Amazon", undefined, undefined, undefined, undefined);});});@@ -340,7 +340,7 @@ describe("JobsContainer Search Functionality", () => {});// Initial call should not have search parameter- expect(getJobsList).toHaveBeenCalledWith(1, 25, undefined, undefined, undefined, undefined, undefined);+ expect(getJobsList).toHaveBeenCalledWith(1, 25, undefined, undefined, undefined, undefined, undefined, undefined);});it("should trigger search when clearing search term after searching", async () => {@@ -368,7 +368,7 @@ describe("JobsContainer Search Functionality", () => {});await waitFor(() => {- expect(getJobsList).toHaveBeenCalledWith(1, 25, undefined, "Test", undefined, undefined, undefined);+ expect(getJobsList).toHaveBeenCalledWith(1, 25, undefined, "Test", undefined, undefined, undefined, undefined);});// Clear the search input@@ -382,7 +382,7 @@ describe("JobsContainer Search Functionality", () => {// Should call with undefined when cleared after having searchedawait waitFor(() => {- expect(getJobsList).toHaveBeenCalledWith(1, 25, undefined, undefined, undefined, undefined, undefined);+ expect(getJobsList).toHaveBeenCalledWith(1, 25, undefined, undefined, undefined, undefined, undefined, undefined);});});});@@ -414,7 +414,7 @@ describe("JobsContainer Search Functionality", () => {});await waitFor(() => {- expect(getJobsList).toHaveBeenCalledWith(1, 25, undefined, "Developer", undefined, undefined, undefined);+ expect(getJobsList).toHaveBeenCalledWith(1, 25, undefined, "Developer", undefined, undefined, undefined, undefined);});// Now change filter@@ -429,7 +429,7 @@ describe("JobsContainer Search Functionality", () => {});await waitFor(() => {- expect(getJobsList).toHaveBeenCalledWith(1, 25, "applied", "Developer", undefined, undefined, undefined);+ expect(getJobsList).toHaveBeenCalledWith(1, 25, "applied", "Developer", undefined, undefined, undefined, undefined);});});@@ -457,7 +457,7 @@ describe("JobsContainer Search Functionality", () => {});await waitFor(() => {- expect(getJobsList).toHaveBeenCalledWith(1, 25, undefined, "Amazon", undefined, undefined, undefined);+ expect(getJobsList).toHaveBeenCalledWith(1, 25, undefined, "Amazon", undefined, undefined, undefined, undefined);});// Change filter@@ -473,7 +473,7 @@ describe("JobsContainer Search Functionality", () => {// Search term should still be presentawait waitFor(() => {- expect(getJobsList).toHaveBeenCalledWith(1, 25, "interview", "Amazon", undefined, undefined, undefined);+ expect(getJobsList).toHaveBeenCalledWith(1, 25, "interview", "Amazon", undefined, undefined, undefined, undefined);});});@@ -512,7 +512,7 @@ describe("JobsContainer Search Functionality", () => {});await waitFor(() => {- expect(getJobsList).toHaveBeenCalledWith(1, 25, "applied", "Developer", undefined, undefined, undefined);+ expect(getJobsList).toHaveBeenCalledWith(1, 25, "applied", "Developer", undefined, undefined, undefined, undefined);});// Now clear filter by selecting None@@ -527,7 +527,7 @@ describe("JobsContainer Search Functionality", () => {// Filter should be cleared but search preservedawait waitFor(() => {- expect(getJobsList).toHaveBeenCalledWith(1, 25, undefined, "Developer", undefined, undefined, undefined);+ expect(getJobsList).toHaveBeenCalledWith(1, 25, undefined, "Developer", undefined, undefined, undefined, undefined);});});});@@ -639,7 +639,7 @@ describe("JobsContainer Search Functionality", () => {});await waitFor(() => {- expect(getJobsList).toHaveBeenCalledWith(1, 25, undefined, "Developer", undefined, undefined, undefined);+ expect(getJobsList).toHaveBeenCalledWith(1, 25, undefined, "Developer", undefined, undefined, undefined, undefined);});// Click load more@@ -650,7 +650,7 @@ describe("JobsContainer Search Functionality", () => {// Should include search term in load more callawait waitFor(() => {- expect(getJobsList).toHaveBeenCalledWith(2, 25, undefined, "Developer", undefined, undefined, undefined);+ expect(getJobsList).toHaveBeenCalledWith(2, 25, undefined, "Developer", undefined, undefined, undefined, undefined);});});});@@ -684,7 +684,7 @@ describe("JobsContainer Search Functionality", () => {});await waitFor(() => {- expect(getJobsList).toHaveBeenCalledWith(1, 25, undefined, "test", undefined, undefined, undefined);+ expect(getJobsList).toHaveBeenCalledWith(1, 25, undefined, "test", undefined, undefined, undefined, undefined);});});});@@ -702,7 +702,7 @@ describe("JobsContainer Search Functionality", () => {renderComponent();await waitFor(() => {- expect(getJobsList).toHaveBeenCalledWith(1, 25, undefined, undefined, "google", true, undefined);+ expect(getJobsList).toHaveBeenCalledWith(1, 25, undefined, undefined, "google", true, undefined, undefined);});});@@ -776,7 +776,7 @@ describe("JobsContainer Search Functionality", () => {renderComponent();await waitFor(() => {- expect(getJobsList).toHaveBeenCalledWith(1, 25, undefined, undefined, "google", true, undefined);+ expect(getJobsList).toHaveBeenCalledWith(1, 25, undefined, undefined, "google", true, undefined, undefined);});const filterTrigger = screen.getByRole("combobox");@@ -790,7 +790,7 @@ describe("JobsContainer Search Functionality", () => {});await waitFor(() => {- expect(getJobsList).toHaveBeenCalledWith(1, 25, "applied", undefined, "google", true, undefined);+ expect(getJobsList).toHaveBeenCalledWith(1, 25, "applied", undefined, "google", true, undefined, undefined);});});});@@ -808,7 +808,7 @@ describe("JobsContainer Search Functionality", () => {renderComponent();await waitFor(() => {- expect(getJobsList).toHaveBeenCalledWith(1, 25, undefined, undefined, undefined, true, "full stack developer");+ expect(getJobsList).toHaveBeenCalledWith(1, 25, undefined, undefined, undefined, true, "full stack developer", undefined);});});@@ -851,4 +851,61 @@ describe("JobsContainer Search Functionality", () => {expect(mockRouter.push).toHaveBeenCalledWith("/dashboard/myjobs");});});++ describe("Location Filter from URL", () => {+ it("should pass location filter to getJobsList when URL has location param", async () => {+ const locationSearchParams = new URLSearchParams("location=remote&applied=true");+ (useSearchParams as jest.Mock).mockReturnValue(locationSearchParams);+ (getJobsList as jest.Mock).mockResolvedValue({+ success: true,+ data: mockJobs,+ total: 2,+ });++ renderComponent();++ await waitFor(() => {+ expect(getJobsList).toHaveBeenCalledWith(1, 25, undefined, undefined, undefined, true, undefined, "remote");+ });+ });++ it("should show location badge when location param is present", async () => {+ const locationSearchParams = new URLSearchParams("location=remote&applied=true");+ (useSearchParams as jest.Mock).mockReturnValue(locationSearchParams);+ (getJobsList as jest.Mock).mockResolvedValue({+ success: true,+ data: mockJobs,+ total: 2,+ });++ renderComponent();++ await waitFor(() => {+ expect(screen.getByText("Remote")).toBeInTheDocument();+ });+ });++ it("should clear location filter when badge is clicked", async () => {+ const locationSearchParams = new URLSearchParams("location=remote&applied=true");+ (useSearchParams as jest.Mock).mockReturnValue(locationSearchParams);+ (getJobsList as jest.Mock).mockResolvedValue({+ success: true,+ data: mockJobs,+ total: 2,+ });++ renderComponent();++ await waitFor(() => {+ expect(screen.getByText("Remote")).toBeInTheDocument();+ });++ const badge = screen.getByText("Remote").closest("button")!;+ await act(async () => {+ await user.click(badge);+ });++ expect(mockRouter.push).toHaveBeenCalledWith("/dashboard/myjobs");+ });+ });});diff --git a/__tests__/job.actions.spec.ts b/__tests__/job.actions.spec.tsindex 3bf5a88..cc9536b 100644--- a/__tests__/job.actions.spec.ts+++ b/__tests__/job.actions.spec.ts@@ -509,6 +509,79 @@ describe("jobActions", () => {expect(findManyCall.where.JobTitle).toBeUndefined();});});++ describe("location filter", () => {+ it("should filter by location value when locationValue is provided", async () => {+ (getCurrentUser as jest.Mock).mockResolvedValue(mockUser);+ (prisma.job.findMany as jest.Mock).mockResolvedValue([]);+ (prisma.job.count as jest.Mock).mockResolvedValue(0);++ await getJobsList(1, 10, undefined, undefined, undefined, undefined, undefined, "remote");++ const findManyCall = (prisma.job.findMany as jest.Mock).mock+ .calls[0][0];+ expect(findManyCall.where).toMatchObject({+ userId: mockUser.id,+ Location: { value: "remote" },+ });+ });++ it("should combine location filter with applied filter", async () => {+ (getCurrentUser as jest.Mock).mockResolvedValue(mockUser);+ (prisma.job.findMany as jest.Mock).mockResolvedValue([]);+ (prisma.job.count as jest.Mock).mockResolvedValue(0);++ await getJobsList(1, 10, undefined, undefined, undefined, true, undefined, "remote");++ const findManyCall = (prisma.job.findMany as jest.Mock).mock+ .calls[0][0];+ expect(findManyCall.where).toMatchObject({+ userId: mockUser.id,+ Location: { value: "remote" },+ applied: true,+ });+ });++ it("should exclude Location from search OR when locationValue is set", async () => {+ (getCurrentUser as jest.Mock).mockResolvedValue(mockUser);+ (prisma.job.findMany as jest.Mock).mockResolvedValue([]);+ (prisma.job.count as jest.Mock).mockResolvedValue(0);++ await getJobsList(1, 10, undefined, "React", undefined, undefined, undefined, "remote");++ const findManyCall = (prisma.job.findMany as jest.Mock).mock+ .calls[0][0];+ expect(findManyCall.where.OR).not.toContainEqual(+ { Location: { label: { contains: "React" } } },+ );+ });++ it("should include Location in search OR when locationValue is not set", async () => {+ (getCurrentUser as jest.Mock).mockResolvedValue(mockUser);+ (prisma.job.findMany as jest.Mock).mockResolvedValue([]);+ (prisma.job.count as jest.Mock).mockResolvedValue(0);++ await getJobsList(1, 10, undefined, "React");++ const findManyCall = (prisma.job.findMany as jest.Mock).mock+ .calls[0][0];+ expect(findManyCall.where.OR).toContainEqual(+ { Location: { label: { contains: "React" } } },+ );+ });++ it("should not add Location when locationValue is undefined", async () => {+ (getCurrentUser as jest.Mock).mockResolvedValue(mockUser);+ (prisma.job.findMany as jest.Mock).mockResolvedValue([]);+ (prisma.job.count as jest.Mock).mockResolvedValue(0);++ await getJobsList(1, 10);++ const findManyCall = (prisma.job.findMany as jest.Mock).mock+ .calls[0][0];+ expect(findManyCall.where.Location).toBeUndefined();+ });+ });});describe("getJobDetails", () => {it("should throw error when jobId is not provided", async () => {diff --git a/src/actions/job.actions.ts b/src/actions/job.actions.tsindex 87d5b5e..436d1be 100644--- a/src/actions/job.actions.ts+++ b/src/actions/job.actions.ts@@ -44,6 +44,7 @@ export const getJobsList = async (companyValue?: string,appliedOnly?: boolean,titleValue?: string,+ locationValue?: string,): Promise<any | undefined> => {try {const user = await getCurrentUser();@@ -78,6 +79,10 @@ export const getJobsList = async (whereClause.JobTitle = { value: titleValue };}+ if (locationValue) {+ whereClause.Location = { value: locationValue };+ }+if (appliedOnly) {whereClause.applied = true;}@@ -90,8 +95,10 @@ export const getJobsList = async (if (!companyValue) {searchConditions.push({ Company: { label: { contains: search } } });}+ if (!locationValue) {+ searchConditions.push({ Location: { label: { contains: search } } });+ }searchConditions.push(- { Location: { label: { contains: search } } },{ description: { contains: search } },);whereClause.OR = searchConditions;diff --git a/src/components/admin/JobLocationsTable.tsx b/src/components/admin/JobLocationsTable.tsxindex 8b877b3..629c644 100644--- a/src/components/admin/JobLocationsTable.tsx+++ b/src/components/admin/JobLocationsTable.tsx@@ -20,6 +20,7 @@ import {} from "../ui/table";import { JobLocation } from "@/models/job.model";import { MoreHorizontal, Trash } from "lucide-react";+import Link from "next/link";import { AlertDialog } from "@/models/alertDialog.model";import { toast } from "../ui/use-toast";import { deleteJobLocationById } from "@/actions/jobLocation.actions";@@ -95,7 +96,16 @@ function JobLocationsTable({{location.value}</TableCell><TableCell className="font-medium">- {location._count?.jobsApplied}+ {location._count?.jobsApplied ? (+ <Link+ href={`/dashboard/myjobs?location=${encodeURIComponent(location.value)}&applied=true`}+ className="text-primary underline-offset-4 hover:underline"+ >+ {location._count.jobsApplied}+ </Link>+ ) : (+ location._count?.jobsApplied ?? 0+ )}</TableCell><TableCell><DropdownMenu>diff --git a/src/components/myjobs/JobsContainer.tsx b/src/components/myjobs/JobsContainer.tsxindex 03a18d3..afc0794 100644--- a/src/components/myjobs/JobsContainer.tsx+++ b/src/components/myjobs/JobsContainer.tsx@@ -81,6 +81,9 @@ function JobsContainer({const [titleFilter, setTitleFilter] = useState<string | null>(queryParams.get("title"),);+ const [locationFilter, setLocationFilter] = useState<string | null>(+ queryParams.get("location"),+ );const [appliedFilter, setAppliedFilter] = useState(queryParams.get("applied") === "true",);@@ -106,6 +109,10 @@ function JobsContainer({? titles.find((t) => t.value === titleFilter)?.label: null;+ const locationLabel = locationFilter+ ? locations.find((l) => l.value === locationFilter)?.label+ : null;+const clearCompanyFilter = () => {setCompanyFilter(null);setAppliedFilter(false);@@ -118,12 +125,20 @@ function JobsContainer({router.push(pathname);};+ const clearLocationFilter = () => {+ setLocationFilter(null);+ setAppliedFilter(false);+ router.push(pathname);+ };+useEffect(() => {const cp = queryParams.get("company");const tp = queryParams.get("title");+ const lp = queryParams.get("location");const ap = queryParams.get("applied") === "true";setCompanyFilter(cp);setTitleFilter(tp);+ setLocationFilter(lp);setAppliedFilter(ap);}, [queryParams]);@@ -140,6 +155,7 @@ function JobsContainer({companyFilter || undefined,appliedFilter || undefined,titleFilter || undefined,+ locationFilter || undefined,);if (success && data) {setJobs((prev) => (page === 1 ? data : [...prev, ...data]));@@ -156,7 +172,7 @@ function JobsContainer({return;}},- [jobsPerPage, companyFilter, appliedFilter, titleFilter],+ [jobsPerPage, companyFilter, appliedFilter, titleFilter, locationFilter],);const reloadJobs = useCallback(async () => {@@ -308,6 +324,15 @@ function JobsContainer({<X className="h-3.5 w-3.5" /></button>)}+ {locationLabel && (+ <button+ onClick={clearLocationFilter}+ className="inline-flex items-center gap-1 rounded-md bg-primary/10 px-2.5 py-1 text-sm font-medium text-primary hover:bg-primary/20 transition-colors"+ >+ {locationLabel}+ <X className="h-3.5 w-3.5" />+ </button>+ )}<div className="relative flex-1 min-w-[140px] sm:flex-none"><Search className="absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground" /><Input