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.

Add recent job widget

Khuram Niaz48d1100397ce
diff --git a/src/actions/dashboard.actions.ts b/src/actions/dashboard.actions.ts
new file mode 100644
index 0000000..9766ca1
--- /dev/null
+++ b/src/actions/dashboard.actions.ts
@@ -0,0 +1,122 @@
+import prisma from "@/lib/db";
+import { getCurrentUser } from "@/utils/user.utils";
+
+const getStartOfWeek = (date: Date) => {
+ const currentDate = new Date(date);
+ const day = currentDate.getDay();
+ const diff = currentDate.getDate() - day + (day === 0 ? -6 : 1); // Adjust when day is Sunday
+ return new Date(currentDate.setDate(diff));
+};
+
+const getEndOfWeek = (startOfWeek: Date) => {
+ const endOfWeek = new Date(startOfWeek);
+ endOfWeek.setDate(startOfWeek.getDate() + 6); // Add 6 days to get to Sunday
+ return endOfWeek;
+};
+
+const getDateNDaysAgo = (days: number) => {
+ const date = new Date();
+ date.setDate(date.getDate() - days);
+ return date;
+};
+
+export const getJobsAppliedForPeriod = async (
+ daysAgo: number
+): Promise<any | undefined> => {
+ const user = await getCurrentUser();
+
+ if (!user) {
+ throw new Error("Not authenticated");
+ }
+
+ try {
+ const startDate = getDateNDaysAgo(daysAgo);
+ const endDate = new Date(); // Current date and time
+
+ const count = await prisma.job.count({
+ where: {
+ userId: user.id,
+ Status: {
+ value: "applied",
+ },
+ appliedDate: {
+ gte: startDate,
+ lt: endDate,
+ },
+ },
+ });
+
+ return count;
+ } catch (error) {
+ const msg = "Failed to job count for this week ";
+ console.error(msg, error);
+ throw new Error(msg);
+ }
+};
+
+export const getJobsAppliedThisWeek = async (): Promise<any | undefined> => {
+ const user = await getCurrentUser();
+
+ if (!user) {
+ throw new Error("Not authenticated");
+ }
+ const startOfWeek = getStartOfWeek(new Date());
+ const endOfWeek = getEndOfWeek(startOfWeek);
+ console.log("START OF WEEK: ", startOfWeek);
+ console.log("END OF WEEK: ", endOfWeek);
+
+ try {
+ const count = await prisma.job.count({
+ where: {
+ userId: user.id,
+ Status: {
+ value: "applied",
+ },
+ appliedDate: {
+ gte: startOfWeek,
+ lt: new Date(endOfWeek.setDate(endOfWeek.getDate() + 1)), // Add 1 to include the end of the week
+ },
+ },
+ });
+
+ return count;
+ } catch (error) {
+ const msg = "Failed to job count for this week ";
+ console.error(msg, error);
+ throw new Error(msg);
+ }
+};
+
+export const getRecentJobs = async (): Promise<any | undefined> => {
+ try {
+ const user = await getCurrentUser();
+
+ if (!user) {
+ throw new Error("Not authenticated");
+ }
+ const list = await prisma.job.findMany({
+ where: {
+ userId: user.id,
+ Status: {
+ value: "applied",
+ },
+ },
+ include: {
+ JobSource: true,
+ JobTitle: true,
+ Company: true,
+ Status: true,
+ Location: true,
+ },
+ orderBy: {
+ appliedDate: "desc",
+ },
+ take: 5,
+ });
+ return list;
+ } catch (error) {
+ const msg = "Failed to fetch jobs list. ";
+ console.error(msg, error);
+ throw new Error(msg);
+ }
+};
diff --git a/src/app/dashboard/myjobs/page.tsx b/src/app/dashboard/myjobs/page.tsx
index 7951440..c48c227 100644
--- a/src/app/dashboard/myjobs/page.tsx
+++ b/src/app/dashboard/myjobs/page.tsx
@@ -1,7 +1,5 @@
-import Image from "next/image";
-import { File, ListFilter, MoreHorizontal, PlusCircle } from "lucide-react";
+import { File, ListFilter, PlusCircle } from "lucide-react";
-import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import {
Card,
@@ -14,25 +12,16 @@ import {
DropdownMenu,
DropdownMenuCheckboxItem,
DropdownMenuContent,
- DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
-import {
- Table,
- TableBody,
- TableCell,
- TableHead,
- TableHeader,
- TableRow,
-} from "@/components/ui/table";
import { Metadata } from "next";
import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog";
import { AddJob } from "@/components/AddJob";
import { getJobsList } from "@/actions/job.actions";
-import { format } from "date-fns";
-import { cn } from "@/lib/utils";
+
+import MyJobsTable from "@/components/MyJobsTable";
export const metadata: Metadata = {
title: "My Jobs | JobSync",
@@ -91,88 +80,7 @@ async function MyJobs() {
</div>
</CardHeader>
<CardContent>
- <Table>
- <TableHeader>
- <TableRow>
- <TableHead className="hidden w-[100px] sm:table-cell">
- <span className="sr-only">Company Logo</span>
- </TableHead>
- <TableHead>Title</TableHead>
- <TableHead>Company</TableHead>
- <TableHead>Status</TableHead>
- <TableHead className="hidden md:table-cell">Source</TableHead>
- <TableHead className="hidden md:table-cell">Location</TableHead>
- <TableHead className="hidden md:table-cell">
- Date Applied
- </TableHead>
- <TableHead>
- <span className="sr-only">Actions</span>
- </TableHead>
- </TableRow>
- </TableHeader>
- <TableBody>
- {jobsList.map((job: any) => {
- return (
- <TableRow key={job.id}>
- <TableCell className="hidden sm:table-cell">
- <Image
- alt="Company logo"
- className="aspect-square rounded-md object-cover"
- height="32"
- src="/icons/amazon-logo.svg"
- width="32"
- />
- </TableCell>
- <TableCell className="font-medium">
- {job.JobTitle?.label}
- </TableCell>
- <TableCell className="font-medium">
- {job.Company?.label}
- </TableCell>
- <TableCell>
- <Badge
- className={cn(
- "w-[70px] justify-center",
- job.Status?.value === "applied" && "bg-cyan-500",
- job.Status?.value === "interview" && "bg-green-500"
- )}
- >
- {job.Status?.label}
- </Badge>
- </TableCell>
- <TableCell className="hidden md:table-cell">
- {job.JobSource?.label}
- </TableCell>
- <TableCell className="hidden md:table-cell">
- {job.Location?.label}
- </TableCell>
- <TableCell className="hidden md:table-cell">
- {format(new Date(job.appliedDate), "MMM d, yyyy")}
- </TableCell>
- <TableCell>
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button
- aria-haspopup="true"
- size="icon"
- variant="ghost"
- >
- <MoreHorizontal className="h-4 w-4" />
- <span className="sr-only">Toggle menu</span>
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- <DropdownMenuLabel>Actions</DropdownMenuLabel>
- <DropdownMenuItem>Edit</DropdownMenuItem>
- <DropdownMenuItem>Delete</DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- </TableCell>
- </TableRow>
- );
- })}
- </TableBody>
- </Table>
+ <MyJobsTable jobs={jobsList} />
</CardContent>
<CardFooter>
<div className="text-xs text-muted-foreground">
diff --git a/src/app/dashboard/page.tsx b/src/app/dashboard/page.tsx
index 7768e2a..80f6c51 100644
--- a/src/app/dashboard/page.tsx
+++ b/src/app/dashboard/page.tsx
@@ -1,3 +1,7 @@
+import {
+ getJobsAppliedForPeriod,
+ getRecentJobs,
+} from "@/actions/dashboard.actions";
import MyResponsiveCalendar from "@/components/ActivityCalendar";
import JobsApplied from "@/components/JobsAppliedCard";
import NumberCard from "@/components/NumberCard";
@@ -11,21 +15,41 @@ export const metadata: Metadata = {
title: "Dashboard",
};
-export default function Dashboard() {
+export default async function Dashboard() {
+ const [jobsAppliedLast7Days, jobsAppliedLast30Days, recentJobs] =
+ await Promise.all([
+ getJobsAppliedForPeriod(7),
+ getJobsAppliedForPeriod(30),
+ getRecentJobs(),
+ ]);
+ // console.log("WEEKLY COUNT: ", count);
return (
<>
<div className="grid auto-rows-max items-start gap-2 md:gap-2 lg:col-span-2">
<div className="grid gap-2 sm:grid-cols-2 md:grid-cols-4 lg:grid-cols-4 xl:grid-cols-4">
<JobsApplied />
- <NumberCard label="This Week" num={14} desc="+35%" progress={45} />
- <NumberCard label="This Month" num={54} desc="+20%" progress={25} />
+ <NumberCard
+ label="Last 7 days"
+ num={jobsAppliedLast7Days}
+ desc="+35%"
+ progress={45}
+ />
+ <NumberCard
+ label="Last 30 days"
+ num={jobsAppliedLast30Days}
+ desc="+20%"
+ progress={25}
+ />
</div>
- <div className=" w-100 h-[240px] flex justify-center">
+ <div className=" w-100 h-[240px] flex flex-col justify-center my-4">
+ <h3 className="text-2xl font-semibold leading-none tracking-tight">
+ Weekly Activity
+ </h3>
<WeeklyBarChart />
</div>
</div>
<div>
- <RecentJobsCard />
+ <RecentJobsCard jobs={recentJobs} />
</div>
<div className="h-[200px] flex flex-col items-start col-span-3">
<h3 className="text-2xl font-semibold leading-none tracking-tight">
diff --git a/src/components/AddJob.tsx b/src/components/AddJob.tsx
index 9201ee7..cf6a39e 100644
--- a/src/components/AddJob.tsx
+++ b/src/components/AddJob.tsx
@@ -5,19 +5,17 @@ import {
getJobLocationList,
getJobSourceList,
getJobTitleList,
- getJobsList,
getStatusList,
} from "@/actions/job.actions";
export async function AddJob() {
- const [statuses, companies, jobTitles, locations, jobSources] =
- await Promise.all([
- getStatusList(),
- getCompanyList(),
- getJobTitleList(),
- getJobLocationList(),
- getJobSourceList(),
- ]);
+ const [statuses, companies, titles, locations, sources] = await Promise.all([
+ getStatusList(),
+ getCompanyList(),
+ getJobTitleList(),
+ getJobLocationList(),
+ getJobSourceList(),
+ ]);
return (
<>
<DialogHeader>
@@ -26,9 +24,9 @@ export async function AddJob() {
<AddJobForm
jobStatuses={statuses}
companies={companies}
- jobTitles={jobTitles}
+ jobTitles={titles}
locations={locations}
- jobSources={jobSources}
+ jobSources={sources}
/>
</>
);
diff --git a/src/components/DatePicker.tsx b/src/components/DatePicker.tsx
index 65b4f61..2d1c5ee 100644
--- a/src/components/DatePicker.tsx
+++ b/src/components/DatePicker.tsx
@@ -43,11 +43,7 @@ export function DatePicker({ field, presets }: DatePickerProps) {
)}
>
<CalendarIcon className="mr-2 h-4 w-4" />
- {field.value ? (
- format(field.value, "PPP")
- ) : (
- <span>Pick a date</span>
- )}
+ {field.value ? format(field.value, "PP") : <span>Pick a date</span>}
</Button>
</FormControl>
</PopoverTrigger>
diff --git a/src/components/Header.tsx b/src/components/Header.tsx
index cad9f26..61554c4 100644
--- a/src/components/Header.tsx
+++ b/src/components/Header.tsx
@@ -62,7 +62,7 @@ async function Header() {
</nav>
</SheetContent>
</Sheet>
- <h1>JobSync - Job Search Assistant</h1>
+ <h1 className="font-semibold">JobSync - Job Search Assistant</h1>
<div className="relative ml-auto flex-1 md:grow-0">
<Search className="absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground" />
<Input
diff --git a/src/components/MyJobsTable.tsx b/src/components/MyJobsTable.tsx
new file mode 100644
index 0000000..d3beab2
--- /dev/null
+++ b/src/components/MyJobsTable.tsx
@@ -0,0 +1,171 @@
+"use client";
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from "./ui/table";
+import Image from "next/image";
+import { MoreHorizontal, Pencil, Tags, Trash, User } from "lucide-react";
+import { cn } from "@/lib/utils";
+import { Badge } from "./ui/badge";
+import { format } from "date-fns";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuGroup,
+ DropdownMenuItem,
+ DropdownMenuLabel,
+ DropdownMenuSeparator,
+ DropdownMenuShortcut,
+ DropdownMenuSub,
+ DropdownMenuSubContent,
+ DropdownMenuSubTrigger,
+ DropdownMenuTrigger,
+} from "./ui/dropdown-menu";
+import { Button } from "./ui/button";
+import {
+ Command,
+ CommandEmpty,
+ CommandGroup,
+ CommandInput,
+ CommandItem,
+ CommandList,
+} from "./ui/command";
+import { useState } from "react";
+function MyJobsTable({ jobs }: { jobs: any[] }) {
+ const labels = [
+ "draft",
+ "applied",
+ "interview",
+ "expired",
+ "rejected",
+ "offer",
+ "archived",
+ ];
+ const [label, setLabel] = useState("feature");
+ const [open, setOpen] = useState(false);
+ return (
+ <Table>
+ <TableHeader>
+ <TableRow>
+ <TableHead className="hidden w-[100px] sm:table-cell">
+ <span className="sr-only">Company Logo</span>
+ </TableHead>
+ <TableHead>Title</TableHead>
+ <TableHead>Company</TableHead>
+ <TableHead>Status</TableHead>
+ <TableHead className="hidden md:table-cell">Source</TableHead>
+ <TableHead className="hidden md:table-cell">Location</TableHead>
+ <TableHead className="hidden md:table-cell">Date Applied</TableHead>
+ <TableHead>
+ <span className="sr-only">Actions</span>
+ </TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {jobs.map((job: any) => {
+ return (
+ <TableRow key={job.id}>
+ <TableCell className="hidden sm:table-cell">
+ <Image
+ alt="Company logo"
+ className="aspect-square rounded-md object-cover"
+ height="32"
+ src="/icons/amazon-logo.svg"
+ width="32"
+ />
+ </TableCell>
+ <TableCell className="font-medium">
+ {job.JobTitle?.label}
+ </TableCell>
+ <TableCell className="font-medium">
+ {job.Company?.label}
+ </TableCell>
+ <TableCell>
+ <Badge
+ className={cn(
+ "w-[70px] justify-center",
+ job.Status?.value === "applied" && "bg-cyan-500",
+ job.Status?.value === "interview" && "bg-green-500"
+ )}
+ >
+ {job.Status?.label}
+ </Badge>
+ </TableCell>
+ <TableCell className="hidden md:table-cell">
+ {job.JobSource?.label}
+ </TableCell>
+ <TableCell className="hidden md:table-cell">
+ {job.Location?.label}
+ </TableCell>
+ <TableCell className="hidden md:table-cell">
+ {format(new Date(job.appliedDate), "PP")}
+ </TableCell>
+ <TableCell>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button aria-haspopup="true" size="icon" variant="ghost">
+ <MoreHorizontal className="h-4 w-4" />
+ <span className="sr-only">Toggle menu</span>
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="w-[200px]">
+ <DropdownMenuLabel>Actions</DropdownMenuLabel>
+ <DropdownMenuGroup>
+ <DropdownMenuItem>
+ <Pencil className="mr-2 h-4 w-4" />
+ Edit
+ </DropdownMenuItem>
+ <DropdownMenuSeparator />
+ <DropdownMenuSub>
+ <DropdownMenuSubTrigger>
+ <Tags className="mr-2 h-4 w-4" />
+ Change status
+ </DropdownMenuSubTrigger>
+ <DropdownMenuSubContent className="p-0">
+ <Command>
+ <CommandInput
+ placeholder="Filter label..."
+ autoFocus={true}
+ />
+ <CommandList>
+ <CommandEmpty>No label found.</CommandEmpty>
+ <CommandGroup>
+ {labels.map((label) => (
+ <CommandItem
+ key={label}
+ value={label}
+ onSelect={(value) => {
+ setLabel(value);
+ setOpen(false);
+ }}
+ >
+ {label}
+ </CommandItem>
+ ))}
+ </CommandGroup>
+ </CommandList>
+ </Command>
+ </DropdownMenuSubContent>
+ </DropdownMenuSub>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem className="text-red-600">
+ <Trash className="mr-2 h-4 w-4" />
+ Delete
+ </DropdownMenuItem>
+ </DropdownMenuGroup>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </TableCell>
+ </TableRow>
+ );
+ })}
+ </TableBody>
+ </Table>
+ );
+}
+
+export default MyJobsTable;
diff --git a/src/components/RecentJobsCard.tsx b/src/components/RecentJobsCard.tsx
index d375e46..a87ec25 100644
--- a/src/components/RecentJobsCard.tsx
+++ b/src/components/RecentJobsCard.tsx
@@ -1,78 +1,34 @@
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
+import { format } from "date-fns";
-export default function RecentJobsCard() {
+export default function RecentJobsCard({ jobs }: { jobs: any[] }) {
+ console.log("RECENT JOBS: ", jobs[0]);
return (
<Card>
<CardHeader>
<CardTitle>Recent Jobs Applied</CardTitle>
</CardHeader>
<CardContent className="grid gap-6">
- <div className="flex items-center gap-4">
- <Avatar className="hidden h-9 w-9 sm:flex">
- {/* <AvatarImage src="/avatars/01.png" alt="Avatar" /> */}
- <AvatarFallback>MS</AvatarFallback>
- </Avatar>
- <div className="grid gap-1">
- <p className="text-sm font-medium leading-none">
- Full Stack Developer
- </p>
- <p className="text-sm text-muted-foreground">Microsoft</p>
+ {jobs.map((job) => (
+ <div key={job.id} className="flex items-center gap-4">
+ <Avatar className="hidden h-9 w-9 sm:flex">
+ <AvatarImage src="/icons/google-logo.svg" alt="Avatar" />
+ <AvatarFallback>MS</AvatarFallback>
+ </Avatar>
+ <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>
+ </div>
+ <div className="ml-auto font-medium">
+ {format(job.appliedDate, "PP")}
+ </div>
</div>
- <div className="ml-auto font-medium">+1,999</div>
- </div>
- <div className="flex items-center gap-4">
- <Avatar className="hidden h-9 w-9 sm:flex">
- {/* <AvatarImage src="/avatars/02.png" alt="Avatar" /> */}
- <AvatarFallback>FB</AvatarFallback>
- </Avatar>
- <div className="grid gap-1">
- <p className="text-sm font-medium leading-none">
- Full Stack Developer
- </p>
- <p className="text-sm text-muted-foreground">Facebook</p>
- </div>
- <div className="ml-auto font-medium">+39</div>
- </div>
- <div className="flex items-center gap-4">
- <Avatar className="hidden h-9 w-9 sm:flex">
- {/* <AvatarImage src="/avatars/03.png" alt="Avatar" /> */}
- <AvatarFallback>AM</AvatarFallback>
- </Avatar>
- <div className="grid gap-1">
- <p className="text-sm font-medium leading-none">
- Frontend Developer
- </p>
- <p className="text-sm text-muted-foreground">Amazon</p>
- </div>
- <div className="ml-auto font-medium">+299</div>
- </div>
- <div className="flex items-center gap-4">
- <Avatar className="hidden h-9 w-9 sm:flex">
- {/* <AvatarImage src="/avatars/04.png" alt="Avatar" /> */}
- <AvatarFallback>NF</AvatarFallback>
- </Avatar>
- <div className="grid gap-1">
- <p className="text-sm font-medium leading-none">
- Frontend Developer
- </p>
- <p className="text-sm text-muted-foreground">Netflix</p>
- </div>
- <div className="ml-auto font-medium">+99</div>
- </div>
- <div className="flex items-center gap-4">
- <Avatar className="hidden h-9 w-9 sm:flex">
- {/* <AvatarImage src="/avatars/05.png" alt="Avatar" /> */}
- <AvatarFallback>SD</AvatarFallback>
- </Avatar>
- <div className="grid gap-1">
- <p className="text-sm font-medium leading-none">
- Software Architect
- </p>
- <p className="text-sm text-muted-foreground">Oracle</p>
- </div>
- <div className="ml-auto font-medium">+39</div>
- </div>
+ ))}
</CardContent>
</Card>
);