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.
TypeScript ai-agentai-resume-analyzerapplication-trackerapplication-tracking-systematscareerjob-applicationjob-automationjob-huntingjob-searchjob-seeker-toolsjob-trackerjob-trackingjobsearchjobseekersmcpollamaresumeresume-reviewself-hosted
seed and use job status list from db
Khuram Niaz341e17fe22f1
diff --git a/scripts/seed.js b/scripts/seed.jsindex fd2c852..097f770 100644--- a/scripts/seed.js+++ b/scripts/seed.js@@ -1,31 +1,66 @@+const { STATUS_DATA } = require("../src/lib/seedData");-const { PrismaClient } = require('@prisma/client');-const bcrypt = require('bcryptjs');+const { PrismaClient } = require("@prisma/client");+const bcrypt = require("bcryptjs");const prisma = new PrismaClient();-async function main() {- const password = await bcrypt.hash('password123', 10);-+async function seedUser() {+ try {+ const password = await bcrypt.hash("password123", 10);+const user1 = await prisma.user.upsert({- where: { email: '[email protected]' },+ where: { email: "[email protected]" },update: {},create: {- email: '[email protected]',- name: 'Admin',+ email: "[email protected]",+ name: "Admin",password,},});--- console.log({ user1 });++ console.log("Seeded user: ", { user1 });+ } catch (error) {+ console.error("Error seeding user: ", error);+ throw error;}-- main()- .catch((e) => {- console.error(e);- process.exit(1);- })- .finally(async () => {- await prisma.$disconnect();- });\ No newline at end of file+}++async function seedStatus() {+ try {+ const statuses = STATUS_DATA;+ for (const status of statuses) {+ // Check if the status already exists+ const existingStatus = await prisma.jobStatus.findUnique({+ where: {+ statusName: status.statusName,+ },+ });++ // If the status does not exist, create it+ if (!existingStatus) {+ await prisma.jobStatus.create({+ data: status,+ });+ }+ }+ console.log("Seeded statuses");+ } catch (error) {+ console.error("Error seeding status: ", error);+ throw error;+ }+}++async function main() {+ await seedUser();+ await seedStatus();+}++main()+ .catch((e) => {+ console.error(e);+ process.exit(1);+ })+ .finally(async () => {+ await prisma.$disconnect();+ });diff --git a/src/actions/job.actions.ts b/src/actions/job.actions.tsnew file mode 100644index 0000000..a22d6ca--- /dev/null+++ b/src/actions/job.actions.ts@@ -0,0 +1,12 @@+import "server-only";+import prisma from "@/lib/db";++export async function getStatusList(): Promise<any | undefined> {+ try {+ const statuses = await prisma.jobStatus.findMany();+ return statuses;+ } catch (error) {+ console.error("Failed to fetch status list:", error);+ throw new Error("Failed to fetch status list.");+ }+}diff --git a/src/components/AddJob.tsx b/src/components/AddJob.tsxindex 8542c5b..2404703 100644--- a/src/components/AddJob.tsx+++ b/src/components/AddJob.tsx@@ -1,350 +1,15 @@-"use client";-import { Button } from "@/components/ui/button";-import {- DialogClose,- DialogFooter,- DialogHeader,- DialogTitle,-} from "@/components/ui/dialog";-import {- Form,- FormControl,- FormField,- FormItem,- FormLabel,- FormMessage,-} from "@/components/ui/form";-import { Input } from "@/components/ui/input";-import { Label } from "@/components/ui/label";-import { Textarea } from "./ui/textarea";-import {- Select,- SelectContent,- SelectGroup,- SelectItem,- SelectTrigger,- SelectValue,-} from "./ui/select";-import { Popover, PopoverContent, PopoverTrigger } from "./ui/popover";-import { cn } from "@/lib/utils";-import { Calendar as CalendarIcon } from "lucide-react";-import { addDays, format } from "date-fns";-import { Calendar } from "./ui/calendar";-import { useState } from "react";-import { z } from "zod";-import { AddJobFormSchema } from "@/models/addJobForm.schema";-import { useForm } from "react-hook-form";-import { zodResolver } from "@hookform/resolvers/zod";-import { toast } from "./ui/use-toast";--export function AddJob() {- const [date, setDate] = useState<Date>();-- const form = useForm<z.infer<typeof AddJobFormSchema>>({- resolver: zodResolver(AddJobFormSchema),- // mode: "onChange",- defaultValues: {- dateApplied: new Date(),- status: "draft",- },- });-- function onSubmit(data: z.infer<typeof AddJobFormSchema>) {- console.log("add job form data: ", data);- toast({- title: "You submitted the following values:",- description: (- <pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">- <code className="text-white">{JSON.stringify(data, null, 2)}</code>- </pre>- ),- });- }+import { DialogHeader, DialogTitle } from "@/components/ui/dialog";+import AddJobForm from "./AddJobForm";+import { getStatusList } from "@/actions/job.actions";+export async function AddJob() {+ const statuses = await getStatusList();return (<><DialogHeader><DialogTitle>Add Job</DialogTitle></DialogHeader>- <Form {...form}>- <form- onSubmit={form.handleSubmit(onSubmit)}- className="grid grid-cols-1 md:grid-cols-2 gap-4 p-4"- >- {/* Job Title */}- <div>- <FormField- control={form.control}- name="title"- render={({ field }) => (- <FormItem className="flex flex-col">- <FormLabel>Job Title</FormLabel>- <FormControl>- <Input {...field} />- </FormControl>- <FormMessage />- </FormItem>- )}- />- </div>- {/* Company */}- <div>- <FormField- control={form.control}- name="company"- render={({ field }) => (- <FormItem className="flex flex-col">- <FormLabel>Company</FormLabel>- <FormControl>- <Input {...field} />- </FormControl>- <FormMessage />- </FormItem>- )}- />- </div>- {/* Location */}- <div>- <FormField- control={form.control}- name="location"- render={({ field }) => (- <FormItem className="flex flex-col">- <FormLabel>Location</FormLabel>- <FormControl>- <Input {...field} />- </FormControl>- <FormMessage />- </FormItem>- )}- />- </div>- {/* Job Source */}- <div>- <FormField- control={form.control}- name="source"- render={({ field }) => (- <FormItem className="flex flex-col">- <FormLabel>Source</FormLabel>- <FormControl>- <Input {...field} />- </FormControl>- <FormMessage />- </FormItem>- )}- />- </div>- {/* Status */}- <div>- <FormField- control={form.control}- name="status"- render={({ field }) => (- <FormItem className="flex flex-col">- <FormLabel>Status</FormLabel>- <Select- onValueChange={field.onChange}- defaultValue={field.value}- name="status"- >- <FormControl>- <SelectTrigger- aria-label="Select status"- className="w-[180px]"- >- <SelectValue placeholder="Select job status" />- </SelectTrigger>- </FormControl>- <SelectContent>- <SelectGroup>- <SelectItem value="draft">Draft</SelectItem>- <SelectItem value="applied">Applied</SelectItem>- <SelectItem value="interview">Interview</SelectItem>- <SelectItem value="rejected">Rejected</SelectItem>- <SelectItem value="expired">Expired</SelectItem>- </SelectGroup>- </SelectContent>- </Select>- <FormMessage />- </FormItem>- )}- />- </div>- {/* Due Date */}- <div>- <FormField- control={form.control}- name="dueDate"- render={({ field }) => (- <FormItem className="flex flex-col">- <FormLabel>Due Date</FormLabel>- <Popover>- <PopoverTrigger asChild>- <FormControl>- <Button- variant={"outline"}- className={cn(- "w-[280px] pl-3 text-left font-normal",- !field.value && "text-muted-foreground"- )}- >- {field.value ? (- format(field.value, "PPP")- ) : (- <span>Pick a date</span>- )}- <CalendarIcon className="ml-auto h-4 w-4 opacity-50" />- </Button>- </FormControl>- </PopoverTrigger>- <PopoverContent className="w-auto p-0" align="start">- {/* <Select- onValueChange={(value) =>- setDate(addDays(new Date(), parseInt(value)))- }- >- <SelectTrigger>- <SelectValue placeholder="Select" />- </SelectTrigger>- <SelectContent position="popper">- <SelectItem value="0">Today</SelectItem>- <SelectItem value="1">Tomorrow</SelectItem>- <SelectItem value="3">In 3 days</SelectItem>- <SelectItem value="7">In a week</SelectItem>- </SelectContent>- </Select> */}- <Calendar- mode="single"- selected={field.value}- onSelect={field.onChange}- /* onSelect={() => {- setCalendarOpen(false);- }} */- disabled={(date) =>- date > new Date() || date < new Date("1900-01-01")- }- initialFocus- />- </PopoverContent>- </Popover>- <FormMessage />- </FormItem>- )}- />- </div>- {/* Date Applied */}- <div className="flex flex-col">- <FormField- control={form.control}- name="dateApplied"- render={({ field }) => (- <FormItem className="flex flex-col">- <FormLabel>Date Applied</FormLabel>- <Popover>- <PopoverTrigger asChild>- <FormControl>- <Button- variant={"outline"}- className={cn(- "w-[280px] pl-3 text-left font-normal",- !field.value && "text-muted-foreground"- )}- >- {field.value ? (- format(field.value, "PPP")- ) : (- <span>Pick a date</span>- )}- <CalendarIcon className="ml-auto h-4 w-4 opacity-50" />- </Button>- </FormControl>- </PopoverTrigger>- <PopoverContent className="w-auto p-0" align="start">- {/* <Select- onValueChange={(value) =>- setDate(addDays(new Date(), parseInt(value)))- }- >- <SelectTrigger>- <SelectValue placeholder="Select" />- </SelectTrigger>- <SelectContent position="popper">- <SelectItem value="0">Today</SelectItem>- <SelectItem value="1">Tomorrow</SelectItem>- <SelectItem value="3">In 3 days</SelectItem>- <SelectItem value="7">In a week</SelectItem>- </SelectContent>- </Select> */}- <Calendar- mode="single"- selected={field.value}- onSelect={field.onChange}- /* onSelect={() => {- setCalendarOpen(false);- }} */- disabled={(date) =>- date > new Date() || date < new Date("1900-01-01")- }- initialFocus- />- </PopoverContent>- </Popover>- <FormMessage />- </FormItem>- )}- />- </div>- {/* Salary Range */}- <div>- <FormField- control={form.control}- name="salaryRange"- render={({ field }) => (- <FormItem className="flex flex-col">- <FormLabel>Salary Range</FormLabel>- <FormControl>- <Input {...field} />- </FormControl>- <FormMessage />- </FormItem>- )}- />- </div>- {/* Job Description */}- <div className="md:col-span-2">- <FormField- control={form.control}- name="jobDescription"- render={({ field }) => (- <FormItem className="flex flex-col">- <FormLabel>Job Description</FormLabel>- <FormControl>- <Textarea- className="h-36 overflow-auto"- placeholder="Copy and paste you job description here."- {...field}- />- </FormControl>- <FormMessage />- </FormItem>- )}- />- </div>- <div className="md:col-span-2">- <DialogFooter- // className="md:col-span- >- <DialogClose>- <Button variant="outline" className="mt-2 md:mt-0 w-full">- Cancel- </Button>- </DialogClose>- <Button type="submit">Save</Button>- </DialogFooter>- </div>- </form>- </Form>+ <AddJobForm jobStatuses={statuses} /></>);}diff --git a/src/components/AddJobForm.tsx b/src/components/AddJobForm.tsxnew file mode 100644index 0000000..daf1d57--- /dev/null+++ b/src/components/AddJobForm.tsx@@ -0,0 +1,347 @@+"use client";+import { Button } from "@/components/ui/button";+import { DialogClose, DialogFooter } from "@/components/ui/dialog";+import {+ Form,+ FormControl,+ FormField,+ FormItem,+ FormLabel,+ FormMessage,+} from "@/components/ui/form";+import { Input } from "@/components/ui/input";+import { Textarea } from "./ui/textarea";+import {+ Select,+ SelectContent,+ SelectGroup,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from "./ui/select";+import { Popover, PopoverContent, PopoverTrigger } from "./ui/popover";+import { cn } from "@/lib/utils";+import { Calendar as CalendarIcon } from "lucide-react";+import { addDays, format } from "date-fns";+import { Calendar } from "./ui/calendar";+import { z } from "zod";+import { AddJobFormSchema } from "@/models/addJobForm.schema";+import { useForm } from "react-hook-form";+import { zodResolver } from "@hookform/resolvers/zod";+import { toast } from "./ui/use-toast";++interface AddJobFormProps {+ jobStatuses: { id: string; statusName: string }[];+}++export default function AddJobForm({ jobStatuses }: AddJobFormProps) {+ const form = useForm<z.infer<typeof AddJobFormSchema>>({+ resolver: zodResolver(AddJobFormSchema),+ // mode: "onChange",+ defaultValues: {+ dateApplied: new Date(),+ status: jobStatuses[0].statusName,+ },+ });++ function onSubmit(data: z.infer<typeof AddJobFormSchema>) {+ console.log("add job form data: ", data);+ toast({+ title: "You submitted the following values:",+ description: (+ <pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">+ <code className="text-white">{JSON.stringify(data, null, 2)}</code>+ </pre>+ ),+ });+ }++ return (+ <>+ <Form {...form}>+ <form+ onSubmit={form.handleSubmit(onSubmit)}+ className="grid grid-cols-1 md:grid-cols-2 gap-4 p-4"+ >+ {/* Job Title */}+ <div>+ <FormField+ control={form.control}+ name="title"+ render={({ field }) => (+ <FormItem className="flex flex-col">+ <FormLabel>Job Title</FormLabel>+ <FormControl>+ <Input {...field} />+ </FormControl>+ <FormMessage />+ </FormItem>+ )}+ />+ </div>+ {/* Company */}+ <div>+ <FormField+ control={form.control}+ name="company"+ render={({ field }) => (+ <FormItem className="flex flex-col">+ <FormLabel>Company</FormLabel>+ <FormControl>+ <Input {...field} />+ </FormControl>+ <FormMessage />+ </FormItem>+ )}+ />+ </div>+ {/* Location */}+ <div>+ <FormField+ control={form.control}+ name="location"+ render={({ field }) => (+ <FormItem className="flex flex-col">+ <FormLabel>Location</FormLabel>+ <FormControl>+ <Input {...field} />+ </FormControl>+ <FormMessage />+ </FormItem>+ )}+ />+ </div>+ {/* Job Source */}+ <div>+ <FormField+ control={form.control}+ name="source"+ render={({ field }) => (+ <FormItem className="flex flex-col">+ <FormLabel>Source</FormLabel>+ <FormControl>+ <Input {...field} />+ </FormControl>+ <FormMessage />+ </FormItem>+ )}+ />+ </div>+ {/* Status */}+ <div>+ <FormField+ control={form.control}+ name="status"+ render={({ field }) => (+ <FormItem className="flex flex-col">+ <FormLabel>Status</FormLabel>+ <Select+ onValueChange={field.onChange}+ defaultValue={field.value}+ name="status"+ >+ <FormControl>+ <SelectTrigger+ aria-label="Select status"+ className="w-[180px]"+ >+ <SelectValue placeholder="Select job status" />+ </SelectTrigger>+ </FormControl>+ <SelectContent>+ <SelectGroup>+ {jobStatuses.map((status) => {+ return (+ <SelectItem+ key={status.id}+ value={status.statusName}+ >+ {status.statusName.toUpperCase()}+ </SelectItem>+ );+ })}+ </SelectGroup>+ </SelectContent>+ </Select>+ <FormMessage />+ </FormItem>+ )}+ />+ </div>+ {/* Due Date */}+ <div>+ <FormField+ control={form.control}+ name="dueDate"+ render={({ field }) => (+ <FormItem className="flex flex-col">+ <FormLabel>Due Date</FormLabel>+ <Popover>+ <PopoverTrigger asChild>+ <FormControl>+ <Button+ variant={"outline"}+ className={cn(+ "w-[280px] pl-3 text-left font-normal",+ !field.value && "text-muted-foreground"+ )}+ >+ {field.value ? (+ format(field.value, "PPP")+ ) : (+ <span>Pick a date</span>+ )}+ <CalendarIcon className="ml-auto h-4 w-4 opacity-50" />+ </Button>+ </FormControl>+ </PopoverTrigger>+ <PopoverContent className="w-auto p-0" align="start">+ {/* <Select+ onValueChange={(value) =>+ setDate(addDays(new Date(), parseInt(value)))+ }+ >+ <SelectTrigger>+ <SelectValue placeholder="Select" />+ </SelectTrigger>+ <SelectContent position="popper">+ <SelectItem value="0">Today</SelectItem>+ <SelectItem value="1">Tomorrow</SelectItem>+ <SelectItem value="3">In 3 days</SelectItem>+ <SelectItem value="7">In a week</SelectItem>+ </SelectContent>+ </Select> */}+ <Calendar+ mode="single"+ selected={field.value}+ onSelect={field.onChange}+ /* onSelect={() => {+ setCalendarOpen(false);+ }} */+ disabled={(date) =>+ date > new Date() || date < new Date("1900-01-01")+ }+ initialFocus+ />+ </PopoverContent>+ </Popover>+ <FormMessage />+ </FormItem>+ )}+ />+ </div>+ {/* Date Applied */}+ <div className="flex flex-col">+ <FormField+ control={form.control}+ name="dateApplied"+ render={({ field }) => (+ <FormItem className="flex flex-col">+ <FormLabel>Date Applied</FormLabel>+ <Popover>+ <PopoverTrigger asChild>+ <FormControl>+ <Button+ variant={"outline"}+ className={cn(+ "w-[280px] pl-3 text-left font-normal",+ !field.value && "text-muted-foreground"+ )}+ >+ {field.value ? (+ format(field.value, "PPP")+ ) : (+ <span>Pick a date</span>+ )}+ <CalendarIcon className="ml-auto h-4 w-4 opacity-50" />+ </Button>+ </FormControl>+ </PopoverTrigger>+ <PopoverContent className="w-auto p-0" align="start">+ {/* <Select+ onValueChange={(value) =>+ setDate(addDays(new Date(), parseInt(value)))+ }+ >+ <SelectTrigger>+ <SelectValue placeholder="Select" />+ </SelectTrigger>+ <SelectContent position="popper">+ <SelectItem value="0">Today</SelectItem>+ <SelectItem value="1">Tomorrow</SelectItem>+ <SelectItem value="3">In 3 days</SelectItem>+ <SelectItem value="7">In a week</SelectItem>+ </SelectContent>+ </Select> */}+ <Calendar+ mode="single"+ selected={field.value}+ onSelect={field.onChange}+ /* onSelect={() => {+ setCalendarOpen(false);+ }} */+ disabled={(date) =>+ date > new Date() || date < new Date("1900-01-01")+ }+ initialFocus+ />+ </PopoverContent>+ </Popover>+ <FormMessage />+ </FormItem>+ )}+ />+ </div>+ {/* Salary Range */}+ <div>+ <FormField+ control={form.control}+ name="salaryRange"+ render={({ field }) => (+ <FormItem className="flex flex-col">+ <FormLabel>Salary Range</FormLabel>+ <FormControl>+ <Input {...field} />+ </FormControl>+ <FormMessage />+ </FormItem>+ )}+ />+ </div>+ {/* Job Description */}+ <div className="md:col-span-2">+ <FormField+ control={form.control}+ name="jobDescription"+ render={({ field }) => (+ <FormItem className="flex flex-col">+ <FormLabel>Job Description</FormLabel>+ <FormControl>+ <Textarea+ className="h-36 overflow-auto"+ placeholder="Copy and paste you job description here."+ {...field}+ />+ </FormControl>+ <FormMessage />+ </FormItem>+ )}+ />+ </div>+ <div className="md:col-span-2">+ <DialogFooter+ // className="md:col-span+ >+ <DialogClose>+ <Button variant="outline" className="mt-2 md:mt-0 w-full">+ Cancel+ </Button>+ </DialogClose>+ <Button type="submit">Save</Button>+ </DialogFooter>+ </div>+ </form>+ </Form>+ </>+ );+}diff --git a/src/lib/seedData.js b/src/lib/seedData.jsnew file mode 100644index 0000000..39b82ae--- /dev/null+++ b/src/lib/seedData.js@@ -0,0 +1,13 @@+const STATUS_DATA = [+ { statusName: "draft" },+ { statusName: "applied" },+ { statusName: "interview" },+ { statusName: "offer" },+ { statusName: "rejected" },+ { statusName: "expired" },+ { statusName: "archived" },+];++module.exports = {+ STATUS_DATA,+};diff --git a/tsconfig.json b/tsconfig.jsonindex 7b28589..c310a9d 100644--- a/tsconfig.json+++ b/tsconfig.json@@ -21,6 +21,6 @@"@/*": ["./src/*"]}},- "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "src/lib/seedData.js"],"exclude": ["node_modules"]}