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: Improve calender label, add hrs activity

Khuram Niaz58793625ee74
diff --git a/__tests__/dashboard.actions.spec.ts b/__tests__/dashboard.actions.spec.ts
index 6763047..df6c94f 100644
--- a/__tests__/dashboard.actions.spec.ts
+++ b/__tests__/dashboard.actions.spec.ts
@@ -298,6 +298,7 @@ describe("Dashboard Actions", () => {
},
];
(prisma.job.groupBy as jest.Mock).mockResolvedValue(mockJobData);
+ (prisma.activity.findMany as jest.Mock).mockResolvedValue([]);
const result = await getActivityCalendarData();
@@ -327,6 +328,7 @@ describe("Dashboard Actions", () => {
it("should return empty object when no job data", async () => {
(getCurrentUser as jest.Mock).mockResolvedValue(mockUser);
(prisma.job.groupBy as jest.Mock).mockResolvedValue([]);
+ (prisma.activity.findMany as jest.Mock).mockResolvedValue([]);
const result = await getActivityCalendarData();
@@ -346,6 +348,7 @@ describe("Dashboard Actions", () => {
},
];
(prisma.job.groupBy as jest.Mock).mockResolvedValue(mockJobData);
+ (prisma.activity.findMany as jest.Mock).mockResolvedValue([]);
const result = await getActivityCalendarData();
@@ -371,6 +374,7 @@ describe("Dashboard Actions", () => {
},
];
(prisma.job.groupBy as jest.Mock).mockResolvedValue(mockJobData);
+ (prisma.activity.findMany as jest.Mock).mockResolvedValue([]);
const result = await getActivityCalendarData();
diff --git a/__tests__/tag.actions.spec.ts b/__tests__/tag.actions.spec.ts
index 75853ae..a238dfb 100644
--- a/__tests__/tag.actions.spec.ts
+++ b/__tests__/tag.actions.spec.ts
@@ -101,7 +101,7 @@ describe("Tag Actions", () => {
where: { createdBy: mockUser.id },
skip: 0,
take: 10,
- orderBy: { label: "asc" },
+ orderBy: { jobs: { _count: "desc" } },
}),
);
});
diff --git a/src/actions/dashboard.actions.ts b/src/actions/dashboard.actions.ts
index ff3007c..195b504 100644
--- a/src/actions/dashboard.actions.ts
+++ b/src/actions/dashboard.actions.ts
@@ -368,30 +368,48 @@ export const getActivityCalendarData = async (): Promise<any | undefined> => {
},
});
- type InputObject = {
- [key: string]: number;
- };
-
- type OutputObject = {
- day: string;
- value: number;
- };
-
- // Reduce to a format that groups by unique date (YYYY-MM-DD)
- const groupedJobs = jobData.reduce((acc: any, job: any) => {
- if (!job.appliedDate) return acc;
- const date = format(new Date(job.appliedDate), "yyyy-MM-dd");
- acc[date] = (acc[date] || 0) + job._count._all;
- return acc;
- }, {});
+ const activityData = await prisma.activity.findMany({
+ where: {
+ userId: user.id,
+ startTime: { gte: daysAgo, lte: today },
+ duration: { not: null },
+ },
+ select: { startTime: true, duration: true },
+ });
+
+ const groupedJobs: Record<string, number> = jobData.reduce(
+ (acc: Record<string, number>, job: any) => {
+ if (!job.appliedDate) return acc;
+ const date = format(new Date(job.appliedDate), "yyyy-MM-dd");
+ acc[date] = (acc[date] || 0) + job._count._all;
+ return acc;
+ },
+ {},
+ );
+
+ const groupedHours: Record<string, number> = activityData.reduce(
+ (acc: Record<string, number>, activity) => {
+ const date = format(new Date(activity.startTime), "yyyy-MM-dd");
+ acc[date] = (acc[date] || 0) + (activity.duration || 0) / 60;
+ return acc;
+ },
+ {},
+ );
+
+ const allDates = new Set([
+ ...Object.keys(groupedJobs),
+ ...Object.keys(groupedHours),
+ ]);
- const groupedByYear = Object.entries(groupedJobs).reduce(
- (acc: any, [date, value]) => {
+ const groupedByYear = [...allDates].reduce(
+ (acc: Record<string, any[]>, date) => {
const year = date.split("-")[0];
- if (!acc[year]) {
- acc[year] = [];
- }
- acc[year].push({ day: date, value });
+ if (!acc[year]) acc[year] = [];
+ acc[year].push({
+ day: date,
+ value: groupedJobs[date] || 0,
+ hours: Math.round((groupedHours[date] || 0) * 10) / 10,
+ });
return acc;
},
{},
diff --git a/src/components/dashboard/ActivityCalendar.tsx b/src/components/dashboard/ActivityCalendar.tsx
index 43ea9d1..8b03bc1 100644
--- a/src/components/dashboard/ActivityCalendar.tsx
+++ b/src/components/dashboard/ActivityCalendar.tsx
@@ -1,5 +1,6 @@
"use client";
import { ResponsiveCalendar } from "@nivo/calendar";
+import { format, parseISO } from "date-fns";
import { useTheme } from "next-themes";
import { Card, CardContent, CardHeader, CardTitle } from "../ui/card";
// make sure parent container have a defined height when using
@@ -16,6 +17,9 @@ export default function ActivityCalendar({
}) {
const { resolvedTheme } = useTheme();
const borderColor = resolvedTheme === "light" ? "#ffffff" : "#0e1117";
+ const hoursMap = Object.fromEntries(
+ data.map((d) => [d.day, d.hours ?? 0]),
+ );
return (
<Card className="w-[100%]">
<CardHeader>
@@ -34,6 +38,25 @@ export default function ActivityCalendar({
monthBorderColor={borderColor}
dayBorderWidth={2}
dayBorderColor={borderColor}
+ tooltip={(day) => {
+ const hours = hoursMap[day.day] ?? 0;
+ return (
+ <div
+ style={{
+ background: "#1e293b",
+ color: "#fff",
+ padding: "6px 12px",
+ borderRadius: "4px",
+ fontSize: "12px",
+ whiteSpace: "nowrap",
+ }}
+ >
+ <div><strong>{format(parseISO(day.day), "EEE MMM d, yyyy")}</strong></div>
+ <div>{day.value} job{Number(day.value) === 1 ? "" : "s"} applied</div>
+ <div>{hours} hr{hours === 1 ? "" : "s"} activity</div>
+ </div>
+ );
+ }}
theme={{
text: {
fill: "#9ca3af",