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: update activity handling to use startTime instead of endTime and enhance job display in MyJobsTable

Khuram Niaza44bbabb2d1a
diff --git a/__tests__/dashboard.actions.spec.ts b/__tests__/dashboard.actions.spec.ts
index 44b61c6..6b7c818 100644
--- a/__tests__/dashboard.actions.spec.ts
+++ b/__tests__/dashboard.actions.spec.ts
@@ -153,12 +153,12 @@ describe("Dashboard Actions", () => {
(getCurrentUser as any).mockResolvedValue(mockUser);
const mockActivities = [
{
- endTime: new Date("2024-01-01T10:00:00Z"),
+ startTime: new Date("2024-01-01T10:00:00Z"),
duration: 60,
activityType: { label: "Applying" },
},
{
- endTime: new Date("2024-01-01T14:00:00Z"),
+ startTime: new Date("2024-01-01T14:00:00Z"),
duration: 30,
activityType: { label: "Interviewing" },
},
@@ -208,7 +208,7 @@ describe("Dashboard Actions", () => {
(getCurrentUser as any).mockResolvedValue(mockUser);
const mockActivities = [
{
- endTime: new Date("2024-01-01T10:00:00Z"),
+ startTime: new Date("2024-01-01T10:00:00Z"),
duration: 60,
activityType: null,
},
diff --git a/src/actions/dashboard.actions.ts b/src/actions/dashboard.actions.ts
index 195b504..9cd4c6f 100644
--- a/src/actions/dashboard.actions.ts
+++ b/src/actions/dashboard.actions.ts
@@ -105,13 +105,13 @@ export const getActivityDataForPeriod = async (): Promise<any | undefined> => {
const activities = await prisma.activity.findMany({
where: {
userId: user.id,
- endTime: {
+ startTime: {
gte: sevenDaysAgo,
lte: today,
},
},
select: {
- endTime: true,
+ startTime: true,
duration: true,
activityType: {
select: {
@@ -120,12 +120,12 @@ export const getActivityDataForPeriod = async (): Promise<any | undefined> => {
},
},
orderBy: {
- endTime: "asc",
+ startTime: "asc",
},
});
const groupedData = activities.reduce((acc: any, activity: any) => {
// Use local date for grouping to match user's perception
- const activityDate = new Date(activity.endTime);
+ const activityDate = new Date(activity.startTime);
const day = format(activityDate, "yyyy-MM-dd");
const activityTypeLabel = activity.activityType?.label || "Unknown";
@@ -257,7 +257,7 @@ export const getTopActivityTypesByDuration = async (
const activities = await prisma.activity.findMany({
where: {
userId: user.id,
- endTime: {
+ startTime: {
gte: startDate,
lte: today,
},
diff --git a/src/components/dashboard/RecentCardToggle.tsx b/src/components/dashboard/RecentCardToggle.tsx
index df35331..c937de9 100644
--- a/src/components/dashboard/RecentCardToggle.tsx
+++ b/src/components/dashboard/RecentCardToggle.tsx
@@ -2,6 +2,7 @@
import { useState } from "react";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
+import { Badge } from "@/components/ui/badge";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { cn } from "@/lib/utils";
import { JobResponse } from "@/models/job.model";
@@ -27,6 +28,38 @@ function formatDuration(totalMinutes: number) {
return totalMinutes === 0 ? "0min" : `${hours}h ${minutes}min`;
}
+function groupJobsByDate(jobs: JobResponse[]) {
+ const groups = new Map<string, JobResponse[]>();
+ for (const job of jobs) {
+ const key = job.appliedDate
+ ? format(job.appliedDate, "EEE MMMM d, yyyy")
+ : "No date";
+ const existing = groups.get(key);
+ if (existing) {
+ existing.push(job);
+ } else {
+ groups.set(key, [job]);
+ }
+ }
+ return Array.from(groups.entries());
+}
+
+function groupActivitiesByDate(activities: RecentActivity[]) {
+ const groups = new Map<string, RecentActivity[]>();
+ for (const activity of activities) {
+ const key = activity.endTime
+ ? format(activity.endTime, "EEE MMMM d, yyyy")
+ : "In progress";
+ const existing = groups.get(key);
+ if (existing) {
+ existing.push(activity);
+ } else {
+ groups.set(key, [activity]);
+ }
+ }
+ return Array.from(groups.entries());
+}
+
const tabs = ["Jobs", "Activities"] as const;
export default function RecentCardToggle({
@@ -64,47 +97,69 @@ export default function RecentCardToggle({
</CardHeader>
<CardContent className="grid gap-6">
{activeIndex === 0
- ? jobs.map((job) => (
- <div key={job.id} className="flex items-center gap-4">
- <Avatar className="hidden h-8 w-8 sm:flex">
- <AvatarImage
- src={job.Company?.logoUrl || "/images/jobsync-logo.svg"}
- alt="Avatar"
- />
- <AvatarFallback>JS</AvatarFallback>
- </Avatar>
- <Link href={`/dashboard/myjobs/${job?.id}`}>
- <div className="grid gap-1">
- <p className="text-sm font-medium leading-none">
- {job.JobTitle?.label}
- </p>
- <p className="text-sm text-muted-foreground">
- {job.Company?.label}
- </p>
+ ? groupJobsByDate(jobs.slice(0, 5)).map(([date, dateJobs]) => (
+ <div key={date} className="grid gap-4">
+ <p className="text-xs font-semibold uppercase tracking-wide text-muted-foreground">
+ {date}
+ </p>
+ {dateJobs.map((job) => (
+ <div key={job.id} className="flex items-center gap-4">
+ <Avatar className="hidden h-8 w-8 sm:flex">
+ <AvatarImage
+ src={job.Company?.logoUrl || "/images/jobsync-logo.svg"}
+ alt="Avatar"
+ />
+ <AvatarFallback>JS</AvatarFallback>
+ </Avatar>
+ <Link href={`/dashboard/myjobs/${job?.id}`} className="min-w-0">
+ <div className="grid gap-1">
+ <p className="text-sm font-medium leading-none truncate">
+ {job.JobTitle?.label}
+ </p>
+ <p className="text-sm text-muted-foreground truncate">
+ {job.Company?.label}
+ {job.Location?.label ? ` · ${job.Location.label}` : ""}
+ </p>
+ </div>
+ </Link>
+ {job.Status?.label ? (
+ <Badge
+ className={cn(
+ "ml-auto shrink-0 justify-center text-xs px-1.5 py-0 h-5",
+ job.Status?.value === "applied" && "bg-cyan-500",
+ job.Status?.value === "interview" && "bg-green-500",
+ )}
+ >
+ {job.Status.label}
+ </Badge>
+ ) : null}
</div>
- </Link>
- <div className="ml-auto text-sm font-medium">
- {job?.appliedDate ? format(job.appliedDate, "PP") : "N/A"}
- </div>
+ ))}
</div>
))
- : activities.map((activity) => (
- <div key={activity.id} className="flex items-center gap-4">
- <div className="grid gap-1 min-w-0 flex-1">
- <p className="text-sm font-medium leading-none truncate">
- {activity.activityName}
- </p>
- <p className="text-sm text-muted-foreground">
- {activity.activityType?.label || "Unknown"}
- </p>
- </div>
- <div className="ml-auto text-right shrink-0">
- <p className="text-sm font-medium">
- {formatDuration(activity.duration ?? 0)}
- </p>
- <p className="text-xs text-muted-foreground">
- {activity.endTime ? format(activity.endTime, "PP") : ""}
- </p>
+ : groupActivitiesByDate(activities.slice(0, 5)).map(([date, dateActivities]) => (
+ <div key={date} className="grid gap-4">
+ <p className="text-xs font-semibold uppercase tracking-wide text-muted-foreground">
+ {date}
+ </p>
+ <div className="grid gap-4 pl-3">
+ {dateActivities.map((activity) => (
+ <div key={activity.id} className="flex items-center gap-4">
+ <div className="grid gap-1 min-w-0 flex-1">
+ <p className="text-sm font-medium leading-none truncate">
+ {activity.activityName}
+ </p>
+ <p className="text-sm text-muted-foreground">
+ {activity.activityType?.label || "Unknown"}
+ </p>
+ </div>
+ <div className="ml-auto text-right shrink-0">
+ <p className="text-sm font-medium">
+ {formatDuration(activity.duration ?? 0)}
+ </p>
+ </div>
+ </div>
+ ))}
</div>
</div>
))}
diff --git a/src/components/myjobs/MyJobsTable.tsx b/src/components/myjobs/MyJobsTable.tsx
index 399d6d0..2cf6ef7 100644
--- a/src/components/myjobs/MyJobsTable.tsx
+++ b/src/components/myjobs/MyJobsTable.tsx
@@ -100,11 +100,11 @@ function MyJobsTable({
src={job.Company?.logoUrl || "/images/jobsync-logo.svg"}
/>
</TableCell>
- <TableCell className="hidden md:table-cell w-[120px]">
+ <TableCell className="hidden md:table-cell w-[120px] whitespace-nowrap">
{job.appliedDate ? format(job.appliedDate, "PP") : "N/A"}
</TableCell>
<TableCell
- className="font-medium cursor-pointer max-w-[120px] sm:max-w-none"
+ className="font-medium cursor-pointer max-w-[120px] md:max-w-[220px]"
>
<div className="flex items-center gap-1.5">
<Link href={`/dashboard/myjobs/${job?.id}`} className="block truncate">
@@ -118,11 +118,11 @@ function MyJobsTable({
)}
</div>
</TableCell>
- <TableCell className="font-medium max-w-[100px] sm:max-w-none">
+ <TableCell className="font-medium max-w-[100px] md:max-w-[160px]">
<span className="block truncate">{job.Company?.label}</span>
</TableCell>
- <TableCell className="hidden md:table-cell">
- {job.Location?.label}
+ <TableCell className="hidden md:table-cell whitespace-nowrap max-w-[120px]">
+ <span className="block truncate">{job.Location?.label}</span>
</TableCell>
<TableCell>
{new Date() > job.dueDate && job.Status?.value === "draft" ? (