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.

View job details

Khuram Niaz3dc162d01946
diff --git a/src/actions/job.actions.ts b/src/actions/job.actions.ts
index 2f6c95b..16471b2 100644
--- a/src/actions/job.actions.ts
+++ b/src/actions/job.actions.ts
@@ -77,12 +77,16 @@ export const getJobsList = async (
},
skip,
take: limit,
- include: {
+ select: {
+ id: true,
JobSource: true,
JobTitle: true,
Company: true,
Status: true,
Location: true,
+ dueDate: true,
+ appliedDate: true,
+ description: false,
},
orderBy: {
createdAt: "desc",
@@ -102,6 +106,39 @@ export const getJobsList = async (
}
};
+export const getJobDetails = async (
+ jobId: string
+): Promise<any | undefined> => {
+ try {
+ if (!jobId) {
+ throw new Error("Please provide job id");
+ }
+ const user = await getCurrentUser();
+
+ if (!user) {
+ throw new Error("Not authenticated");
+ }
+
+ const job = prisma.job.findUnique({
+ where: {
+ id: jobId,
+ },
+ include: {
+ JobSource: true,
+ JobTitle: true,
+ Company: true,
+ Status: true,
+ Location: true,
+ },
+ });
+ return job;
+ } catch (error) {
+ const msg = "Failed to fetch job details. ";
+ console.error(msg, error);
+ throw new Error(msg);
+ }
+};
+
export const createCompany = async (
label: string
): Promise<any | undefined> => {
diff --git a/src/components/JobDetails.tsx b/src/components/JobDetails.tsx
new file mode 100644
index 0000000..66a50b7
--- /dev/null
+++ b/src/components/JobDetails.tsx
@@ -0,0 +1,64 @@
+"use client";
+import { useEffect, useState } from "react";
+import { Button } from "./ui/button";
+import {
+ DialogClose,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from "./ui/dialog";
+import { getJobDetails } from "@/actions/job.actions";
+import { DialogDescription } from "@radix-ui/react-dialog";
+import { format } from "date-fns";
+import { EditorContent, useEditor } from "@tiptap/react";
+import StarterKit from "@tiptap/starter-kit";
+
+function JobDetails({ jobId }: { jobId: string }) {
+ const [job, setJob] = useState<any>({});
+ const editor = useEditor({
+ extensions: [StarterKit],
+ content: "",
+ editable: false, // Make it non-editable if you only want to display content
+ });
+ useEffect(() => {
+ const getJob = async (id: string) => {
+ const res = await getJobDetails(id);
+ editor?.commands.setContent(res.description);
+ setJob(res);
+ };
+ getJob(jobId);
+ }, [jobId, editor]);
+
+ return (
+ <>
+ {job?.id ? (
+ <div className="col-span-3">
+ <DialogHeader className="mb-4">
+ <DialogDescription>{job?.Company?.label}</DialogDescription>
+ <DialogTitle>{job?.JobTitle?.label}</DialogTitle>
+ <DialogDescription>
+ {job?.Location?.label} - {job?.jobType}
+ </DialogDescription>
+ </DialogHeader>
+
+ <h3>Applied: {format(new Date(job?.appliedDate), "PP")}</h3>
+ <div className="my-4">
+ <EditorContent editor={editor} />
+ </div>
+ {/* <pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">
+ <code className="text-white">{JSON.stringify(job, null, 2)}</code>
+ </pre> */}
+ <DialogFooter>
+ <DialogClose>
+ <Button variant="outline" className="mt-2 md:mt-0 w-full">
+ Cancel
+ </Button>
+ </DialogClose>
+ </DialogFooter>
+ </div>
+ ) : null}
+ </>
+ );
+}
+
+export default JobDetails;
diff --git a/src/components/MyJobsTable.tsx b/src/components/MyJobsTable.tsx
index 2159174..697ea49 100644
--- a/src/components/MyJobsTable.tsx
+++ b/src/components/MyJobsTable.tsx
@@ -8,7 +8,13 @@ import {
TableRow,
} from "./ui/table";
import Image from "next/image";
-import { MoreHorizontal, Pencil, Tags, Trash, User } from "lucide-react";
+import {
+ ListCollapse,
+ MoreHorizontal,
+ Pencil,
+ Tags,
+ Trash,
+} from "lucide-react";
import { cn } from "@/lib/utils";
import { Badge } from "./ui/badge";
import { format } from "date-fns";
@@ -36,6 +42,9 @@ import {
import { useEffect, useState } from "react";
import { TablePagination } from "./TablePagination";
import { getJobsList } from "@/actions/job.actions";
+import { Dialog, DialogContent, DialogTrigger } from "./ui/dialog";
+import JobDetails from "./JobDetails";
+
function MyJobsTable() {
const labels = [
"draft",
@@ -48,6 +57,8 @@ function MyJobsTable() {
];
const [label, setLabel] = useState("feature");
const [open, setOpen] = useState(false);
+ const [dialogOpen, setDialogOpen] = useState(false);
+ const [curJobId, setCurJobId] = useState("");
const [jobs, setJobs] = useState([]);
const [totalJobs, setTotalJobs] = useState(0);
@@ -67,6 +78,11 @@ function MyJobsTable() {
const startPostIndex = (currentPage - 1) * jobsPerPage + 1;
const endPostIndex = Math.min(currentPage * jobsPerPage, totalJobs);
+ const viewJobDetails = (jobId: string) => {
+ setCurJobId(jobId);
+ setDialogOpen(true);
+ };
+
return (
<>
<Table>
@@ -75,12 +91,12 @@ function MyJobsTable() {
<TableHead className="hidden w-[100px] sm:table-cell">
<span className="sr-only">Company Logo</span>
</TableHead>
+ <TableHead className="hidden md:table-cell">Date Applied</TableHead>
<TableHead>Title</TableHead>
<TableHead>Company</TableHead>
+ <TableHead className="hidden md:table-cell">Location</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>
@@ -89,7 +105,11 @@ function MyJobsTable() {
<TableBody>
{jobs.map((job: any) => {
return (
- <TableRow key={job.id}>
+ <TableRow
+ key={job.id}
+ className="cursor-pointer"
+ onClick={() => viewJobDetails(job?.id)}
+ >
<TableCell className="hidden sm:table-cell">
<Image
alt="Company logo"
@@ -99,31 +119,35 @@ function MyJobsTable() {
width="32"
/>
</TableCell>
+ <TableCell className="hidden md:table-cell">
+ {format(new Date(job.appliedDate), "PP")}
+ </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>
+ {new Date() > job.dueDate && job.Status?.value === "draft" ? (
+ <Badge className="bg-red-500">Expired</Badge>
+ ) : (
+ <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">
- {format(new Date(job.appliedDate), "PP")}
+ {job.JobSource?.label}
</TableCell>
<TableCell>
<DropdownMenu>
@@ -136,6 +160,13 @@ function MyJobsTable() {
<DropdownMenuContent align="end" className="w-[200px]">
<DropdownMenuLabel>Actions</DropdownMenuLabel>
<DropdownMenuGroup>
+ <DropdownMenuItem
+ className="cursor-pointer"
+ onClick={() => viewJobDetails(job?.id)}
+ >
+ <ListCollapse className="mr-2 h-4 w-4" />
+ View Details
+ </DropdownMenuItem>
<DropdownMenuItem>
<Pencil className="mr-2 h-4 w-4" />
Edit
@@ -186,11 +217,17 @@ function MyJobsTable() {
})}
</TableBody>
</Table>
+ <Dialog open={dialogOpen} onOpenChange={setDialogOpen}>
+ <DialogTrigger asChild></DialogTrigger>
+ <DialogContent className="lg:max-w-screen-lg lg:max-h-screen overflow-y-scroll">
+ <JobDetails jobId={curJobId} />
+ </DialogContent>
+ </Dialog>
<div className="text-xs text-muted-foreground">
- Showing{" "}
+ Showing
<strong>
{startPostIndex} to {endPostIndex}
- </strong>{" "}
+ </strong>
of
<strong> {totalJobs}</strong> jobs
</div>