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 job form and minor refactor

Khuram Niazd21ed97fc4f6
diff --git a/next.config.mjs b/next.config.mjs
index 0a7c9af..d5ffe88 100644
--- a/next.config.mjs
+++ b/next.config.mjs
@@ -1,5 +1,14 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
+ async redirects() {
+ return [
+ {
+ source: '/',
+ destination: '/dashboard',
+ permanent: true,
+ },
+ ]
+ },
};
export default nextConfig;
diff --git a/package-lock.json b/package-lock.json
index 703a980..8edc4d0 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -18,6 +18,7 @@
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-progress": "^1.0.3",
+ "@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-tooltip": "^1.0.7",
"bcryptjs": "^2.4.3",
@@ -744,6 +745,14 @@
"@prisma/debug": "5.14.0"
}
},
+ "node_modules/@radix-ui/number": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/@radix-ui/number/-/number-1.0.1.tgz",
+ "integrity": "sha512-T5gIdVO2mmPW3NNhjNgEP3cqMXjXL9UbO0BzWcXfvdBs+BohbQxvd/K5hSVKmn9/lbTdsQVKbUcP5WLCwvUbBg==",
+ "dependencies": {
+ "@babel/runtime": "^7.13.10"
+ }
+ },
"node_modules/@radix-ui/primitive": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@radix-ui/primitive/-/primitive-1.0.1.tgz",
@@ -1250,6 +1259,49 @@
}
}
},
+ "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",
+ "integrity": "sha512-RH5b7af4oHtkcHS7pG6Sgv5rk5Wxa7XI8W5gvB1N/yiuDGZxko1ynvOiVhFM7Cis2A8zxF9bTOUVbRDzPepe6w==",
+ "dependencies": {
+ "@babel/runtime": "^7.13.10",
+ "@radix-ui/number": "1.0.1",
+ "@radix-ui/primitive": "1.0.1",
+ "@radix-ui/react-collection": "1.0.3",
+ "@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-dismissable-layer": "1.0.5",
+ "@radix-ui/react-focus-guards": "1.0.1",
+ "@radix-ui/react-focus-scope": "1.0.4",
+ "@radix-ui/react-id": "1.0.1",
+ "@radix-ui/react-popper": "1.1.3",
+ "@radix-ui/react-portal": "1.0.4",
+ "@radix-ui/react-primitive": "1.0.3",
+ "@radix-ui/react-slot": "1.0.2",
+ "@radix-ui/react-use-callback-ref": "1.0.1",
+ "@radix-ui/react-use-controllable-state": "1.0.1",
+ "@radix-ui/react-use-layout-effect": "1.0.1",
+ "@radix-ui/react-use-previous": "1.0.1",
+ "@radix-ui/react-visually-hidden": "1.0.3",
+ "aria-hidden": "^1.1.1",
+ "react-remove-scroll": "2.5.5"
+ },
+ "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-slot": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@radix-ui/react-slot/-/react-slot-1.0.2.tgz",
@@ -1372,6 +1424,23 @@
}
}
},
+ "node_modules/@radix-ui/react-use-previous": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-use-previous/-/react-use-previous-1.0.1.tgz",
+ "integrity": "sha512-cV5La9DPwiQ7S0gf/0qiD6YgNqM5Fk97Kdrlc5yBcrF3jyEZQwm7vYFqMo4IfeHgJXsRaMvLABFtd0OVEmZhDw==",
+ "dependencies": {
+ "@babel/runtime": "^7.13.10"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "react": "^16.8 || ^17.0 || ^18.0"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ }
+ }
+ },
"node_modules/@radix-ui/react-use-rect": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@radix-ui/react-use-rect/-/react-use-rect-1.0.1.tgz",
diff --git a/package.json b/package.json
index f59b436..e8c7b83 100644
--- a/package.json
+++ b/package.json
@@ -20,6 +20,7 @@
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-progress": "^1.0.3",
+ "@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-tooltip": "^1.0.7",
"bcryptjs": "^2.4.3",
diff --git a/src/app/dashboard/layout.tsx b/src/app/dashboard/layout.tsx
index 1444680..716b93b 100644
--- a/src/app/dashboard/layout.tsx
+++ b/src/app/dashboard/layout.tsx
@@ -6,7 +6,6 @@ export default function RootLayout({
}: Readonly<{
children: React.ReactNode;
}>) {
- const loggedIn: User = { $id: "23", name: "JobSync", email: "[email protected]" };
return (
<div className="flex min-h-screen w-full flex-col bg-muted/40">
<Sidebar />
diff --git a/src/app/dashboard/myjobs/page.tsx b/src/app/dashboard/myjobs/page.tsx
index e2ee54f..68fc3a4 100644
--- a/src/app/dashboard/myjobs/page.tsx
+++ b/src/app/dashboard/myjobs/page.tsx
@@ -29,6 +29,8 @@ import {
} from "@/components/ui/table";
import { MY_JOBS_DATA } from "@/lib/myJobsData";
import { Metadata } from "next";
+import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog";
+import { AddJob } from "@/components/AddJob";
export const metadata: Metadata = {
title: "My Jobs | JobSync",
@@ -68,12 +70,22 @@ function MyJobs() {
Export
</span>
</Button>
- <Button size="sm" className="h-8 gap-1">
- <PlusCircle className="h-3.5 w-3.5" />
- <span className="sr-only sm:not-sr-only sm:whitespace-nowrap">
- Add Job
- </span>
- </Button>
+ <Dialog>
+ <DialogTrigger asChild>
+ <Button size="sm" className="h-8 gap-1">
+ <PlusCircle className="h-3.5 w-3.5" />
+ <span className="sr-only sm:not-sr-only sm:whitespace-nowrap">
+ Add Job
+ </span>
+ </Button>
+ </DialogTrigger>
+ <DialogContent
+ className="lg:max-w-screen-lg overflow-y-scroll lg:max-h-screen"
+ // className="sm:max-w-[425px]"
+ >
+ <AddJob />
+ </DialogContent>
+ </Dialog>
</div>
</div>
</CardHeader>
diff --git a/src/auth.ts b/src/auth.ts
index 3147c1a..0b085ad 100644
--- a/src/auth.ts
+++ b/src/auth.ts
@@ -3,7 +3,7 @@ import Credentials from "next-auth/providers/credentials";
import { z } from "zod";
var bcrypt = require("bcryptjs");
import { authConfig } from "./auth.config";
-import { User } from "./models/user";
+import { User } from "./models/user.model";
import prisma from "./lib/db";
async function getUser(email: string): Promise<User | undefined> {
diff --git a/src/components/AddJob.tsx b/src/components/AddJob.tsx
new file mode 100644
index 0000000..ff3ee00
--- /dev/null
+++ b/src/components/AddJob.tsx
@@ -0,0 +1,177 @@
+import { Button } from "@/components/ui/button";
+import {
+ DialogClose,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from "@/components/ui/dialog";
+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";
+
+export function AddJob() {
+ return (
+ <>
+ <DialogHeader>
+ <DialogTitle>Add Job</DialogTitle>
+ </DialogHeader>
+ <form className="grid grid-cols-1 md:grid-cols-2 gap-4 p-4">
+ {/* Job Title */}
+ <div className="flex flex-col">
+ <Label htmlFor="title" className="mb-1">
+ Job Title
+ </Label>
+ <Input
+ id="title"
+ name="title"
+ type="text"
+ className="p-2 border rounded"
+ />
+ </div>
+
+ {/* Company */}
+ <div className="flex flex-col">
+ <Label htmlFor="company" className="mb-1">
+ Company
+ </Label>
+ <Input
+ id="company"
+ name="company"
+ type="text"
+ className="p-2 border rounded"
+ />
+ </div>
+
+ {/* Location */}
+ <div className="flex flex-col">
+ <Label htmlFor="location" className="mb-1">
+ Location
+ </Label>
+ <Input
+ id="location"
+ name="location"
+ type="text"
+ className="p-2 border rounded"
+ />
+ </div>
+
+ {/* Job Source */}
+ <div className="flex flex-col">
+ <Label htmlFor="source" className="mb-1">
+ Source
+ </Label>
+ <Input
+ id="source"
+ name="source"
+ type="text"
+ className="p-2 border rounded"
+ />
+ </div>
+
+ {/* Status */}
+ <div className="flex flex-col">
+ <Label htmlFor="status" className="mb-1">
+ Status
+ </Label>
+ <Select defaultValue="draft">
+ <SelectTrigger
+ id="status"
+ aria-label="Select status"
+ className="w-[180px]"
+ >
+ <SelectValue placeholder="Select job status" />
+ </SelectTrigger>
+ <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>
+ </div>
+
+ {/* Due Date */}
+ <div className="flex flex-col">
+ <Label htmlFor="due_date" className="mb-1">
+ Due Date
+ </Label>
+ <Input
+ id="due_date"
+ name="due_date"
+ type="text"
+ className="p-2 border rounded"
+ />
+ </div>
+
+ {/* Date Applied */}
+ <div className="flex flex-col">
+ <Label htmlFor="date_applied" className="mb-1">
+ Date Applied
+ </Label>
+ <Input
+ id="date_applied"
+ name="date_applied"
+ type="text"
+ className="p-2 border rounded"
+ />
+ </div>
+
+ {/* Salary Range */}
+ <div className="flex flex-col">
+ <Label htmlFor="salary_range" className="mb-1">
+ Salary Range
+ </Label>
+ <Input
+ id="salary_range"
+ name="salary_range"
+ type="text"
+ className="p-2 border rounded"
+ />
+ </div>
+
+ {/* Job Description */}
+ <div className="flex flex-col md:col-span-2">
+ <Label htmlFor="message" className="mb-1">
+ Job Description
+ </Label>
+ <Textarea
+ className="h-36 overflow-auto"
+ placeholder="Paste you job description here."
+ id="message"
+ />
+ </div>
+ </form>
+ {/* <div className="grid gap-4 py-4">
+ <div className="grid grid-cols-4 items-center gap-4">
+ <Label htmlFor="title" className="text-right">
+ Job Title
+ </Label>
+ <Input id="title" className="col-span-3" />
+ </div>
+ <div className="grid grid-cols-4 items-center gap-4">
+ <Label htmlFor="company" className="text-right">
+ Company
+ </Label>
+ <Input id="company" className="col-span-3" />
+ </div>
+ </div> */}
+ <DialogFooter>
+ <DialogClose>
+ <Button variant="outline">Cancel</Button>
+ </DialogClose>
+ <Button type="submit">Save</Button>
+ </DialogFooter>
+ </>
+ );
+}
diff --git a/src/components/Header.tsx b/src/components/Header.tsx
index b407fc8..497961f 100644
--- a/src/components/Header.tsx
+++ b/src/components/Header.tsx
@@ -19,12 +19,13 @@ import {
} from "@/components/ui/sheet";
import { ModeToggle } from "./ModeToggle";
import { SIDEBAR_LINKS } from "@/lib/constants";
-import { auth, signOut } from "@/auth";
+import { signOut } from "@/auth";
import UserAvatar from "./UserAvatar";
-import { SessionUser } from "@/models/user";
+import { getCurrentUser } from "@/utils/user.utils";
async function Header() {
- const session = await auth();
+ // const session = await auth();
+ const user = await getCurrentUser();
return (
<header className="sticky top-0 z-30 flex h-14 items-center gap-4 border-b bg-background px-4 sm:static sm:h-auto sm:border-0 sm:bg-transparent sm:px-6">
<Sheet>
@@ -74,7 +75,7 @@ async function Header() {
<DropdownMenu>
<DropdownMenuTrigger>
- <UserAvatar user={session?.user as SessionUser} />
+ <UserAvatar user={user} />
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuLabel>My Account</DropdownMenuLabel>
diff --git a/src/components/UserAvatar.tsx b/src/components/UserAvatar.tsx
index 6479e01..7b0f39a 100644
--- a/src/components/UserAvatar.tsx
+++ b/src/components/UserAvatar.tsx
@@ -1,9 +1,8 @@
-import { Button } from "./ui/button";
import Image from "next/image";
-import { useSession } from "next-auth/react";
-import { SessionUser } from "@/models/user";
+import { CurrentUser } from "@/models/user.model";
+// import { useSession } from "next-auth/react";
-export default function UserAvatar({ user }: { user: SessionUser }) {
+export default function UserAvatar({ user }: { user: CurrentUser | null }) {
// const { data: session, status } = useSession();
// console.log("session user :", session?.user, status);
if (!user) return null;
diff --git a/src/components/ui/dialog.tsx b/src/components/ui/dialog.tsx
new file mode 100644
index 0000000..01ff19c
--- /dev/null
+++ b/src/components/ui/dialog.tsx
@@ -0,0 +1,122 @@
+"use client"
+
+import * as React from "react"
+import * as DialogPrimitive from "@radix-ui/react-dialog"
+import { X } from "lucide-react"
+
+import { cn } from "@/lib/utils"
+
+const Dialog = DialogPrimitive.Root
+
+const DialogTrigger = DialogPrimitive.Trigger
+
+const DialogPortal = DialogPrimitive.Portal
+
+const DialogClose = DialogPrimitive.Close
+
+const DialogOverlay = React.forwardRef<
+ React.ElementRef<typeof DialogPrimitive.Overlay>,
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
+>(({ className, ...props }, ref) => (
+ <DialogPrimitive.Overlay
+ ref={ref}
+ className={cn(
+ "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
+ className
+ )}
+ {...props}
+ />
+))
+DialogOverlay.displayName = DialogPrimitive.Overlay.displayName
+
+const DialogContent = React.forwardRef<
+ React.ElementRef<typeof DialogPrimitive.Content>,
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
+>(({ className, children, ...props }, ref) => (
+ <DialogPortal>
+ <DialogOverlay />
+ <DialogPrimitive.Content
+ ref={ref}
+ className={cn(
+ "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
+ className
+ )}
+ {...props}
+ >
+ {children}
+ <DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
+ <X className="h-4 w-4" />
+ <span className="sr-only">Close</span>
+ </DialogPrimitive.Close>
+ </DialogPrimitive.Content>
+ </DialogPortal>
+))
+DialogContent.displayName = DialogPrimitive.Content.displayName
+
+const DialogHeader = ({
+ className,
+ ...props
+}: React.HTMLAttributes<HTMLDivElement>) => (
+ <div
+ className={cn(
+ "flex flex-col space-y-1.5 text-center sm:text-left",
+ className
+ )}
+ {...props}
+ />
+)
+DialogHeader.displayName = "DialogHeader"
+
+const DialogFooter = ({
+ className,
+ ...props
+}: React.HTMLAttributes<HTMLDivElement>) => (
+ <div
+ className={cn(
+ "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
+ className
+ )}
+ {...props}
+ />
+)
+DialogFooter.displayName = "DialogFooter"
+
+const DialogTitle = React.forwardRef<
+ React.ElementRef<typeof DialogPrimitive.Title>,
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
+>(({ className, ...props }, ref) => (
+ <DialogPrimitive.Title
+ ref={ref}
+ className={cn(
+ "text-lg font-semibold leading-none tracking-tight",
+ className
+ )}
+ {...props}
+ />
+))
+DialogTitle.displayName = DialogPrimitive.Title.displayName
+
+const DialogDescription = React.forwardRef<
+ React.ElementRef<typeof DialogPrimitive.Description>,
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
+>(({ className, ...props }, ref) => (
+ <DialogPrimitive.Description
+ ref={ref}
+ className={cn("text-sm text-muted-foreground", className)}
+ {...props}
+ />
+))
+DialogDescription.displayName = DialogPrimitive.Description.displayName
+
+export {
+ Dialog,
+ DialogPortal,
+ DialogOverlay,
+ DialogClose,
+ DialogTrigger,
+ DialogContent,
+ DialogHeader,
+ DialogFooter,
+ DialogTitle,
+ DialogDescription,
+}
diff --git a/src/components/ui/select.tsx b/src/components/ui/select.tsx
new file mode 100644
index 0000000..cbe5a36
--- /dev/null
+++ b/src/components/ui/select.tsx
@@ -0,0 +1,160 @@
+"use client"
+
+import * as React from "react"
+import * as SelectPrimitive from "@radix-ui/react-select"
+import { Check, ChevronDown, ChevronUp } from "lucide-react"
+
+import { cn } from "@/lib/utils"
+
+const Select = SelectPrimitive.Root
+
+const SelectGroup = SelectPrimitive.Group
+
+const SelectValue = SelectPrimitive.Value
+
+const SelectTrigger = React.forwardRef<
+ React.ElementRef<typeof SelectPrimitive.Trigger>,
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
+>(({ className, children, ...props }, ref) => (
+ <SelectPrimitive.Trigger
+ ref={ref}
+ className={cn(
+ "flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
+ className
+ )}
+ {...props}
+ >
+ {children}
+ <SelectPrimitive.Icon asChild>
+ <ChevronDown className="h-4 w-4 opacity-50" />
+ </SelectPrimitive.Icon>
+ </SelectPrimitive.Trigger>
+))
+SelectTrigger.displayName = SelectPrimitive.Trigger.displayName
+
+const SelectScrollUpButton = React.forwardRef<
+ React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>
+>(({ className, ...props }, ref) => (
+ <SelectPrimitive.ScrollUpButton
+ ref={ref}
+ className={cn(
+ "flex cursor-default items-center justify-center py-1",
+ className
+ )}
+ {...props}
+ >
+ <ChevronUp className="h-4 w-4" />
+ </SelectPrimitive.ScrollUpButton>
+))
+SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName
+
+const SelectScrollDownButton = React.forwardRef<
+ React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>
+>(({ className, ...props }, ref) => (
+ <SelectPrimitive.ScrollDownButton
+ ref={ref}
+ className={cn(
+ "flex cursor-default items-center justify-center py-1",
+ className
+ )}
+ {...props}
+ >
+ <ChevronDown className="h-4 w-4" />
+ </SelectPrimitive.ScrollDownButton>
+))
+SelectScrollDownButton.displayName =
+ SelectPrimitive.ScrollDownButton.displayName
+
+const SelectContent = React.forwardRef<
+ React.ElementRef<typeof SelectPrimitive.Content>,
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
+>(({ className, children, position = "popper", ...props }, ref) => (
+ <SelectPrimitive.Portal>
+ <SelectPrimitive.Content
+ ref={ref}
+ className={cn(
+ "relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
+ position === "popper" &&
+ "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
+ className
+ )}
+ position={position}
+ {...props}
+ >
+ <SelectScrollUpButton />
+ <SelectPrimitive.Viewport
+ className={cn(
+ "p-1",
+ position === "popper" &&
+ "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
+ )}
+ >
+ {children}
+ </SelectPrimitive.Viewport>
+ <SelectScrollDownButton />
+ </SelectPrimitive.Content>
+ </SelectPrimitive.Portal>
+))
+SelectContent.displayName = SelectPrimitive.Content.displayName
+
+const SelectLabel = React.forwardRef<
+ React.ElementRef<typeof SelectPrimitive.Label>,
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>
+>(({ className, ...props }, ref) => (
+ <SelectPrimitive.Label
+ ref={ref}
+ className={cn("py-1.5 pl-8 pr-2 text-sm font-semibold", className)}
+ {...props}
+ />
+))
+SelectLabel.displayName = SelectPrimitive.Label.displayName
+
+const SelectItem = React.forwardRef<
+ React.ElementRef<typeof SelectPrimitive.Item>,
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>
+>(({ className, children, ...props }, ref) => (
+ <SelectPrimitive.Item
+ ref={ref}
+ className={cn(
+ "relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
+ className
+ )}
+ {...props}
+ >
+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
+ <SelectPrimitive.ItemIndicator>
+ <Check className="h-4 w-4" />
+ </SelectPrimitive.ItemIndicator>
+ </span>
+
+ <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
+ </SelectPrimitive.Item>
+))
+SelectItem.displayName = SelectPrimitive.Item.displayName
+
+const SelectSeparator = React.forwardRef<
+ React.ElementRef<typeof SelectPrimitive.Separator>,
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
+>(({ className, ...props }, ref) => (
+ <SelectPrimitive.Separator
+ ref={ref}
+ className={cn("-mx-1 my-1 h-px bg-muted", className)}
+ {...props}
+ />
+))
+SelectSeparator.displayName = SelectPrimitive.Separator.displayName
+
+export {
+ Select,
+ SelectGroup,
+ SelectValue,
+ SelectTrigger,
+ SelectContent,
+ SelectLabel,
+ SelectItem,
+ SelectSeparator,
+ SelectScrollUpButton,
+ SelectScrollDownButton,
+}
diff --git a/src/components/ui/textarea.tsx b/src/components/ui/textarea.tsx
new file mode 100644
index 0000000..9f9a6dc
--- /dev/null
+++ b/src/components/ui/textarea.tsx
@@ -0,0 +1,24 @@
+import * as React from "react"
+
+import { cn } from "@/lib/utils"
+
+export interface TextareaProps
+ extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {}
+
+const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
+ ({ className, ...props }, ref) => {
+ return (
+ <textarea
+ className={cn(
+ "flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
+ className
+ )}
+ ref={ref}
+ {...props}
+ />
+ )
+ }
+)
+Textarea.displayName = "Textarea"
+
+export { Textarea }
diff --git a/src/middleware.ts b/src/middleware.ts
index 6f6efcd..97c6da1 100644
--- a/src/middleware.ts
+++ b/src/middleware.ts
@@ -8,5 +8,6 @@ export const config = {
matcher: [
// "/((?!api|_next/static|_next/image|.*\\.png$).*)",
"/dashboard",
+ "/dashboard/myjobs",
],
};
diff --git a/src/models/user.ts b/src/models/user.model.ts
similarity index 63%
rename from src/models/user.ts
rename to src/models/user.model.ts
index 3701e9e..02be80f 100644
--- a/src/models/user.ts
+++ b/src/models/user.model.ts
@@ -5,7 +5,10 @@ export interface User {
password: string;
}
-export type SessionUser = {
+export type CurrentUser = {
+ id: string;
name: string;
email: string;
+ iat?: number;
+ exp?: number;
};
diff --git a/src/utils/user.utils.ts b/src/utils/user.utils.ts
new file mode 100644
index 0000000..a75e250
--- /dev/null
+++ b/src/utils/user.utils.ts
@@ -0,0 +1,17 @@
+import "server-only";
+import { auth } from "@/auth";
+import { CurrentUser } from "@/models/user.model";
+
+export const getCurrentUser = async () => {
+ const session = await auth();
+ if (!session?.accessToken) return null;
+ const { sub, name, email, iat, exp } = session?.accessToken;
+ const user: CurrentUser = {
+ id: sub,
+ name,
+ email,
+ iat,
+ exp,
+ };
+ return user;
+};
diff --git a/types/index.t.ts b/types/index.t.ts
index 2989693..2de0fdd 100644
--- a/types/index.t.ts
+++ b/types/index.t.ts
@@ -1,16 +1,16 @@
-declare interface HeaderProps {
- type?: "title" | "greeting";
- title: string;
- subtext: string;
- user?: string;
-}
+// declare interface HeaderProps {
+// type?: "title" | "greeting";
+// title: string;
+// subtext: string;
+// user?: string;
+// }
-declare type User = {
- $id: string;
- email: string;
- name: string;
-};
+// declare type User = {
+// $id: string;
+// email: string;
+// name: string;
+// };
-declare interface SidebarProps {
- user: User;
-}
+// declare interface SidebarProps {
+// user: User;
+// }