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 combobox form item component
Khuram Niaza25cf0ae724a
diff --git a/package-lock.json b/package-lock.jsonindex eb65057..8f16da8 100644--- a/package-lock.json+++ b/package-lock.json@@ -19,6 +19,7 @@"@radix-ui/react-label": "^2.0.2","@radix-ui/react-popover": "^1.0.7","@radix-ui/react-progress": "^1.0.3",+ "@radix-ui/react-scroll-area": "^1.0.5","@radix-ui/react-select": "^2.0.0","@radix-ui/react-slot": "^1.0.2","@radix-ui/react-toast": "^1.1.5",@@ -26,6 +27,7 @@"bcryptjs": "^2.4.3","class-variance-authority": "^0.7.0","clsx": "^2.1.1",+ "cmdk": "^1.0.0","date-fns": "^3.6.0","lucide-react": "^0.379.0","next": "14.2.3",@@ -1300,6 +1302,37 @@}}},+ "node_modules/@radix-ui/react-scroll-area": {+ "version": "1.0.5",+ "resolved": "https://registry.npmjs.org/@radix-ui/react-scroll-area/-/react-scroll-area-1.0.5.tgz",+ "integrity": "sha512-b6PAgH4GQf9QEn8zbT2XUHpW5z8BzqEc7Kl11TwDrvuTrxlkcjTD5qa/bxgKr+nmuXKu4L/W5UZ4mlP/VG/5Gw==",+ "dependencies": {+ "@babel/runtime": "^7.13.10",+ "@radix-ui/number": "1.0.1",+ "@radix-ui/primitive": "1.0.1",+ "@radix-ui/react-compose-refs": "1.0.1",+ "@radix-ui/react-context": "1.0.1",+ "@radix-ui/react-direction": "1.0.1",+ "@radix-ui/react-presence": "1.0.1",+ "@radix-ui/react-primitive": "1.0.3",+ "@radix-ui/react-use-callback-ref": "1.0.1",+ "@radix-ui/react-use-layout-effect": "1.0.1"+ },+ "peerDependencies": {+ "@types/react": "*",+ "@types/react-dom": "*",+ "react": "^16.8 || ^17.0 || ^18.0",+ "react-dom": "^16.8 || ^17.0 || ^18.0"+ },+ "peerDependenciesMeta": {+ "@types/react": {+ "optional": true+ },+ "@types/react-dom": {+ "optional": true+ }+ }+ },"node_modules/@radix-ui/react-select": {"version": "2.0.0","resolved": "https://registry.npmjs.org/@radix-ui/react-select/-/react-select-2.0.0.tgz",@@ -2410,6 +2443,19 @@"node": ">=6"}},+ "node_modules/cmdk": {+ "version": "1.0.0",+ "resolved": "https://registry.npmjs.org/cmdk/-/cmdk-1.0.0.tgz",+ "integrity": "sha512-gDzVf0a09TvoJ5jnuPvygTB77+XdOSwEmJ88L6XPFPlv7T3RxbP9jgenfylrAMD0+Le1aO0nVjQUzl2g+vjz5Q==",+ "dependencies": {+ "@radix-ui/react-dialog": "1.0.5",+ "@radix-ui/react-primitive": "1.0.3"+ },+ "peerDependencies": {+ "react": "^18.0.0",+ "react-dom": "^18.0.0"+ }+ },"node_modules/color-convert": {"version": "2.0.1","resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",diff --git a/package.json b/package.jsonindex 76edfcf..2bd921d 100644--- a/package.json+++ b/package.json@@ -21,6 +21,7 @@"@radix-ui/react-label": "^2.0.2","@radix-ui/react-popover": "^1.0.7","@radix-ui/react-progress": "^1.0.3",+ "@radix-ui/react-scroll-area": "^1.0.5","@radix-ui/react-select": "^2.0.0","@radix-ui/react-slot": "^1.0.2","@radix-ui/react-toast": "^1.1.5",@@ -28,6 +29,7 @@"bcryptjs": "^2.4.3","class-variance-authority": "^0.7.0","clsx": "^2.1.1",+ "cmdk": "^1.0.0","date-fns": "^3.6.0","lucide-react": "^0.379.0","next": "14.2.3",diff --git a/src/components/AddJobForm.tsx b/src/components/AddJobForm.tsxindex daf1d57..2efab26 100644--- a/src/components/AddJobForm.tsx+++ b/src/components/AddJobForm.tsx@@ -29,12 +29,32 @@ 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";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 comboOptions = [+ { label: "option1", value: "optionvalue1" },+ { label: "option2", value: "optionvalue2" },+ { label: "option3", value: "optionvalue3" },+ { label: "option4", value: "optionvalue4" },+ ];+ const selectedValue = comboOptions[1].value;+const form = useForm<z.infer<typeof AddJobFormSchema>>({resolver: zodResolver(AddJobFormSchema),// mode: "onChange",@@ -56,6 +76,10 @@ export default function AddJobForm({ jobStatuses }: AddJobFormProps) {});}+ function handleOnCreate(value: string) {+ console.log("handle new optoin created: ", value);+ }+return (<><Form {...form}>@@ -102,7 +126,7 @@ export default function AddJobForm({ jobStatuses }: AddJobFormProps) {name="location"render={({ field }) => (<FormItem className="flex flex-col">- <FormLabel>Location</FormLabel>+ <FormLabel>Job Location</FormLabel><FormControl><Input {...field} /></FormControl>@@ -117,13 +141,15 @@ export default function AddJobForm({ jobStatuses }: AddJobFormProps) {control={form.control}name="source"render={({ field }) => (- <FormItem className="flex flex-col">- <FormLabel>Source</FormLabel>- <FormControl>- <Input {...field} />- </FormControl>- <FormMessage />- </FormItem>+ <ComboboxFormItem+ options={jobSources}+ label="Job Source"+ field={field}+ onChange={field.onChange}+ onCreate={(value) => {+ handleOnCreate(value);+ }}+ ></ComboboxFormItem>)}/></div>@@ -308,6 +334,7 @@ export default function AddJobForm({ jobStatuses }: AddJobFormProps) {)}/></div>+{/* Job Description */}<div className="md:col-span-2"><FormFielddiff --git a/src/components/ComboBoxFormItem.tsx b/src/components/ComboBoxFormItem.tsxnew file mode 100644index 0000000..ffc97df--- /dev/null+++ b/src/components/ComboBoxFormItem.tsx@@ -0,0 +1,128 @@+"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/ui/command.tsx b/src/components/ui/command.tsxnew file mode 100644index 0000000..dbb2e8b--- /dev/null+++ b/src/components/ui/command.tsx@@ -0,0 +1,155 @@+"use client"++import * as React from "react"+import { type DialogProps } from "@radix-ui/react-dialog"+import { Command as CommandPrimitive } from "cmdk"+import { Search } from "lucide-react"++import { cn } from "@/lib/utils"+import { Dialog, DialogContent } from "@/components/ui/dialog"++const Command = React.forwardRef<+ React.ElementRef<typeof CommandPrimitive>,+ React.ComponentPropsWithoutRef<typeof CommandPrimitive>+>(({ className, ...props }, ref) => (+ <CommandPrimitive+ ref={ref}+ className={cn(+ "flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",+ className+ )}+ {...props}+ />+))+Command.displayName = CommandPrimitive.displayName++interface CommandDialogProps extends DialogProps {}++const CommandDialog = ({ children, ...props }: CommandDialogProps) => {+ return (+ <Dialog {...props}>+ <DialogContent className="overflow-hidden p-0 shadow-lg">+ <Command className="[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">+ {children}+ </Command>+ </DialogContent>+ </Dialog>+ )+}++const CommandInput = React.forwardRef<+ React.ElementRef<typeof CommandPrimitive.Input>,+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>+>(({ className, ...props }, ref) => (+ <div className="flex items-center border-b px-3" cmdk-input-wrapper="">+ <Search className="mr-2 h-4 w-4 shrink-0 opacity-50" />+ <CommandPrimitive.Input+ ref={ref}+ className={cn(+ "flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",+ className+ )}+ {...props}+ />+ </div>+))++CommandInput.displayName = CommandPrimitive.Input.displayName++const CommandList = React.forwardRef<+ React.ElementRef<typeof CommandPrimitive.List>,+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>+>(({ className, ...props }, ref) => (+ <CommandPrimitive.List+ ref={ref}+ className={cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className)}+ {...props}+ />+))++CommandList.displayName = CommandPrimitive.List.displayName++const CommandEmpty = React.forwardRef<+ React.ElementRef<typeof CommandPrimitive.Empty>,+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>+>((props, ref) => (+ <CommandPrimitive.Empty+ ref={ref}+ className="py-6 text-center text-sm"+ {...props}+ />+))++CommandEmpty.displayName = CommandPrimitive.Empty.displayName++const CommandGroup = React.forwardRef<+ React.ElementRef<typeof CommandPrimitive.Group>,+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>+>(({ className, ...props }, ref) => (+ <CommandPrimitive.Group+ ref={ref}+ className={cn(+ "overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",+ className+ )}+ {...props}+ />+))++CommandGroup.displayName = CommandPrimitive.Group.displayName++const CommandSeparator = React.forwardRef<+ React.ElementRef<typeof CommandPrimitive.Separator>,+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>+>(({ className, ...props }, ref) => (+ <CommandPrimitive.Separator+ ref={ref}+ className={cn("-mx-1 h-px bg-border", className)}+ {...props}+ />+))+CommandSeparator.displayName = CommandPrimitive.Separator.displayName++const CommandItem = React.forwardRef<+ React.ElementRef<typeof CommandPrimitive.Item>,+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>+>(({ className, ...props }, ref) => (+ <CommandPrimitive.Item+ ref={ref}+ className={cn(+ "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50",+ className+ )}+ {...props}+ />+))++CommandItem.displayName = CommandPrimitive.Item.displayName++const CommandShortcut = ({+ className,+ ...props+}: React.HTMLAttributes<HTMLSpanElement>) => {+ return (+ <span+ className={cn(+ "ml-auto text-xs tracking-widest text-muted-foreground",+ className+ )}+ {...props}+ />+ )+}+CommandShortcut.displayName = "CommandShortcut"++export {+ Command,+ CommandDialog,+ CommandInput,+ CommandList,+ CommandEmpty,+ CommandGroup,+ CommandItem,+ CommandShortcut,+ CommandSeparator,+}diff --git a/src/components/ui/scroll-area.tsx b/src/components/ui/scroll-area.tsxnew file mode 100644index 0000000..0b4a48d--- /dev/null+++ b/src/components/ui/scroll-area.tsx@@ -0,0 +1,48 @@+"use client"++import * as React from "react"+import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area"++import { cn } from "@/lib/utils"++const ScrollArea = React.forwardRef<+ React.ElementRef<typeof ScrollAreaPrimitive.Root>,+ React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root>+>(({ className, children, ...props }, ref) => (+ <ScrollAreaPrimitive.Root+ ref={ref}+ className={cn("relative overflow-hidden", className)}+ {...props}+ >+ <ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]">+ {children}+ </ScrollAreaPrimitive.Viewport>+ <ScrollBar />+ <ScrollAreaPrimitive.Corner />+ </ScrollAreaPrimitive.Root>+))+ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName++const ScrollBar = React.forwardRef<+ React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,+ React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>+>(({ className, orientation = "vertical", ...props }, ref) => (+ <ScrollAreaPrimitive.ScrollAreaScrollbar+ ref={ref}+ orientation={orientation}+ className={cn(+ "flex touch-none select-none transition-colors",+ orientation === "vertical" &&+ "h-full w-2.5 border-l border-l-transparent p-[1px]",+ orientation === "horizontal" &&+ "h-2.5 flex-col border-t border-t-transparent p-[1px]",+ className+ )}+ {...props}+ >+ <ScrollAreaPrimitive.ScrollAreaThumb className="relative flex-1 rounded-full bg-border" />+ </ScrollAreaPrimitive.ScrollAreaScrollbar>+))+ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName++export { ScrollArea, ScrollBar }diff --git a/src/models/addJobForm.schema.ts b/src/models/addJobForm.schema.tsindex a9e942d..29554a3 100644--- a/src/models/addJobForm.schema.ts+++ b/src/models/addJobForm.schema.ts@@ -45,6 +45,7 @@ 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.tsnew file mode 100644index 0000000..011cdf2--- /dev/null+++ b/src/models/job.model.ts@@ -0,0 +1,12 @@+export interface Job {+ source: string;+ title: string;+ company: string;+ location: string;+ status: string;+ dueDate: Date;+ dateApplied: Date;+ salaryRange: string;+ testCombo: string;+ jobDescription: string;+}