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(dashboard): show a monthly goal summary above the daily goals calendar, with wiki help

Khuram Niaz9ac69c9aad71
diff --git a/__tests__/DailyGoalsCalendar.spec.tsx b/__tests__/DailyGoalsCalendar.spec.tsx
index f9c3a8c..5cecc93 100644
--- a/__tests__/DailyGoalsCalendar.spec.tsx
+++ b/__tests__/DailyGoalsCalendar.spec.tsx
@@ -1,4 +1,4 @@
-import { act, render, screen, waitFor } from "@testing-library/react";
+import { act, render, waitFor, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import DailyGoalsCalendar from "@/components/dashboard/DailyGoalsCalendar";
import { getDailyGoalValues } from "@/actions/dailyGoals.actions";
@@ -30,27 +30,36 @@ describe("DailyGoalsCalendar", () => {
/>,
);
- const root = () => screen.getByRole("status").closest(".daily-goals-calendar")!;
+ // [summary Card, calendar Card]; the calendar is always the last one
+ const cards = () =>
+ Array.from(
+ document.querySelectorAll<HTMLElement>(".daily-goals-calendar"),
+ );
+ const summary = () => within(cards()[0]);
+ const calendar = () => within(cards().at(-1)!);
+ const previous = () =>
+ calendar().getByRole("button", { name: "Previous month" });
+ const next = () => calendar().getByRole("button", { name: "Next month" });
it("shows the current month from the initial values without fetching", () => {
renderCalendar();
- expect(screen.getByRole("status")).toHaveTextContent("Oct 2026");
+ expect(calendar().getByRole("status")).toHaveTextContent("Oct 2026");
expect(
- screen.getByText(/October 1: Jobs applied 3 of 5, Activity 2\.5 of 4 h/),
+ calendar().getByText(/October 1: Jobs applied 3 of 5, Activity 2\.5 of 4 h/),
).toBeInTheDocument();
expect(getDailyGoalValues).not.toHaveBeenCalled();
});
it("shows a legend naming both rings and their targets", () => {
renderCalendar();
- expect(screen.getByText("Jobs applied")).toBeInTheDocument();
- expect(screen.getByText("Activity")).toBeInTheDocument();
- expect(screen.getByText("4 h")).toBeInTheDocument();
+ expect(calendar().getByText("Jobs applied")).toBeInTheDocument();
+ expect(calendar().getByText("Activity")).toBeInTheDocument();
+ expect(calendar().getByText("4 h")).toBeInTheDocument();
});
it("cannot navigate into future months", () => {
renderCalendar();
- expect(screen.getByRole("button", { name: "Next month" })).toHaveAttribute(
+ expect(next()).toHaveAttribute(
"aria-disabled",
"true",
);
@@ -63,15 +72,15 @@ describe("DailyGoalsCalendar", () => {
});
renderCalendar();
- await user.click(screen.getByRole("button", { name: "Previous month" }));
+ await user.click(previous());
expect(getDailyGoalValues).toHaveBeenCalledWith("2026-09");
expect(
- await screen.findByText(/September 10: Jobs applied 5 of 5, Activity 4 of 4 h\. All goals met\./),
+ await calendar().findByText(/September 10: Jobs applied 5 of 5, Activity 4 of 4 h\. All goals met\./),
).toBeInTheDocument();
- expect(root()).not.toHaveAttribute("aria-busy");
+ expect(cards().at(-1)).not.toHaveAttribute("aria-busy");
- await user.click(screen.getByRole("button", { name: "Next month" }));
- await user.click(screen.getByRole("button", { name: "Previous month" }));
+ await user.click(next());
+ await user.click(previous());
expect(getDailyGoalValues).toHaveBeenCalledTimes(1);
});
@@ -83,16 +92,16 @@ describe("DailyGoalsCalendar", () => {
.mockReturnValueOnce(aug.promise);
renderCalendar();
- await user.click(screen.getByRole("button", { name: "Previous month" }));
- await user.click(screen.getByRole("button", { name: "Previous month" }));
- expect(root()).toHaveAttribute("aria-busy", "true");
+ await user.click(previous());
+ await user.click(previous());
+ expect(cards().at(-1)).toHaveAttribute("aria-busy", "true");
// September settles while August is on screen: the dim must stay
await act(async () => sep.resolve({ success: true, data: {} }));
- expect(root()).toHaveAttribute("aria-busy", "true");
+ expect(cards().at(-1)).toHaveAttribute("aria-busy", "true");
await act(async () => aug.resolve({ success: true, data: {} }));
- expect(root()).not.toHaveAttribute("aria-busy");
+ expect(cards().at(-1)).not.toHaveAttribute("aria-busy");
});
it("toasts a failed month and retries on the next visit", async () => {
@@ -101,12 +110,92 @@ describe("DailyGoalsCalendar", () => {
.mockResolvedValueOnce({ success: true, data: {} });
renderCalendar();
- await user.click(screen.getByRole("button", { name: "Previous month" }));
+ await user.click(previous());
await waitFor(() => expect(toastError).toHaveBeenCalledWith("Boom"));
- expect(root()).not.toHaveAttribute("aria-busy");
+ expect(cards().at(-1)).not.toHaveAttribute("aria-busy");
- await user.click(screen.getByRole("button", { name: "Next month" }));
- await user.click(screen.getByRole("button", { name: "Previous month" }));
+ await user.click(next());
+ await user.click(previous());
expect(getDailyGoalValues).toHaveBeenCalledTimes(2);
});
+
+ it("shows the current month's summary above the calendar", () => {
+ renderCalendar();
+ expect(cards()).toHaveLength(2);
+ // Oct 1 had 3 jobs, 2.5h: neither met; Oct 2–4 empty; today not met
+ expect(summary().getByRole("status")).toHaveTextContent(
+ "October 2026. Goal hit: Jobs applied 0%, Activity 0%",
+ );
+ // Stat rows are <dt>/<dd>: roles "term" / "definition"
+ const text = (role: string) =>
+ summary().getAllByRole(role).map((el) => el.textContent);
+ expect(text("term")).toEqual([
+ "Current streak",
+ "Best streak",
+ "Both goals met",
+ "Nothing logged",
+ ]);
+ // Placeholder streaks, then Oct 2–4 with nothing logged
+ expect(text("definition")).toEqual(["3 days", "7 days", "0 days", "3 days"]);
+ });
+
+ it("moves the calendar when the summary navigates", async () => {
+ (getDailyGoalValues as any).mockResolvedValue({ success: true, data: {} });
+ renderCalendar();
+
+ await user.click(
+ summary().getByRole("button", { name: "Previous month" }),
+ );
+ expect(getDailyGoalValues).toHaveBeenCalledWith("2026-09");
+ expect(calendar().getByRole("status")).toHaveTextContent("Sep 2026");
+ });
+
+ it("summarises a lazily loaded month once it arrives", async () => {
+ const sep = deferred<any>();
+ (getDailyGoalValues as any).mockReturnValueOnce(sep.promise);
+ renderCalendar();
+
+ await user.click(previous());
+ // data-empty is on the package root inside the Card
+ expect(cards()[0].querySelector("[data-empty]")).not.toBeNull();
+ expect(cards()[0]).toHaveAttribute("aria-busy", "true");
+ expect(cards()[1]).toHaveAttribute("aria-busy", "true");
+
+ await act(async () =>
+ sep.resolve({
+ success: true,
+ data: { "2026-09-01": { jobs: 5, hours: 4 } },
+ }),
+ );
+ expect(summary().getByRole("status")).toHaveTextContent(
+ "September 2026. Goal hit: Jobs applied 3%, Activity 3%",
+ );
+ expect(cards()[0]).not.toHaveAttribute("aria-busy");
+ expect(cards()[1]).not.toHaveAttribute("aria-busy");
+ });
+
+ it("shows no summary for a month that failed", async () => {
+ (getDailyGoalValues as any).mockResolvedValueOnce({
+ success: false,
+ message: "Boom",
+ });
+ renderCalendar();
+
+ await user.click(previous());
+ await waitFor(() => expect(toastError).toHaveBeenCalledWith("Boom"));
+ expect(summary().getByRole("status")).toHaveTextContent(
+ "September 2026. Goal hit: no data",
+ );
+ expect(summary().queryByText("Current streak")).not.toBeInTheDocument();
+ expect(cards()[0]).not.toHaveAttribute("aria-busy");
+ });
+
+ it("shows no summary when the current month failed to load", () => {
+ render(<DailyGoalsCalendar today={today} initialValues={null} />);
+ expect(summary().getByRole("status")).toHaveTextContent(
+ "October 2026. Goal hit: no data",
+ );
+ expect(summary().queryByText("Nothing logged")).not.toBeInTheDocument();
+ expect(getDailyGoalValues).not.toHaveBeenCalled();
+ });
});
diff --git a/src/app/dashboard/page.tsx b/src/app/dashboard/page.tsx
index 53eeea3..3cac0df 100644
--- a/src/app/dashboard/page.tsx
+++ b/src/app/dashboard/page.tsx
@@ -77,7 +77,7 @@ export default async function Dashboard() {
<div className="flex flex-col gap-2 @3xl/main:self-stretch">
<DailyGoalsCalendar
today={today}
- initialValues={dailyGoals.success ? dailyGoals.data : {}}
+ initialValues={dailyGoals.success ? dailyGoals.data : null}
/>
<div className="@3xl/main:relative @3xl/main:min-h-64 @3xl/main:flex-1">
<RecentCardToggle jobs={recentJobs} activities={recentActivities} />
diff --git a/src/components/dashboard/DailyGoalsCalendar.tsx b/src/components/dashboard/DailyGoalsCalendar.tsx
index 11e6da1..260c000 100644
--- a/src/components/dashboard/DailyGoalsCalendar.tsx
+++ b/src/components/dashboard/DailyGoalsCalendar.tsx
@@ -1,11 +1,21 @@
"use client";
-import { useState } from "react";
-import { GcMonthCalendar, type GcGoal } from "react-goal-calendar";
+import { useMemo, useState } from "react";
+import {
+ GcMonthCalendar,
+ GcMonthSummary,
+ type GcGoal,
+} from "react-goal-calendar";
import { getDailyGoalValues } from "@/actions/dailyGoals.actions";
import { Card } from "@/components/ui/card";
import { DAILY_GOALS } from "@/lib/constants";
-import { GOAL_IDS, goalMonthRange, type GoalValues } from "@/lib/dailyGoals";
+import {
+ GOAL_IDS,
+ buildMonthSummary,
+ goalMonthRange,
+ type GoalValues,
+ type MonthSummary,
+} from "@/lib/dailyGoals";
import { toastError } from "@/lib/toast";
import { cn } from "@/lib/utils";
@@ -21,7 +31,7 @@ const GOALS: GcGoal[] = [
interface DailyGoalsCalendarProps {
today: string;
- initialValues: GoalValues;
+ initialValues: GoalValues | null;
}
export default function DailyGoalsCalendar({
@@ -30,11 +40,21 @@ export default function DailyGoalsCalendar({
}: DailyGoalsCalendarProps) {
const { minMonth, maxMonth } = goalMonthRange(today);
const [month, setMonth] = useState(maxMonth);
+ // null = the server fetch failed: leave uncached so it shows "—"
const [valuesByMonth, setValuesByMonth] = useState<
Record<string, GoalValues>
- >({ [maxMonth]: initialValues });
+ >(initialValues ? { [maxMonth]: initialValues } : {});
const [loadingMonth, setLoadingMonth] = useState<string | null>(null);
+ // Only cached months get an entry; the rest show the package's "—"
+ const summaries = useMemo(() => {
+ const data: Record<string, MonthSummary> = {};
+ for (const [key, values] of Object.entries(valuesByMonth)) {
+ data[key] = buildMonthSummary(key, values, today);
+ }
+ return data;
+ }, [valuesByMonth, today]);
+
const handleMonthChange = async (next: string) => {
setMonth(next);
if (valuesByMonth[next]) return;
@@ -50,22 +70,31 @@ export default function DailyGoalsCalendar({
};
const loading = loadingMonth === month;
+ const cardProps = {
+ "aria-busy": loading || undefined,
+ className: cn("daily-goals-calendar p-4", loading && "opacity-60"),
+ };
+ const monthProps = {
+ today,
+ month,
+ minMonth,
+ maxMonth,
+ onMonthChange: handleMonthChange,
+ };
return (
- <Card
- aria-busy={loading || undefined}
- className={cn("daily-goals-calendar p-4", loading && "opacity-60")}
- >
- <GcMonthCalendar
- goals={GOALS}
- values={valuesByMonth[month]}
- today={today}
- month={month}
- minMonth={minMonth}
- maxMonth={maxMonth}
- onMonthChange={handleMonthChange}
- legend
- />
- </Card>
+ <>
+ <Card {...cardProps}>
+ <GcMonthSummary rings={GOALS} data={summaries} {...monthProps} />
+ </Card>
+ <Card {...cardProps}>
+ <GcMonthCalendar
+ goals={GOALS}
+ values={valuesByMonth[month]}
+ legend
+ {...monthProps}
+ />
+ </Card>
+ </>
);
}
diff --git a/wiki/getting-started.md b/wiki/getting-started.md
index e325908..3339f78 100644
--- a/wiki/getting-started.md
+++ b/wiki/getting-started.md
@@ -43,6 +43,8 @@ Five of them take you to the matching page with the form already open, so you la
The calendar at the top right of the Dashboard shows one month, with two rings under each day. The outer ring fills as you apply to jobs that day, towards a target of 5; the inner ring fills with the hours of finished activities started that day, towards 4 hours. The key under the calendar shows which ring is which. A day where both targets are met is shown in bold, and hovering over a day, or tapping it, shows the exact numbers. Use the arrows beside the month name to look back up to 11 months; future days stay empty. The targets are fixed for now.
+Above the calendar, the summary card shows the same month at a glance. The donut gives the share of days each goal was hit: past days of the month, plus today once that goal is met, so an unfinished today never lowers it. Beside it, "Both goals met" counts the days both targets were reached and "Nothing logged" counts past days with no applications and no finished activity. The streak rows are placeholders for now and show fixed numbers. Both cards' arrows move together.
+
## What is each area of the sidebar for?
- **Dashboard** — summary cards: application counts, recent jobs and activities, weekly charts, and a quick-add card for the six kinds of record you create most.