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
Add job, submit form data
Khuram Niaz1da6390e6365
diff --git a/scripts/seed.js b/scripts/seed.jsindex 36f00d8..74c1502 100644--- a/scripts/seed.js+++ b/scripts/seed.js@@ -1,4 +1,4 @@-const { STATUS_DATA } = require("../src/lib/data/seedData");+const { STATUS_DATA, JOB_SOURCES } = require("../src/lib/data/seedData");const { PrismaClient } = require("@prisma/client");const bcrypt = require("bcryptjs");@@ -51,9 +51,30 @@ async function seedStatus() {}}+async function seedJobSouces() {+ try {+ const sources = JOB_SOURCES;+ for (const source of sources) {+ const { label, value } = source;+ await prisma.jobSource.upsert({+ where: {+ value,+ },+ update: { label, value },+ create: { label, value },+ });+ }+ console.log("Seeded job sources");+ } catch (error) {+ console.error("Error seeding job sources: ", error);+ throw error;+ }+}+async function main() {await seedUser();await seedStatus();+ await seedJobSouces();}main()diff --git a/src/actions/job.actions.ts b/src/actions/job.actions.tsindex fa2b66e..534b632 100644--- a/src/actions/job.actions.ts+++ b/src/actions/job.actions.ts@@ -1,6 +1,8 @@"use server";import prisma from "@/lib/db";+import { AddJobFormSchema } from "@/models/addJobForm.schema";import { getCurrentUser } from "@/utils/user.utils";+import { z } from "zod";export const getStatusList = async (): Promise<any | undefined> => {try {@@ -35,6 +37,17 @@ export const getJobTitleList = async (): Promise<any | undefined> => {}};+export const getJobSourceList = async (): Promise<any | undefined> => {+ try {+ const list = await prisma.jobSource.findMany();+ return list;+ } catch (error) {+ const msg = "Failed to fetch job source list. ";+ console.error(msg, error);+ throw new Error(msg);+ }+};+export const getJobLocationList = async (): Promise<any | undefined> => {try {const list = await prisma.location.findMany();@@ -46,6 +59,25 @@ export const getJobLocationList = async (): Promise<any | undefined> => {}};+export const getJobsList = async (): Promise<any | undefined> => {+ try {+ const list = await prisma.job.findMany({+ include: {+ JobSource: true,+ JobTitle: true,+ Company: true,+ Status: true,+ Location: true,+ },+ });+ return list;+ } catch (error) {+ const msg = "Failed to fetch jobs list. ";+ console.error(msg, error);+ throw new Error(msg);+ }+};+export const createCompany = async (label: string): Promise<any | undefined> => {@@ -122,3 +154,38 @@ export const createLocation = async (throw new Error(msg);}};++export const addJob = async (+ data: z.infer<typeof AddJobFormSchema>+): Promise<any | undefined> => {+ try {+ const user = await getCurrentUser();++ if (!user) {+ throw new Error("Not authenticated");+ }++ const job = await prisma.job.create({+ data: {+ jobTitleId: data.title,+ companyId: data.company,+ locationId: data.location,+ statusId: data.status,+ jobSourceId: data.source,+ salaryRange: data.salaryRange,+ createdAt: new Date(),+ dueDate: data.dueDate,+ appliedDate: data.dateApplied,+ description: data.jobDescription,+ jobType: "fulltime",+ userId: user.id,+ },+ });++ return job;+ } catch (error) {+ const msg = "Failed to create job. ";+ console.error(msg, error);+ throw new Error(msg);+ }+};diff --git a/src/components/AddJob.tsx b/src/components/AddJob.tsxindex cf9909b..e75e2ce 100644--- a/src/components/AddJob.tsx+++ b/src/components/AddJob.tsx@@ -3,17 +3,23 @@ import AddJobForm from "./AddJobForm";import {getCompanyList,getJobLocationList,+ getJobSourceList,getJobTitleList,+ getJobsList,getStatusList,} from "@/actions/job.actions";export async function AddJob() {- const [statuses, companies, jobTitles, locations] = await Promise.all([- getStatusList(),- getCompanyList(),- getJobTitleList(),- getJobLocationList(),- ]);+ const [statuses, companies, jobTitles, locations, jobSources, jobs] =+ await Promise.all([+ getStatusList(),+ getCompanyList(),+ getJobTitleList(),+ getJobLocationList(),+ getJobSourceList(),+ getJobsList(),+ ]);+ console.log("JOBS LIST: ", jobs);return (<><DialogHeader>@@ -24,6 +30,7 @@ export async function AddJob() {companies={companies}jobTitles={jobTitles}locations={locations}+ jobSources={jobSources}/></>);diff --git a/src/components/AddJobForm.tsx b/src/components/AddJobForm.tsxindex 2315952..c640dc4 100644--- a/src/components/AddJobForm.tsx+++ b/src/components/AddJobForm.tsx@@ -21,13 +21,17 @@ import { DatePicker } from "./DatePicker";import SelectFormCtrl from "./Select";import { JOB_SOURCES } from "@/lib/data/jobSourcesData";import { SALARY_RANGES } from "@/lib/data/salaryRangeData";-import { useState } from "react";+import { useState, useTransition } from "react";+import { addDays } from "date-fns";+import { addJob } from "@/actions/job.actions";+import { Loader } from "lucide-react";interface AddJobFormProps {jobStatuses: { id: string; label: string; value: string }[];companies: any[];jobTitles: { id: string; label: string; value: string }[];locations: { id: string; label: string; value: string }[];+ jobSources: { id: string; label: string; value: string }[];}export default function AddJobForm({@@ -35,20 +39,30 @@ export default function AddJobForm({companies,jobTitles,locations,+ jobSources,}: AddJobFormProps) {const [loading, setLoading] = useState(false);+ const [isPending, startTransition] = useTransition();const form = useForm<z.infer<typeof AddJobFormSchema>>({resolver: zodResolver(AddJobFormSchema),// mode: "onChange",defaultValues: {dateApplied: new Date(),- status: jobStatuses[0].value,+ dueDate: addDays(new Date(), 3),+ status: jobStatuses[0].id,+ salaryRange: "1",+ jobDescription: "Job details are provided here",},});function onSubmit(data: z.infer<typeof AddJobFormSchema>) {console.log("add job form data: ", data);+ startTransition(async () => {+ const res = await addJob(data);+ form.reset();+ console.log("RESPONSE DATA: ", res);+ });toast({title: "You submitted the following values:",description: (@@ -122,7 +136,7 @@ export default function AddJobForm({render={({ field }) => (<FormItem className="flex flex-col"><FormLabel>Job Source</FormLabel>- <Combobox options={JOB_SOURCES} field={field} />+ <Combobox options={jobSources} field={field} /><FormMessage /></FormItem>)}@@ -228,7 +242,12 @@ export default function AddJobForm({Cancel</Button></DialogClose>- <Button type="submit">Save</Button>+ <Button type="submit">+ Save+ {isPending ? (+ <Loader className="h-4 w-4 shrink-0 spinner" />+ ) : null}+ </Button></DialogFooter></div></form>diff --git a/src/components/ComboBox.tsx b/src/components/ComboBox.tsxindex 2fc8bd2..1967e80 100644--- a/src/components/ComboBox.tsx+++ b/src/components/ComboBox.tsx@@ -59,7 +59,7 @@ export function Combobox({ options, field, creatable }: ComboboxProps) {break;}options.unshift(response);- field.onChange(response.value);+ field.onChange(response.id);setIsPopoverOpen(false);});};@@ -77,7 +77,7 @@ export function Combobox({ options, field, creatable }: ComboboxProps) {)}>{field.value- ? options.find((option) => option.value === field.value).label+ ? options.find((option) => option.id === field.value).label: `Select ${field.name}`}{isPending ? (@@ -126,7 +126,7 @@ export function Combobox({ options, field, creatable }: ComboboxProps) {key={option.id}onSelect={() => {if (field.onChange) {- field.onChange(option.value);+ field.onChange(option.id);setIsPopoverOpen(false);}}}diff --git a/src/components/Select.tsx b/src/components/Select.tsxindex 1b81a08..a145bd2 100644--- a/src/components/Select.tsx+++ b/src/components/Select.tsx@@ -36,10 +36,10 @@ function SelectFormCtrl({ label, options, field }: SelectProps) {return (<SelectItemkey={option.id}- value={option.value}+ value={option.id}className="capitalize">- {option.label ? option.label : option.value}+ {option.label ?? option.value}</SelectItem>);})}diff --git a/src/lib/data/salaryRangeData.ts b/src/lib/data/salaryRangeData.tsindex b69dac4..3fb3900 100644--- a/src/lib/data/salaryRangeData.ts+++ b/src/lib/data/salaryRangeData.ts@@ -1,16 +1,16 @@export const SALARY_RANGES = [- { id: 1, value: "0 - 10,000" },- { id: 2, value: "10,000 - 20,000" },- { id: 3, value: "20,000 - 30,000" },- { id: 4, value: "30,000 - 40,000" },- { id: 5, value: "40,000 - 50,000" },- { id: 6, value: "50,000 - 60,000" },- { id: 7, value: "60,000 - 70,000" },- { id: 8, value: "70,000 - 80,000" },- { id: 9, value: "80,000 - 90,000" },- { id: 10, value: "90,000 - 100,000" },- { id: 11, value: "100,000 - 110,000" },- { id: 12, value: "120,000 - 130,000" },- { id: 13, value: "130,000 - 140,000" },- { id: 14, value: "> 150,000" },+ { id: "1", value: "0 - 10,000" },+ { id: "2", value: "10,000 - 20,000" },+ { id: "3", value: "20,000 - 30,000" },+ { id: "4", value: "30,000 - 40,000" },+ { id: "5", value: "40,000 - 50,000" },+ { id: "6", value: "50,000 - 60,000" },+ { id: "7", value: "60,000 - 70,000" },+ { id: "8", value: "70,000 - 80,000" },+ { id: "9", value: "80,000 - 90,000" },+ { id: "10", value: "90,000 - 100,000" },+ { id: "11", value: "100,000 - 110,000" },+ { id: "12", value: "120,000 - 130,000" },+ { id: "13", value: "130,000 - 140,000" },+ { id: "14", value: "> 150,000" },];diff --git a/src/lib/data/seedData.js b/src/lib/data/seedData.jsindex 42a10d7..2e284de 100644--- a/src/lib/data/seedData.js+++ b/src/lib/data/seedData.js@@ -8,6 +8,19 @@ const STATUS_DATA = [{ label: "Archived", value: "archived" },];+const JOB_SOURCES = [+ { label: "Indeed", value: "indeed" },+ { label: "Linkedin", value: "linkedin" },+ { label: "Monster", value: "monster" },+ { label: "Glassdoor", value: "glassdoor" },+ { label: "Company Career page", value: "careerpage" },+ { label: "Google", value: "google" },+ { label: "ZipRecruiter", value: "ziprecruiter" },+ { label: "Job Street", value: "jobstreet" },+ { label: "Other", value: "other" },+];+module.exports = {STATUS_DATA,+ JOB_SOURCES,};