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
Refactor salary range and select field
Khuram Niazdad31a984a22
diff --git a/scripts/seed.js b/scripts/seed.jsindex 097f770..87005df 100644--- a/scripts/seed.js+++ b/scripts/seed.js@@ -1,4 +1,4 @@-const { STATUS_DATA } = require("../src/lib/seedData");+const { STATUS_DATA } = require("../src/lib/data/seedData");const { PrismaClient } = require("@prisma/client");const bcrypt = require("bcryptjs");diff --git a/src/app/dashboard/myjobs/page.tsx b/src/app/dashboard/myjobs/page.tsxindex e9edd7a..272178b 100644--- a/src/app/dashboard/myjobs/page.tsx+++ b/src/app/dashboard/myjobs/page.tsx@@ -27,7 +27,7 @@ import {TableHeader,TableRow,} from "@/components/ui/table";-import { MY_JOBS_DATA } from "@/lib/myJobsData";+import { MY_JOBS_DATA } from "@/lib/data/myJobsData";import { Metadata } from "next";import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog";import { AddJob } from "@/components/AddJob";diff --git a/src/app/dashboard/page.tsx b/src/app/dashboard/page.tsxindex 8f12db6..7768e2a 100644--- a/src/app/dashboard/page.tsx+++ b/src/app/dashboard/page.tsx@@ -3,7 +3,7 @@ import JobsApplied from "@/components/JobsAppliedCard";import NumberCard from "@/components/NumberCard";import RecentJobsCard from "@/components/RecentJobsCard";import WeeklyBarChart from "@/components/WeeklyBarChart";-import { calendarData } from "@/lib/calendarData";+import { calendarData } from "@/lib/data/calendarData";import { Metadata } from "next";diff --git a/src/components/AddJobForm.tsx b/src/components/AddJobForm.tsxindex ece0489..714efbd 100644--- a/src/components/AddJobForm.tsx+++ b/src/components/AddJobForm.tsx@@ -11,39 +11,22 @@ import {} 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 { 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";-import { ComboboxFormItem } from "./ComboBoxFormItem";+import { Combobox } from "./ComboBox";import { DatePicker } from "./DatePicker";+import SelectFormCtrl from "./Select";+import { JOB_SOURCES } from "@/lib/data/jobSourcesData";+import { SALARY_RANGES } from "@/lib/data/salaryRangeData";interface AddJobFormProps {jobStatuses: { id: string; statusName: string }[];}export default function AddJobForm({ jobStatuses }: AddJobFormProps) {- const jobSources = [- { 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" },- ];-const form = useForm<z.infer<typeof AddJobFormSchema>>({resolver: zodResolver(AddJobFormSchema),// mode: "onChange",@@ -130,15 +113,17 @@ export default function AddJobForm({ jobStatuses }: AddJobFormProps) {control={form.control}name="source"render={({ field }) => (- <ComboboxFormItem- options={jobSources}- label="Job Source"- field={field}- onChange={field.onChange}- onCreate={(value) => {- handleOnCreate(value);- }}- ></ComboboxFormItem>+ <FormItem className="flex flex-col">+ <FormLabel>Job Source</FormLabel>+ <Combobox+ options={JOB_SOURCES}+ field={field}+ onCreate={(value) => {+ handleOnCreate(value);+ }}+ />+ <FormMessage />+ </FormItem>)}/></div>@@ -148,36 +133,14 @@ export default function AddJobForm({ jobStatuses }: AddJobFormProps) {control={form.control}name="status"render={({ field }) => (- <FormItem className="flex flex-col">+ <FormItem className="flex flex-col [&>button]:capitalize"><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>+ <SelectFormCtrl+ label="Job Status"+ dataKey="statusName"+ options={jobStatuses}+ field={field}+ /><FormMessage /></FormItem>)}@@ -220,7 +183,12 @@ export default function AddJobForm({ jobStatuses }: AddJobFormProps) {<FormItem className="flex flex-col"><FormLabel>Salary Range</FormLabel><FormControl>- <Input {...field} />+ <SelectFormCtrl+ label="Salary Range"+ dataKey="range"+ options={SALARY_RANGES}+ field={field}+ /></FormControl><FormMessage /></FormItem>@@ -253,7 +221,11 @@ export default function AddJobForm({ jobStatuses }: AddJobFormProps) {// className="md:col-span><DialogClose>- <Button variant="outline" className="mt-2 md:mt-0 w-full">+ <Button+ type="reset"+ variant="outline"+ className="mt-2 md:mt-0 w-full"+ >Cancel</Button></DialogClose>diff --git a/src/components/ComboBox.tsx b/src/components/ComboBox.tsxnew file mode 100644index 0000000..e8b5436--- /dev/null+++ b/src/components/ComboBox.tsx@@ -0,0 +1,118 @@+"use client";++import { Check, ChevronsUpDown } from "lucide-react";+import { ControllerRenderProps, FieldName } from "react-hook-form";++import { cn } from "@/lib/utils";+import { Button } from "@/components/ui/button";+import {+ Command,+ CommandEmpty,+ CommandGroup,+ CommandInput,+ CommandItem,+ CommandList,+} from "@/components/ui/command";+import {+ FormControl,+ FormItem,+ FormLabel,+ FormMessage,+} from "@/components/ui/form";+import {+ Popover,+ PopoverContent,+ PopoverTrigger,+} from "@/components/ui/popover";+import { Job } from "@/models/job.model";+import { ScrollArea } from "./ui/scroll-area";+import { useState } from "react";++export type ComboboxOptions = {+ value: string;+ label: string;+};++interface ComboboxProps {+ options: ComboboxOptions[];+ field: ControllerRenderProps<Job, any>;+ onCreate?: (value: string) => void;+}++export function Combobox({ options, field, onCreate }: ComboboxProps) {+ const [newOption, setNewOption] = useState<string>("");+ const [isPopoverOpen, setIsPopoverOpen] = useState<boolean>(false);++ return (+ <Popover open={isPopoverOpen} onOpenChange={setIsPopoverOpen}>+ <PopoverTrigger asChild>+ <FormControl>+ <Button+ variant="outline"+ role="combobox"+ className={cn(+ "w-[200px] justify-between",+ !field.value && "text-muted-foreground"+ )}+ >+ {field.value+ ? options.find((option) => option.value === field.value)?.label+ : `Select ${field.name}`}+ <ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />+ </Button>+ </FormControl>+ </PopoverTrigger>+ <PopoverContent className="w-[200px] p-0">+ <Command>+ <CommandInput+ value={newOption}+ onValueChange={(val: string) => setNewOption(val)}+ placeholder={`Search ${field.name}`}+ />+ <CommandEmpty+ onClick={() => {+ if (onCreate) {+ onCreate(newOption);+ setNewOption(newOption);+ }+ }}+ className="flex cursor-pointer items-center justify-center gap-1 italic"+ >+ <p>Create: </p>+ <p className="block max-w-48 truncate font-semibold text-primary">+ {newOption}+ </p>+ </CommandEmpty>+ <ScrollArea>+ <CommandGroup>+ <CommandList>+ {options.map((option) => (+ <CommandItem+ value={option.label}+ key={option.value}+ onSelect={() => {+ if (field.onChange) {+ field.onChange(option.value);+ setIsPopoverOpen(false);+ }+ }}+ >+ <Check+ className={cn(+ "mr-2 h-4 w-4",+ option.value === field.value+ ? "opacity-100"+ : "opacity-0"+ )}+ />+ {option.label}+ </CommandItem>+ ))}+ </CommandList>+ </CommandGroup>+ </ScrollArea>+ </Command>+ </PopoverContent>+ </Popover>+ );+}diff --git a/src/components/ComboBoxFormItem.tsx b/src/components/ComboBoxFormItem.tsxdeleted file mode 100644index ffc97df..0000000--- a/src/components/ComboBoxFormItem.tsx+++ /dev/null@@ -1,128 +0,0 @@-"use client";--import { Check, ChevronsUpDown } from "lucide-react";-import { ControllerRenderProps, FieldName } from "react-hook-form";--import { cn } from "@/lib/utils";-import { Button } from "@/components/ui/button";-import {- Command,- CommandEmpty,- CommandGroup,- CommandInput,- CommandItem,- CommandList,-} from "@/components/ui/command";-import {- FormControl,- FormItem,- FormLabel,- FormMessage,-} from "@/components/ui/form";-import {- Popover,- PopoverContent,- PopoverTrigger,-} from "@/components/ui/popover";-import { Job } from "@/models/job.model";-import { ScrollArea } from "./ui/scroll-area";-import { useState } from "react";--export type ComboboxOptions = {- value: string;- label: string;-};--interface ComboboxFormItemProps {- options: ComboboxOptions[];- field: ControllerRenderProps<Job, any>;- label: string;- onChange?: (...event: any[]) => void;- onCreate?: (value: string) => void;-}--export function ComboboxFormItem({- options,- field,- label,- onChange,- onCreate,-}: ComboboxFormItemProps) {- const [newOption, setNewOption] = useState<string>("");-- return (- <FormItem className="flex flex-col">- <FormLabel>{label}</FormLabel>- <Popover>- <PopoverTrigger asChild>- <FormControl>- <Button- variant="outline"- role="combobox"- className={cn(- "w-[200px] justify-between",- !field.value && "text-muted-foreground"- )}- >- {field.value- ? options.find((option) => option.value === field.value)?.label- : `Select ${label}`}- <ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />- </Button>- </FormControl>- </PopoverTrigger>- <PopoverContent className="w-[200px] p-0">- <Command>- <CommandInput- value={newOption}- onValueChange={(val: string) => setNewOption(val)}- placeholder={`Search ${label}`}- />- <CommandEmpty- onClick={() => {- if (onCreate) {- onCreate(newOption);- setNewOption("");- }- }}- className="flex cursor-pointer items-center justify-center gap-1 italic"- >- <p>Create: </p>- <p className="block max-w-48 truncate font-semibold text-primary">- {newOption}- </p>- </CommandEmpty>- <ScrollArea>- <CommandGroup>- <CommandList>- {options.map((option) => (- <CommandItem- value={option.label}- key={option.value}- onSelect={() => {- if (onChange) {- onChange(option.value);- }- }}- >- <Check- className={cn(- "mr-2 h-4 w-4",- option.value === field.value- ? "opacity-100"- : "opacity-0"- )}- />- {option.label}- </CommandItem>- ))}- </CommandList>- </CommandGroup>- </ScrollArea>- </Command>- </PopoverContent>- </Popover>- <FormMessage />- </FormItem>- );-}diff --git a/src/components/DatePicker.tsx b/src/components/DatePicker.tsxindex 24aab1b..ae96739 100644--- a/src/components/DatePicker.tsx+++ b/src/components/DatePicker.tsx@@ -21,6 +21,7 @@ import {import { ControllerRenderProps } from "react-hook-form";import { Job } from "@/models/job.model";import { useState } from "react";+import { FormControl } from "./ui/form";interface DatePickerProps {field: ControllerRenderProps<Job, any>;@@ -33,16 +34,22 @@ export function DatePicker({ field, presets }: DatePickerProps) {return (<Popover open={isPopoverOpen} onOpenChange={setIsPopoverOpen}><PopoverTrigger asChild>- <Button- variant={"outline"}- className={cn(- "w-[280px] justify-start text-left font-normal",- !field.value && "text-muted-foreground"- )}- >- <CalendarIcon className="mr-2 h-4 w-4" />- {field.value ? format(field.value, "PPP") : <span>Pick a date</span>}- </Button>+ <FormControl>+ <Button+ variant={"outline"}+ className={cn(+ "w-[280px] justify-start text-left font-normal",+ !field.value && "text-muted-foreground"+ )}+ >+ <CalendarIcon className="mr-2 h-4 w-4" />+ {field.value ? (+ format(field.value, "PPP")+ ) : (+ <span>Pick a date</span>+ )}+ </Button>+ </FormControl></PopoverTrigger><PopoverContent className="flex w-auto flex-col space-y-2 p-2">{presets ? (diff --git a/src/components/Select.tsx b/src/components/Select.tsxnew file mode 100644index 0000000..9921cdd--- /dev/null+++ b/src/components/Select.tsx@@ -0,0 +1,54 @@+import React from "react";+import {+ Select,+ SelectContent,+ SelectGroup,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from "./ui/select";+import { FormControl } from "./ui/form";+import { ControllerRenderProps } from "react-hook-form";+import { Job } from "@/models/job.model";++interface SelectProps {+ label: string;+ options: any[];+ field: ControllerRenderProps<Job, any>;+ dataKey: string;+}++function SelectFormCtrl({ label, options, field, dataKey }: SelectProps) {+ return (+ <>+ <Select+ onValueChange={field.onChange}+ defaultValue={field.value}+ name={field.name}+ >+ <FormControl>+ <SelectTrigger aria-label={`Select ${label}`} className="w-[200px]">+ <SelectValue placeholder={`Select ${label}`} />+ </SelectTrigger>+ </FormControl>+ <SelectContent>+ <SelectGroup>+ {options.map((option) => {+ return (+ <SelectItem+ key={option.id}+ value={option[dataKey]}+ className="capitalize"+ >+ {option[dataKey]}+ </SelectItem>+ );+ })}+ </SelectGroup>+ </SelectContent>+ </Select>+ </>+ );+}++export default SelectFormCtrl;diff --git a/src/components/WeeklyBarChart.tsx b/src/components/WeeklyBarChart.tsxindex 5f19270..4ce77a0 100644--- a/src/components/WeeklyBarChart.tsx+++ b/src/components/WeeklyBarChart.tsx@@ -1,5 +1,5 @@"use client";-import { barChartData } from "@/lib/barChartData";+import { barChartData } from "@/lib/data/barChartData";import { ResponsiveBar } from "@nivo/bar";export default function WeeklyBarChart() {diff --git a/src/lib/barChartData.ts b/src/lib/data/barChartData.tssimilarity index 100%rename from src/lib/barChartData.tsrename to src/lib/data/barChartData.tsdiff --git a/src/lib/calendarData.ts b/src/lib/data/calendarData.tssimilarity index 100%rename from src/lib/calendarData.tsrename to src/lib/data/calendarData.tsdiff --git a/src/lib/data/jobSourcesData.ts b/src/lib/data/jobSourcesData.tsnew file mode 100644index 0000000..45ea856--- /dev/null+++ b/src/lib/data/jobSourcesData.ts@@ -0,0 +1,11 @@+export 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" },+];diff --git a/src/lib/myJobsData.ts b/src/lib/data/myJobsData.tssimilarity index 100%rename from src/lib/myJobsData.tsrename to src/lib/data/myJobsData.tsdiff --git a/src/lib/data/salaryRangeData.ts b/src/lib/data/salaryRangeData.tsnew file mode 100644index 0000000..8e7e9bd--- /dev/null+++ b/src/lib/data/salaryRangeData.ts@@ -0,0 +1,16 @@+export const SALARY_RANGES = [+ { id: 1, range: "0 - 10,000" },+ { id: 2, range: "10,000 - 20,000" },+ { id: 3, range: "20,000 - 30,000" },+ { id: 4, range: "30,000 - 40,000" },+ { id: 5, range: "40,000 - 50,000" },+ { id: 6, range: "50,000 - 60,000" },+ { id: 7, range: "60,000 - 70,000" },+ { id: 8, range: "70,000 - 80,000" },+ { id: 9, range: "80,000 - 90,000" },+ { id: 10, range: "90,000 - 100,000" },+ { id: 11, range: "100,000 - 110,000" },+ { id: 12, range: "120,000 - 130,000" },+ { id: 13, range: "130,000 - 140,000" },+ { id: 14, range: "> 150,000" },+];diff --git a/src/lib/seedData.js b/src/lib/data/seedData.jssimilarity index 100%rename from src/lib/seedData.jsrename to src/lib/data/seedData.jsdiff --git a/src/models/addJobForm.schema.ts b/src/models/addJobForm.schema.tsindex 29554a3..a9e942d 100644--- a/src/models/addJobForm.schema.ts+++ b/src/models/addJobForm.schema.ts@@ -45,7 +45,6 @@ export const AddJobFormSchema = z.object({//dateApplied: z.date(),salaryRange: z.string(),- testCombo: z.string(),jobDescription: z.string().min(10, {message: "Job description must be at least 10 characters.",}),diff --git a/src/models/job.model.ts b/src/models/job.model.tsindex 011cdf2..4822ce3 100644--- a/src/models/job.model.ts+++ b/src/models/job.model.ts@@ -7,6 +7,5 @@ export interface Job {dueDate: Date;dateApplied: Date;salaryRange: string;- testCombo: string;jobDescription: string;}diff --git a/tsconfig.json b/tsconfig.jsonindex c310a9d..5f75a09 100644--- a/tsconfig.json+++ b/tsconfig.json@@ -21,6 +21,6 @@"@/*": ["./src/*"]}},- "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "src/lib/seedData.js"],+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "src/lib/data/seedData.js"],"exclude": ["node_modules"]}