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 resume and contactInfo

Khuram Niaze8928ba56e8d
diff --git a/src/actions/profile.actions.ts b/src/actions/profile.actions.ts
index a097477..6953341 100644
--- a/src/actions/profile.actions.ts
+++ b/src/actions/profile.actions.ts
@@ -1,9 +1,127 @@
"use server";
import prisma from "@/lib/db";
+import { AddContactInfoFormSchema } from "@/models/addContactInfoForm.schema";
import { CreateResumeFormSchema } from "@/models/createResumeForm.schema";
import { getCurrentUser } from "@/utils/user.utils";
import { z } from "zod";
+export const getResumeList = async (
+ page = 1,
+ limit = 10
+): Promise<any | undefined> => {
+ try {
+ const user = await getCurrentUser();
+
+ if (!user) {
+ throw new Error("Not authenticated");
+ }
+ const skip = (page - 1) * limit;
+
+ const [data, total] = await Promise.all([
+ prisma.resume.findMany({
+ where: {
+ profile: {
+ userId: user.id,
+ },
+ },
+ skip,
+ take: limit,
+ orderBy: {
+ createdAt: "desc",
+ },
+ }),
+ prisma.resume.count({
+ where: {
+ profile: {
+ userId: user.id,
+ },
+ },
+ }),
+ ]);
+ return { data, total, success: true };
+ } catch (error) {
+ const msg = "Failed to get resume list.";
+ console.error(msg, error);
+ if (error instanceof Error) {
+ return { success: false, message: error.message };
+ }
+ }
+};
+
+export const getResumeById = async (
+ resumeId: string
+): Promise<any | undefined> => {
+ try {
+ if (!resumeId) {
+ throw new Error("Please provide resume id");
+ }
+ const user = await getCurrentUser();
+
+ if (!user) {
+ throw new Error("Not authenticated");
+ }
+
+ const resume = prisma.resume.findUnique({
+ where: {
+ id: resumeId,
+ },
+ include: {
+ ContactInfo: true,
+ },
+ });
+ return resume;
+ } catch (error) {
+ const msg = "Failed to get resume.";
+ console.error(msg, error);
+ if (error instanceof Error) {
+ return { success: false, message: error.message };
+ }
+ }
+};
+
+export const addContactInfo = async (
+ data: z.infer<typeof AddContactInfoFormSchema>
+): Promise<any | undefined> => {
+ try {
+ const user = await getCurrentUser();
+
+ if (!user) {
+ throw new Error("Not authenticated");
+ }
+
+ //check if contact info exists
+
+ const res = await prisma.resume.update({
+ where: {
+ id: data.resumeId,
+ },
+ data: {
+ ContactInfo: {
+ connectOrCreate: {
+ where: { resumeId: data.resumeId },
+ create: {
+ firstName: data.firstName,
+ lastName: data.lastName,
+ headline: data.headline,
+ email: data.email!,
+ phone: data.phone!,
+ address: data.address,
+ },
+ },
+ },
+ },
+ });
+ console.log("response: ", res);
+ return { data: res, success: true };
+ } catch (error) {
+ const msg = "Failed to create contact info.";
+ console.error(msg, error);
+ if (error instanceof Error) {
+ return { success: false, message: error.message };
+ }
+ }
+};
+
export const createResumeProfile = async (
data: z.infer<typeof CreateResumeFormSchema>
): Promise<any | undefined> => {
diff --git a/src/app/dashboard/profile/resume/[id]/page.tsx b/src/app/dashboard/profile/resume/[id]/page.tsx
new file mode 100644
index 0000000..3fd4bbc
--- /dev/null
+++ b/src/app/dashboard/profile/resume/[id]/page.tsx
@@ -0,0 +1,14 @@
+import { getResumeById } from "@/actions/profile.actions";
+import ResumeContainer from "@/components/ResumeContainer";
+
+async function ResumePage({ params }: any) {
+ const { id } = params;
+ const resume = await getResumeById(id);
+ return (
+ <div className="col-span-3">
+ <ResumeContainer resume={resume} />
+ </div>
+ );
+}
+
+export default ResumePage;
diff --git a/src/components/AddContactInfo.tsx b/src/components/AddContactInfo.tsx
new file mode 100644
index 0000000..c5b558f
--- /dev/null
+++ b/src/components/AddContactInfo.tsx
@@ -0,0 +1,222 @@
+"use client";
+import { Loader } from "lucide-react";
+import { Button } from "./ui/button";
+import {
+ Dialog,
+ DialogClose,
+ DialogContent,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from "./ui/dialog";
+import {
+ Form,
+ FormControl,
+ FormField,
+ FormItem,
+ FormLabel,
+ FormMessage,
+} from "./ui/form";
+import { Input } from "./ui/input";
+import { AddContactInfoFormSchema } from "@/models/addContactInfoForm.schema";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { useForm } from "react-hook-form";
+import { z } from "zod";
+import { useTransition } from "react";
+import { toast } from "./ui/use-toast";
+import { ContactInfo } from "@/models/profile.model";
+import { addContactInfo } from "@/actions/profile.actions";
+
+interface AddContactInfoProps {
+ dialogOpen: boolean;
+ setDialogOpen: (e: boolean) => void;
+ editContactInfo?: ContactInfo | null;
+ resumeId: string | undefined;
+}
+
+function AddContactInfo({
+ dialogOpen,
+ setDialogOpen,
+ editContactInfo,
+ resumeId,
+}: AddContactInfoProps) {
+ const [isPending, startTransition] = useTransition();
+
+ const pageTitle = editContactInfo ? "Edit Contact Info" : "Add Contact Info";
+
+ const form = useForm<z.infer<typeof AddContactInfoFormSchema>>({
+ resolver: zodResolver(AddContactInfoFormSchema),
+ defaultValues: {
+ resumeId,
+ },
+ });
+
+ const { setValue, reset, formState } = form;
+
+ const onSubmit = (data: z.infer<typeof AddContactInfoFormSchema>) => {
+ startTransition(async () => {
+ // const res = editContactInfo
+ // ? await updateCompany(data)
+ // : await addContactInfo(data);
+ const res = await addContactInfo(data);
+ if (!res.success) {
+ toast({
+ variant: "destructive",
+ title: "Error!",
+ description: res.message,
+ });
+ } else {
+ reset();
+ setDialogOpen(false);
+ // reloadCompanies();
+ toast({
+ variant: "success",
+ description: `Contact Info has been ${
+ editContactInfo ? "updated" : "created"
+ } successfully`,
+ });
+ }
+ });
+ };
+
+ return (
+ <Dialog open={dialogOpen} onOpenChange={setDialogOpen}>
+ <DialogContent className="lg:max-h-screen overflow-y-scroll">
+ <DialogHeader>
+ <DialogTitle>Add Contact Info</DialogTitle>
+ </DialogHeader>
+ <Form {...form}>
+ <form
+ onSubmit={form.handleSubmit(onSubmit)}
+ className="grid grid-cols-1 md:grid-cols-2 gap-4 p-2"
+ >
+ {/* FIRST NAME */}
+ <div className="md:col-span-2">
+ <FormField
+ control={form.control}
+ name="firstName"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>First Name</FormLabel>
+ <FormControl>
+ <Input {...field} />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ </div>
+
+ {/* LAST NAME */}
+ <div className="md:col-span-2">
+ <FormField
+ control={form.control}
+ name="lastName"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>Last Name</FormLabel>
+ <FormControl>
+ <Input {...field} />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ </div>
+
+ {/* HEADLINE */}
+ <div className="md:col-span-2">
+ <FormField
+ control={form.control}
+ name="headline"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>Headline</FormLabel>
+ <FormControl>
+ <Input {...field} />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ </div>
+
+ {/* EMAIL */}
+ <div className="md:col-span-2">
+ <FormField
+ control={form.control}
+ name="email"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>Email</FormLabel>
+ <FormControl>
+ <Input {...field} />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ </div>
+
+ {/* PHONE */}
+ <div className="md:col-span-2">
+ <FormField
+ control={form.control}
+ name="phone"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>Phone</FormLabel>
+ <FormControl>
+ <Input {...field} />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ </div>
+
+ {/* ADDRESS */}
+ <div className="md:col-span-2">
+ <FormField
+ control={form.control}
+ name="address"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>Address</FormLabel>
+ <FormControl>
+ <Input {...field} />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ </div>
+ <div className="md:col-span-2 mt-4">
+ <DialogFooter
+ // className="md:col-span
+ >
+ <DialogClose>
+ <Button
+ type="reset"
+ variant="outline"
+ className="mt-2 md:mt-0 w-full"
+ >
+ Cancel
+ </Button>
+ </DialogClose>
+ <Button type="submit" disabled={!formState.isDirty}>
+ Save
+ {isPending ? (
+ <Loader className="h-4 w-4 shrink-0 spinner" />
+ ) : null}
+ </Button>
+ </DialogFooter>
+ </div>
+ </form>
+ </Form>
+ </DialogContent>
+ </Dialog>
+ );
+}
+
+export default AddContactInfo;
diff --git a/src/components/AddResumeSection.tsx b/src/components/AddResumeSection.tsx
new file mode 100644
index 0000000..3ef5017
--- /dev/null
+++ b/src/components/AddResumeSection.tsx
@@ -0,0 +1,55 @@
+"use client";
+import { PlusCircle } from "lucide-react";
+import { Button } from "./ui/button";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuGroup,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+} from "./ui/dropdown-menu";
+import AddContactInfo from "./AddContactInfo";
+import { useState } from "react";
+import { Resume } from "@/models/profile.model";
+
+function AddResumeSection({ resume }: { resume: Resume }) {
+ const [contactInfoDialogOpen, setcontactInfoDialogOpen] = useState(false);
+
+ const addResumeSection = () => {};
+
+ return (
+ <>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button size="sm" className="h-8 gap-1" onClick={addResumeSection}>
+ <PlusCircle className="h-3.5 w-3.5" />
+ <span className="sr-only sm:not-sr-only sm:whitespace-nowrap">
+ Add Section
+ </span>
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent className="w-56">
+ <DropdownMenuGroup>
+ <DropdownMenuItem
+ className="cursor-pointer"
+ onClick={() => setcontactInfoDialogOpen(true)}
+ disabled={!!resume.ContactInfo}
+ >
+ Add Contact Info
+ </DropdownMenuItem>
+ <DropdownMenuItem>Add Summary</DropdownMenuItem>
+ <DropdownMenuItem>Add Experience</DropdownMenuItem>
+ <DropdownMenuItem>Add Education</DropdownMenuItem>
+ </DropdownMenuGroup>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ <AddContactInfo
+ dialogOpen={contactInfoDialogOpen}
+ setDialogOpen={setcontactInfoDialogOpen}
+ resumeId={resume.id}
+ />
+ </>
+ );
+}
+
+export default AddResumeSection;
diff --git a/src/components/ContactInfoCard.tsx b/src/components/ContactInfoCard.tsx
new file mode 100644
index 0000000..2e7e601
--- /dev/null
+++ b/src/components/ContactInfoCard.tsx
@@ -0,0 +1,41 @@
+"use client";
+import { ContactInfo } from "@/models/profile.model";
+import { Card, CardDescription, CardHeader, CardTitle } from "./ui/card";
+import { Button } from "./ui/button";
+import { Edit } from "lucide-react";
+
+function ContactInfoCard({
+ contactInfo,
+}: {
+ contactInfo: ContactInfo | undefined;
+}) {
+ const editContactInfo = () => {};
+ return (
+ <Card>
+ <CardHeader className="flex-row justify-between relative">
+ <div>
+ <CardTitle>
+ {contactInfo?.firstName} {contactInfo?.lastName}
+ </CardTitle>
+ <CardDescription>{contactInfo?.headline}</CardDescription>
+ <CardDescription>
+ {contactInfo?.email} - {contactInfo?.phone} - {contactInfo?.address}
+ </CardDescription>
+ </div>
+ <Button
+ variant="ghost"
+ size="sm"
+ className="h-8 gap-1 absolute top-0 right-1"
+ onClick={editContactInfo}
+ >
+ <Edit className="h-3.5 w-3.5" />
+ <span className="sr-only sm:not-sr-only sm:whitespace-nowrap">
+ Edit
+ </span>
+ </Button>
+ </CardHeader>
+ </Card>
+ );
+}
+
+export default ContactInfoCard;
diff --git a/src/components/ProfileContainer.tsx b/src/components/ProfileContainer.tsx
index bc8499f..8ecb881 100644
--- a/src/components/ProfileContainer.tsx
+++ b/src/components/ProfileContainer.tsx
@@ -1,8 +1,47 @@
-import ActivitiesTable from "./ActivitiesTable";
+"use client";
+import { useCallback, useEffect, useState } from "react";
import CreateResume from "./CreateResume";
import { Card, CardContent, CardHeader, CardTitle } from "./ui/card";
+import { getResumeList } from "@/actions/profile.actions";
+import { Resume } from "@/models/profile.model";
+import { useSearchParams } from "next/navigation";
+import { APP_CONSTANTS } from "@/lib/constants";
+import Loading from "./Loading";
+import ResumeTable from "./ResumeTable";
function ActivitiesContainer() {
+ const queryParams = useSearchParams();
+ const recordsPerPage = APP_CONSTANTS.RECORDS_PER_PAGE;
+
+ const [resumes, setResumes] = useState<Resume[]>([]);
+ const [totalResumes, setTotalResumes] = useState(0);
+ const [currentPage, setCurrentPage] = useState(
+ Number(queryParams.get("page")) || 1
+ );
+ const [loading, setLoading] = useState(false);
+
+ const totalPages = Math.ceil(totalResumes / recordsPerPage);
+
+ const loadResumes = useCallback(
+ async (page: number) => {
+ setLoading(true);
+ const { data, total, success } = await getResumeList(
+ page,
+ recordsPerPage
+ );
+ setResumes(data);
+ setTotalResumes(total);
+ if (success) {
+ setLoading(false);
+ }
+ },
+ [recordsPerPage]
+ );
+
+ useEffect(() => {
+ loadResumes(currentPage);
+ }, [currentPage, loadResumes]);
+
return (
<Card>
<CardHeader className="flex-row justify-between items-center">
@@ -11,7 +50,21 @@ function ActivitiesContainer() {
<CreateResume />
</div>
</CardHeader>
- <CardContent></CardContent>
+ <CardContent>
+ {!loading ? (
+ <ResumeTable
+ resumes={resumes}
+ currentPage={currentPage}
+ totalPages={totalPages}
+ recordsPerPage={recordsPerPage}
+ totalResumes={totalResumes}
+ // onPageChange={onPageChange}
+ // editCompany={onEditCompany}
+ />
+ ) : (
+ <Loading />
+ )}
+ </CardContent>
</Card>
);
}
diff --git a/src/components/ResumeContainer.tsx b/src/components/ResumeContainer.tsx
new file mode 100644
index 0000000..e0f5d71
--- /dev/null
+++ b/src/components/ResumeContainer.tsx
@@ -0,0 +1,24 @@
+import { Resume } from "@/models/profile.model";
+import { Card, CardDescription, CardHeader, CardTitle } from "./ui/card";
+import AddResumeSection from "./AddResumeSection";
+import ContactInfoCard from "./ContactInfoCard";
+
+function ResumeContainer({ resume }: { resume: Resume }) {
+ console.log("RESUME: ", resume);
+ return (
+ <>
+ <Card>
+ <CardHeader className="flex-row justify-between items-center">
+ <CardTitle>Resume</CardTitle>
+ <CardDescription>{resume.title}</CardDescription>
+ <div className="flex items-center">
+ <AddResumeSection resume={resume} />
+ </div>
+ </CardHeader>
+ </Card>
+ <ContactInfoCard contactInfo={resume.ContactInfo} />
+ </>
+ );
+}
+
+export default ResumeContainer;
diff --git a/src/components/ResumeTable.tsx b/src/components/ResumeTable.tsx
new file mode 100644
index 0000000..0459fd1
--- /dev/null
+++ b/src/components/ResumeTable.tsx
@@ -0,0 +1,107 @@
+"use client";
+import { FilePenLine, MoreHorizontal, Pencil, Trash } from "lucide-react";
+import { Button } from "./ui/button";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuLabel,
+ DropdownMenuTrigger,
+} from "./ui/dropdown-menu";
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from "./ui/table";
+import { Resume } from "@/models/profile.model";
+import { format } from "date-fns";
+import Link from "next/link";
+
+type ResumeTableProps = {
+ resumes: Resume[];
+ currentPage: number;
+ totalPages: number;
+ totalResumes: number;
+ recordsPerPage: number;
+ // onPageChange: (n: number) => void;
+ // editCompany: (id: string) => void;
+};
+
+function ResumeTable({
+ resumes,
+ currentPage,
+ totalPages,
+ totalResumes,
+ recordsPerPage,
+}: // onPageChange,
+// editCompany,
+ResumeTableProps) {
+ return (
+ <Table>
+ <TableHeader>
+ <TableRow>
+ <TableHead>Resume Title</TableHead>
+ <TableHead>Created At</TableHead>
+ <TableHead>Actions</TableHead>
+ <TableHead>
+ <span className="sr-only">Actions</span>
+ </TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {resumes.map((resume: Resume) => {
+ return (
+ <TableRow key={resume.id}>
+ <TableCell className="font-medium">
+ <Link href={`/dashboard/profile/resume/${resume.id}`}>
+ {resume.title}
+ </Link>
+ </TableCell>
+ <TableCell>
+ {resume.createdAt && format(resume.createdAt, "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">
+ <DropdownMenuLabel>Actions</DropdownMenuLabel>
+ <Link href={`/dashboard/profile/resume/${resume.id}`}>
+ <DropdownMenuItem
+ className="cursor-pointer"
+ onClick={() => ""}
+ >
+ <FilePenLine className="mr-2 h-4 w-4" />
+ View/Edit Resume
+ </DropdownMenuItem>
+ </Link>
+ <DropdownMenuItem
+ className="cursor-pointer"
+ onClick={() => ""}
+ >
+ <Pencil className="mr-2 h-4 w-4" />
+ Edit Resume Title
+ </DropdownMenuItem>
+ <DropdownMenuItem className="text-red-600 cursor-pointer">
+ <Trash className="mr-2 h-4 w-4" />
+ Delete
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </TableCell>
+ </TableRow>
+ );
+ })}
+ </TableBody>
+ </Table>
+ );
+}
+
+export default ResumeTable;
diff --git a/src/models/addContactInfoForm.schema.ts b/src/models/addContactInfoForm.schema.ts
new file mode 100644
index 0000000..58a9dda
--- /dev/null
+++ b/src/models/addContactInfoForm.schema.ts
@@ -0,0 +1,26 @@
+import { z } from "zod";
+
+export const AddContactInfoFormSchema = z.object({
+ id: z.string().optional(),
+ createdAt: z.string().optional(),
+ updatedAt: z.string().optional(),
+ resumeId: z.string().optional(),
+ firstName: z
+ .string({
+ required_error: "First Name is required.",
+ })
+ .min(1),
+ lastName: z
+ .string({
+ required_error: "Last Name is required.",
+ })
+ .min(1),
+ headline: z
+ .string({
+ required_error: "Headline is required.",
+ })
+ .min(1),
+ email: z.string().optional(),
+ phone: z.string().optional(),
+ address: z.string().optional(),
+});
diff --git a/src/models/profile.model.ts b/src/models/profile.model.ts
index 6854433..a8c9b85 100644
--- a/src/models/profile.model.ts
+++ b/src/models/profile.model.ts
@@ -4,4 +4,18 @@ export interface Resume {
title: string;
createdAt?: Date;
updatedAt?: Date;
+ ContactInfo?: ContactInfo;
+}
+
+export interface ContactInfo {
+ id?: string;
+ createdAt: Date;
+ updatedAt: Date;
+ resumeId: string;
+ firstName: string;
+ lastName: string;
+ headline: string;
+ email?: string;
+ phone?: string;
+ address?: string;
}