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
fix: persist tasks activity filter in URL, sticky sidebar, hide empty types, portal tooltip content
Khuram Niaz3f9726e42b5e
diff --git a/__tests__/TasksPageClient.spec.tsx b/__tests__/TasksPageClient.spec.tsxindex 382cefa..db2c9df 100644--- a/__tests__/TasksPageClient.spec.tsx+++ b/__tests__/TasksPageClient.spec.tsx@@ -2,6 +2,7 @@ import TasksPageClient from "@/app/dashboard/tasks/TasksPageClient";import { screen, render, waitFor } from "@testing-library/react";import userEvent from "@testing-library/user-event";import { getTasksList } from "@/actions/task.actions";+import { useRouter, useSearchParams } from "next/navigation";vi.mock("next-auth", () => {const mockAuth = vi.fn();@@ -46,6 +47,7 @@ vi.mock("next/navigation", () => ({replace: vi.fn(),prefetch: vi.fn(),}),+ usePathname: vi.fn().mockReturnValue("/dashboard/tasks"),useSearchParams: vi.fn().mockReturnValue(new URLSearchParams()),}));@@ -132,6 +134,7 @@ describe("TasksPageClient Component", () => {data: [],total: 0,});+ (useSearchParams as any).mockReturnValue(new URLSearchParams());});describe("Rendering", () => {@@ -573,4 +576,73 @@ describe("TasksPageClient Component", () => {});});});++ describe("URL Persistence", () => {+ it("should initialize the selected filter from the activityType URL param", () => {+ (useSearchParams as any).mockReturnValue(+ new URLSearchParams("activityType=type-1")+ );++ render(+ <TasksPageClient+ activityTypes={mockActivityTypes}+ activityTypesWithCounts={mockActivityTypesWithCounts}+ totalTasks={8}+ />+ );++ const developmentButton = screen.getByRole("button", {+ name: /Development/i,+ });+ expect(developmentButton).toHaveClass("bg-accent");+ });++ it("should write the selected activity type to the URL", async () => {+ const routerMock = (useRouter as any)();++ render(+ <TasksPageClient+ activityTypes={mockActivityTypes}+ activityTypesWithCounts={mockActivityTypesWithCounts}+ totalTasks={8}+ />+ );++ const developmentButton = screen.getByRole("button", {+ name: /Development/i,+ });+ await user.click(developmentButton);++ await waitFor(() => {+ expect(routerMock.replace).toHaveBeenCalledWith(+ "/dashboard/tasks?activityType=type-1",+ { scroll: false }+ );+ });+ });++ it("should remove the activityType param from the URL when All is clicked", async () => {+ (useSearchParams as any).mockReturnValue(+ new URLSearchParams("activityType=type-1")+ );+ const routerMock = (useRouter as any)();++ render(+ <TasksPageClient+ activityTypes={mockActivityTypes}+ activityTypesWithCounts={mockActivityTypesWithCounts}+ totalTasks={8}+ />+ );++ const allButton = screen.getByRole("button", { name: /All/i });+ await user.click(allButton);++ await waitFor(() => {+ expect(routerMock.replace).toHaveBeenCalledWith("/dashboard/tasks", {+ scroll: false,+ });+ });+ });+ });});diff --git a/src/app/dashboard/tasks/TasksPageClient.tsx b/src/app/dashboard/tasks/TasksPageClient.tsxindex b0450b0..9bcd408 100644--- a/src/app/dashboard/tasks/TasksPageClient.tsx+++ b/src/app/dashboard/tasks/TasksPageClient.tsx@@ -3,6 +3,7 @@ import TasksContainer from "@/components/tasks/TasksContainer";import TasksSidebar from "@/components/tasks/TasksSidebar";import { ActivityType } from "@/models/activity.model";import { useState, useCallback } from "react";+import { usePathname, useRouter, useSearchParams } from "next/navigation";import { getActivityTypesWithTaskCounts } from "@/actions/task.actions";type ActivityTypeWithCount = {@@ -23,13 +24,29 @@ function TasksPageClient({activityTypesWithCounts,totalTasks,}: TasksPageClientProps) {- const [filterKey, setFilterKey] = useState<string | undefined>(undefined);+ const router = useRouter();+ const pathname = usePathname();+ const searchParams = useSearchParams();++ const [filterKey, setFilterKey] = useState<string | undefined>(+ searchParams.get("activityType") ?? undefined,+ );const [sidebarCounts, setSidebarCounts] =useState<ActivityTypeWithCount[]>(activityTypesWithCounts);const [sidebarTotal, setSidebarTotal] = useState<number>(totalTasks);const onFilterChange = (filter: string | undefined) => {setFilterKey(filter);+ const params = new URLSearchParams(searchParams.toString());+ if (filter) {+ params.set("activityType", filter);+ } else {+ params.delete("activityType");+ }+ const query = params.toString();+ router.replace(query ? `${pathname}?${query}` : pathname, {+ scroll: false,+ });};const refreshSidebarCounts = useCallback(async () => {diff --git a/src/components/tasks/TasksSidebar.tsx b/src/components/tasks/TasksSidebar.tsxindex 2c2eff4..0cc45f7 100644--- a/src/components/tasks/TasksSidebar.tsx+++ b/src/components/tasks/TasksSidebar.tsx@@ -28,7 +28,7 @@ function TasksSidebar({return (<divclassName={cn(- "relative border-r py-4 hidden md:flex flex-col h-full transition-all duration-200 -ml-3",+ "relative border-r py-4 hidden md:flex flex-col sticky top-4 self-start transition-all duration-200 -ml-3",collapsed ? "w-0 overflow-visible" : "w-48",)}>@@ -66,26 +66,28 @@ function TasksSidebar({</span></button></li>- {activityTypes.map((type) => (- <li key={type.id}>- <button- onClick={() => onFilterChange(type.id)}- className={cn(- "w-full text-left px-3 py-2 rounded-md text-sm transition-colors",- "hover:bg-accent hover:text-accent-foreground",- selectedFilter === type.id &&- "bg-accent text-accent-foreground font-medium",- )}- >- <span className="flex justify-between items-center">- <span className="truncate">{type.label}</span>- <span className="text-muted-foreground text-xs">- {type.taskCount}+ {activityTypes+ .filter((type) => type.taskCount > 0)+ .map((type) => (+ <li key={type.id}>+ <button+ onClick={() => onFilterChange(type.id)}+ className={cn(+ "w-full text-left px-3 py-2 rounded-md text-sm transition-colors",+ "hover:bg-accent hover:text-accent-foreground",+ selectedFilter === type.id &&+ "bg-accent text-accent-foreground font-medium",+ )}+ >+ <span className="flex justify-between items-center">+ <span className="truncate">{type.label}</span>+ <span className="text-muted-foreground text-xs">+ {type.taskCount}+ </span></span>- </span>- </button>- </li>- ))}+ </button>+ </li>+ ))}</ul></>)}diff --git a/src/components/ui/tooltip.tsx b/src/components/ui/tooltip.tsxindex 30fc44d..25576f5 100644--- a/src/components/ui/tooltip.tsx+++ b/src/components/ui/tooltip.tsx@@ -15,15 +15,17 @@ const TooltipContent = React.forwardRef<React.ElementRef<typeof TooltipPrimitive.Content>,React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>>(({ className, sideOffset = 4, ...props }, ref) => (- <TooltipPrimitive.Content- ref={ref}- sideOffset={sideOffset}- className={cn(- "z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",- className- )}- {...props}- />+ <TooltipPrimitive.Portal>+ <TooltipPrimitive.Content+ ref={ref}+ sideOffset={sideOffset}+ className={cn(+ "z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",+ className+ )}+ {...props}+ />+ </TooltipPrimitive.Portal>))TooltipContent.displayName = TooltipPrimitive.Content.displayName