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.

feat: Clickable number of jobs applied for companies

Khuram Niaz95cc5da99e62
diff --git a/src/actions/job.actions.ts b/src/actions/job.actions.ts
index 06eafeb..fb0ab85 100644
--- a/src/actions/job.actions.ts
+++ b/src/actions/job.actions.ts
@@ -41,6 +41,8 @@ export const getJobsList = async (
limit: number = APP_CONSTANTS.RECORDS_PER_PAGE,
filter?: string,
search?: string,
+ companyValue?: string,
+ appliedOnly?: boolean,
): Promise<any | undefined> => {
try {
const user = await getCurrentUser();
@@ -67,13 +69,24 @@ export const getJobsList = async (
...filterBy,
};
+ if (companyValue) {
+ whereClause.Company = { value: companyValue };
+ }
+
+ if (appliedOnly) {
+ whereClause.applied = true;
+ }
+
if (search) {
- whereClause.OR = [
+ const searchConditions: Record<string, any>[] = [
{ JobTitle: { label: { contains: search } } },
- { Company: { label: { contains: search } } },
{ Location: { label: { contains: search } } },
{ description: { contains: search } },
];
+ if (!companyValue) {
+ searchConditions.push({ Company: { label: { contains: search } } });
+ }
+ whereClause.OR = searchConditions;
}
const [data, total] = await Promise.all([
diff --git a/src/components/admin/CompaniesTable.tsx b/src/components/admin/CompaniesTable.tsx
index 03d2605..094a0d8 100644
--- a/src/components/admin/CompaniesTable.tsx
+++ b/src/components/admin/CompaniesTable.tsx
@@ -18,6 +18,7 @@ import {
import { Company } from "@/models/job.model";
import { MoreHorizontal, Pencil, Trash } from "lucide-react";
import { useState } from "react";
+import Link from "next/link";
import { deleteCompanyById } from "@/actions/company.actions";
import { toast } from "../ui/use-toast";
import { DeleteAlertDialog } from "../DeleteAlertDialog";
@@ -110,7 +111,16 @@ function CompaniesTable({
{company.value}
</TableCell>
<TableCell className="font-medium">
- {company._count?.jobsApplied}
+ {company._count?.jobsApplied ? (
+ <Link
+ href={`/dashboard/myjobs?company=${encodeURIComponent(company.value)}&applied=true`}
+ className="text-primary underline-offset-4 hover:underline"
+ >
+ {company._count.jobsApplied}
+ </Link>
+ ) : (
+ company._count?.jobsApplied ?? 0
+ )}
</TableCell>
<TableCell>
<DropdownMenu>
diff --git a/src/components/myjobs/JobsContainer.tsx b/src/components/myjobs/JobsContainer.tsx
index 4a23867..e5562b1 100644
--- a/src/components/myjobs/JobsContainer.tsx
+++ b/src/components/myjobs/JobsContainer.tsx
@@ -9,7 +9,7 @@ import {
} from "../ui/card";
import { Button } from "../ui/button";
import { Input } from "../ui/input";
-import { File, ListFilter, Search } from "lucide-react";
+import { File, ListFilter, Search, X } from "lucide-react";
import {
deleteJobById,
getJobDetails,
@@ -75,6 +75,12 @@ function JobsContainer({
},
[queryParams],
);
+ const [companyFilter, setCompanyFilter] = useState<string | null>(
+ queryParams.get("company"),
+ );
+ const [appliedFilter, setAppliedFilter] = useState(
+ queryParams.get("applied") === "true",
+ );
const [jobs, setJobs] = useState<JobResponse[]>([]);
const [page, setPage] = useState(1);
const [totalJobs, setTotalJobs] = useState(0);
@@ -89,6 +95,23 @@ function JobsContainer({
const [noteJobId, setNoteJobId] = useState("");
const hasSearched = useRef(false);
+ const companyLabel = companyFilter
+ ? companies.find((c) => c.value === companyFilter)?.label
+ : null;
+
+ const clearCompanyFilter = () => {
+ setCompanyFilter(null);
+ setAppliedFilter(false);
+ router.push(pathname);
+ };
+
+ useEffect(() => {
+ const cp = queryParams.get("company");
+ const ap = queryParams.get("applied") === "true";
+ setCompanyFilter(cp);
+ setAppliedFilter(ap);
+ }, [queryParams]);
+
const jobsPerPage = recordsPerPage;
const loadJobs = useCallback(
@@ -99,6 +122,8 @@ function JobsContainer({
jobsPerPage,
filter,
search,
+ companyFilter || undefined,
+ appliedFilter || undefined,
);
if (success && data) {
setJobs((prev) => (page === 1 ? data : [...prev, ...data]));
@@ -115,7 +140,7 @@ function JobsContainer({
return;
}
},
- [jobsPerPage],
+ [jobsPerPage, companyFilter, appliedFilter],
);
const reloadJobs = useCallback(async () => {
@@ -249,6 +274,15 @@ function JobsContainer({
<CardHeader className="flex-col gap-3 sm:flex-row sm:justify-between sm:items-center">
<CardTitle>My Jobs</CardTitle>
<div className="flex flex-wrap items-center gap-2">
+ {companyLabel && (
+ <button
+ onClick={clearCompanyFilter}
+ 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"
+ >
+ {companyLabel}
+ <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