ts ki mkc
This commit is contained in:
@@ -15,7 +15,7 @@ export default async function JobDetailPage({ params }: JobPageProps) {
|
||||
if (isNaN(jobId)) notFound();
|
||||
|
||||
const jobRes = await db.select().from(jobs).where(eq(jobs.id, jobId)).limit(1);
|
||||
if (jobRes.length === 0) notFound();
|
||||
if (jobRes.length === 0 || !jobRes[0]) notFound();
|
||||
const job = jobRes[0];
|
||||
|
||||
const companyRes = await db.select().from(companies).where(eq(companies.id, job.companyId)).limit(1);
|
||||
|
||||
53
apps/admin/app/(main)/jobs/new/actions.ts
Normal file
53
apps/admin/app/(main)/jobs/new/actions.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
'use server';
|
||||
import { db, companies, jobs } from '@workspace/db';
|
||||
|
||||
export async function createJob(formData: FormData) {
|
||||
const companyIdRaw = formData.get('companyId');
|
||||
const companyId = companyIdRaw ? Number(companyIdRaw) : undefined;
|
||||
const title = String(formData.get('title') ?? '').trim();
|
||||
const link = String(formData.get('link') ?? '').trim();
|
||||
const description = String(formData.get('description') ?? '').trim() || 'N/A';
|
||||
const location = String(formData.get('location') ?? '').trim() || 'N/A';
|
||||
const imageURL =
|
||||
String(formData.get('imageURL') ?? '').trim() || 'https://via.placeholder.com/100x100?text=Job';
|
||||
const salary = String(formData.get('salary') ?? '').trim() || 'N/A';
|
||||
const deadlineRaw = formData.get('applicationDeadline');
|
||||
const applicationDeadline = deadlineRaw ? new Date(String(deadlineRaw)) : new Date();
|
||||
const minCGPA = formData.get('minCGPA') !== null ? String(formData.get('minCGPA')) : '0';
|
||||
const minSSC = formData.get('minSSC') !== null ? String(formData.get('minSSC')) : '0';
|
||||
const minHSC = formData.get('minHSC') !== null ? String(formData.get('minHSC')) : '0';
|
||||
const allowDeadKT = formData.get('allowDeadKT') === 'on' || formData.get('allowDeadKT') === 'true';
|
||||
const allowLiveKT = formData.get('allowLiveKT') === 'on' || formData.get('allowLiveKT') === 'true';
|
||||
|
||||
if (!companyId || !title) return { error: 'Company and title are required.' };
|
||||
|
||||
await db.insert(jobs).values({
|
||||
companyId,
|
||||
title,
|
||||
link,
|
||||
description,
|
||||
location,
|
||||
imageURL,
|
||||
salary,
|
||||
applicationDeadline,
|
||||
active: true,
|
||||
minCGPA,
|
||||
minSSC,
|
||||
minHSC,
|
||||
allowDeadKT,
|
||||
allowLiveKT,
|
||||
});
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
export async function createCompany(formData: FormData) {
|
||||
const name = String(formData.get('name') ?? '').trim();
|
||||
const email = String(formData.get('email') ?? '').trim();
|
||||
const link = String(formData.get('link') ?? '').trim();
|
||||
const description = String(formData.get('description') ?? '').trim();
|
||||
const imageURL = String(formData.get('imageURL') ?? '').trim() || 'https://via.placeholder.com/100x100?text=Company';
|
||||
if (!name || !email || !link || !description) return { error: 'All fields are required.' };
|
||||
const [inserted] = await db.insert(companies).values({ name, email, link, description, imageURL }).returning();
|
||||
if (!inserted) return { error: 'Failed to add company.' };
|
||||
return { success: true, company: { id: inserted.id, name: inserted.name } };
|
||||
}
|
||||
31
apps/admin/app/(main)/jobs/new/loading.tsx
Normal file
31
apps/admin/app/(main)/jobs/new/loading.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
import { Skeleton } from '@workspace/ui/components/skeleton';
|
||||
|
||||
export default function Loading() {
|
||||
return (
|
||||
<div className="min-h-screen flex items-center justify-center bg-gray-50">
|
||||
<div className="w-full max-w-2xl px-4">
|
||||
<div className="rounded-lg bg-white shadow p-8">
|
||||
<Skeleton className="h-8 w-1/2 mb-8 mx-auto" />
|
||||
<div className="space-y-6">
|
||||
<Skeleton className="h-5 w-full" />
|
||||
<Skeleton className="h-5 w-full" />
|
||||
<Skeleton className="h-20 w-full" />
|
||||
<Skeleton className="h-5 w-full" />
|
||||
<Skeleton className="h-5 w-full" />
|
||||
<Skeleton className="h-5 w-full" />
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
<Skeleton className="h-5 w-full" />
|
||||
<Skeleton className="h-5 w-full" />
|
||||
<Skeleton className="h-5 w-full" />
|
||||
</div>
|
||||
<div className="flex gap-6">
|
||||
<Skeleton className="h-5 w-24" />
|
||||
<Skeleton className="h-5 w-24" />
|
||||
</div>
|
||||
<Skeleton className="h-10 w-full mt-6" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
366
apps/admin/app/(main)/jobs/new/new-job-form.tsx
Normal file
366
apps/admin/app/(main)/jobs/new/new-job-form.tsx
Normal file
@@ -0,0 +1,366 @@
|
||||
'use client';
|
||||
import { useState, useTransition } from 'react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { Input } from '@workspace/ui/components/input';
|
||||
import { Textarea } from '@workspace/ui/components/textarea';
|
||||
import { Button } from '@workspace/ui/components/button';
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from '@workspace/ui/components/form';
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@workspace/ui/components/select';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@workspace/ui/components/card';
|
||||
import { jobSchema, JobFormData } from './schema';
|
||||
import { createJob, createCompany } from './actions';
|
||||
import { Popover, PopoverTrigger, PopoverContent } from '@workspace/ui/components/popover';
|
||||
import { Calendar } from '@workspace/ui/components/calendar';
|
||||
import { format } from 'date-fns';
|
||||
import { Calendar as CalendarIcon } from 'lucide-react';
|
||||
import { cn } from '@workspace/ui/lib/utils';
|
||||
|
||||
function NewJobForm({ companies }: { companies: { id: number; name: string }[] }) {
|
||||
const [success, setSuccess] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [isPending, startTransition] = useTransition();
|
||||
const [showModal, setShowModal] = useState(false);
|
||||
const [addingCompany, setAddingCompany] = useState(false);
|
||||
const [companyList, setCompanyList] = useState(companies);
|
||||
const [newCompanyName, setNewCompanyName] = useState('');
|
||||
const [newCompanyEmail, setNewCompanyEmail] = useState('');
|
||||
const [newCompanyLink, setNewCompanyLink] = useState('');
|
||||
const [newCompanyDescription, setNewCompanyDescription] = useState('');
|
||||
const [newCompanyImageURL, setNewCompanyImageURL] = useState('');
|
||||
const [companyError, setCompanyError] = useState<string | null>(null);
|
||||
const form = useForm<JobFormData>({
|
||||
resolver: zodResolver(jobSchema),
|
||||
defaultValues: {
|
||||
companyId: companies[0]?.id ?? 0,
|
||||
title: '',
|
||||
link: '',
|
||||
description: '',
|
||||
location: '',
|
||||
imageURL: '',
|
||||
salary: '',
|
||||
applicationDeadline: new Date(),
|
||||
minCGPA: 0,
|
||||
minSSC: 0,
|
||||
minHSC: 0,
|
||||
allowDeadKT: true,
|
||||
allowLiveKT: true,
|
||||
},
|
||||
});
|
||||
|
||||
async function handleSubmit(formData: FormData) {
|
||||
setError(null);
|
||||
setSuccess(false);
|
||||
startTransition(async () => {
|
||||
const result = await createJob(formData);
|
||||
if (result?.success) {
|
||||
setSuccess(true);
|
||||
form.reset(form.formState.defaultValues);
|
||||
} else {
|
||||
setError(result?.error || 'Failed to create job');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function handleAddCompany(e: React.FormEvent) {
|
||||
e.preventDefault();
|
||||
setCompanyError(null);
|
||||
if (!newCompanyName.trim() || !newCompanyEmail.trim() || !newCompanyLink.trim() || !newCompanyDescription.trim()) return;
|
||||
setAddingCompany(true);
|
||||
const formData = new FormData();
|
||||
formData.append('name', newCompanyName.trim());
|
||||
formData.append('email', newCompanyEmail.trim());
|
||||
formData.append('link', newCompanyLink.trim());
|
||||
formData.append('description', newCompanyDescription.trim());
|
||||
formData.append('imageURL', newCompanyImageURL.trim());
|
||||
const result = await createCompany(formData);
|
||||
if (result?.success && result.company) {
|
||||
setCompanyList((prev) => [...prev, result.company]);
|
||||
form.setValue('companyId', result.company.id);
|
||||
setNewCompanyName('');
|
||||
setNewCompanyEmail('');
|
||||
setNewCompanyLink('');
|
||||
setNewCompanyDescription('');
|
||||
setNewCompanyImageURL('');
|
||||
setShowModal(false);
|
||||
} else {
|
||||
setCompanyError(result?.error || 'Failed to add company');
|
||||
}
|
||||
setAddingCompany(false);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen py-8">
|
||||
<div className="max-w-2xl mx-auto px-4">
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-2xl font-bold text-center">Create a New Job</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Form {...form}>
|
||||
<form action={handleSubmit} className="space-y-6">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="companyId"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Company *</FormLabel>
|
||||
<Select onValueChange={(val) => field.onChange(val)} value={String(field.value || '')}>
|
||||
<FormControl>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="Select company" />
|
||||
</SelectTrigger>
|
||||
</FormControl>
|
||||
<SelectContent>
|
||||
{companies.map((c) => (
|
||||
<SelectItem key={c.id} value={String(c.id)}>
|
||||
{c.name}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="title"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Title *</FormLabel>
|
||||
<FormControl>
|
||||
<Input placeholder="Job title" {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="link"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Job Link *</FormLabel>
|
||||
<FormControl>
|
||||
<Input placeholder="https://company.com/job" {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="description"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Description *</FormLabel>
|
||||
<FormControl>
|
||||
<Textarea placeholder="Job description" {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="location"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Location *</FormLabel>
|
||||
<FormControl>
|
||||
<Input placeholder="Location" {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="imageURL"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Image URL</FormLabel>
|
||||
<FormControl>
|
||||
<Input placeholder="https://..." {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="salary"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Salary *</FormLabel>
|
||||
<FormControl>
|
||||
<Input placeholder="Salary" {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="applicationDeadline"
|
||||
render={({ field }) => {
|
||||
const getDisplayDate = (value: string) => {
|
||||
if (!value) return '';
|
||||
try {
|
||||
return format(new Date(value), 'PPP');
|
||||
} catch {
|
||||
return value;
|
||||
}
|
||||
};
|
||||
const selectedDate = field.value ? new Date(field.value) : undefined;
|
||||
// Use a local handler to ensure immediate update
|
||||
const handleSelect = (date: Date | undefined) => {
|
||||
// Use setTimeout to ensure the onChange is processed after popover closes
|
||||
setTimeout(() => {
|
||||
if (date) {
|
||||
field.onChange(date.toISOString().slice(0, 10));
|
||||
} else {
|
||||
field.onChange('');
|
||||
}
|
||||
}, 0);
|
||||
};
|
||||
return (
|
||||
<FormItem className="flex flex-col">
|
||||
<FormLabel>Application Deadline *</FormLabel>
|
||||
<Popover>
|
||||
<PopoverTrigger asChild>
|
||||
<FormControl>
|
||||
<Button
|
||||
variant="outline"
|
||||
className={cn(
|
||||
"w-[240px] pl-3 text-left font-normal",
|
||||
!field.value && "text-muted-foreground"
|
||||
)}
|
||||
type="button"
|
||||
>
|
||||
{getDisplayDate(typeof field.value === 'string' ? field.value : '') || <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">
|
||||
<Calendar
|
||||
mode="single"
|
||||
selected={selectedDate}
|
||||
onSelect={handleSelect}
|
||||
captionLayout="dropdown"
|
||||
key={typeof field.value === 'string' ? field.value : 'empty'}
|
||||
/>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="minCGPA"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Min CGPA</FormLabel>
|
||||
<FormControl>
|
||||
<Input type="number" step="0.01" placeholder="0" {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="minSSC"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Min SSC %</FormLabel>
|
||||
<FormControl>
|
||||
<Input type="number" step="0.01" placeholder="0" {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="minHSC"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Min HSC %</FormLabel>
|
||||
<FormControl>
|
||||
<Input type="number" step="0.01" placeholder="0" {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex gap-6">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="allowDeadKT"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Allow Dead KT</FormLabel>
|
||||
<FormControl>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={field.value}
|
||||
onChange={(e) => field.onChange(e.target.checked)}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="allowLiveKT"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Allow Live KT</FormLabel>
|
||||
<FormControl>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={field.value}
|
||||
onChange={(e) => field.onChange(e.target.checked)}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
{success && <div className="text-green-600">Job created successfully!</div>}
|
||||
{error && <div className="text-red-600">{error}</div>}
|
||||
<Button type="submit" disabled={isPending}>
|
||||
{isPending ? 'Creating...' : 'Create Job'}
|
||||
</Button>
|
||||
</form>
|
||||
</Form>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default NewJobForm;
|
||||
7
apps/admin/app/(main)/jobs/new/page.tsx
Normal file
7
apps/admin/app/(main)/jobs/new/page.tsx
Normal file
@@ -0,0 +1,7 @@
|
||||
import { db, companies } from '@workspace/db';
|
||||
import NewJobForm from './new-job-form';
|
||||
|
||||
export default async function NewJobPage() {
|
||||
const companyList = await db.select().from(companies);
|
||||
return <NewJobForm companies={companyList.map((c) => ({ id: c.id, name: c.name }))} />;
|
||||
}
|
||||
19
apps/admin/app/(main)/jobs/new/schema.ts
Normal file
19
apps/admin/app/(main)/jobs/new/schema.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import * as z from 'zod';
|
||||
|
||||
export const jobSchema = z.object({
|
||||
companyId: z.number().min(1, 'Company is required'),
|
||||
title: z.string().min(1, 'Title is required'),
|
||||
link: z.string().url('Invalid URL'),
|
||||
description: z.string().min(1, 'Description is required'),
|
||||
location: z.string().min(1, 'Location is required'),
|
||||
imageURL: z.string().url('Invalid URL'),
|
||||
salary: z.string().min(1, 'Salary is required'),
|
||||
applicationDeadline: z.date(),
|
||||
minCGPA: z.number().min(0),
|
||||
minSSC: z.number().min(0),
|
||||
minHSC: z.number().min(0),
|
||||
allowDeadKT: z.boolean(),
|
||||
allowLiveKT: z.boolean(),
|
||||
});
|
||||
|
||||
export type JobFormData = z.infer<typeof jobSchema>;
|
||||
@@ -7,12 +7,9 @@ import { Button } from '@workspace/ui/components/button';
|
||||
export const dynamic = 'force-dynamic';
|
||||
|
||||
async function getAllJobsWithCompany() {
|
||||
const allJobs = await db.select().from(jobs);
|
||||
const allCompanies = await db.select().from(companies);
|
||||
return allJobs.map(job => ({
|
||||
...job,
|
||||
company: allCompanies.find(c => c.id === job.companyId) || null,
|
||||
}));
|
||||
return await db.query.jobs.findMany({
|
||||
with: { company: true },
|
||||
});
|
||||
}
|
||||
|
||||
export default async function JobsListPage() {
|
||||
|
||||
@@ -8,7 +8,7 @@ const navLinks = [
|
||||
|
||||
export default function MainLayout({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<div className="min-h-screen bg-[#f8fafc] font-sans">
|
||||
<div className="min-h-screen bg-background font-sans">
|
||||
{/* Sticky top navbar */}
|
||||
<header className="sticky top-0 z-30 w-full bg-[#1e293b] shadow-lg">
|
||||
<div className="max-w-7xl mx-auto flex items-center justify-between px-6 py-3">
|
||||
@@ -30,7 +30,9 @@ export default function MainLayout({ children }: { children: React.ReactNode })
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
<main className="max-w-7xl mx-auto px-4 py-8 md:py-12 bg-[#f8fafc] min-h-screen">{children}</main>
|
||||
<main className="max-w-7xl mx-auto px-4 py-8 md:py-12 bg-background min-h-screen">
|
||||
{children}
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
import { Card, CardContent, CardFooter, CardHeader, CardTitle } from '@workspace/ui/components/card';
|
||||
import {
|
||||
Card, CardContent, CardFooter, CardHeader, CardTitle,
|
||||
} from '@workspace/ui/components/card';
|
||||
import { Input } from '@workspace/ui/components/input';
|
||||
import { Textarea } from '@workspace/ui/components/textarea';
|
||||
import { Button } from '@workspace/ui/components/button';
|
||||
import Link from 'next/link';
|
||||
import { revalidatePath } from 'next/cache';
|
||||
import { db, companies, jobs } from '@workspace/db';
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger, DialogDescription } from '@workspace/ui/components/dialog';
|
||||
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@workspace/ui/components/accordion';
|
||||
import { Badge } from '@workspace/ui/components/badge';
|
||||
|
||||
// -----------------------
|
||||
// Server Actions
|
||||
// -----------------------
|
||||
import Link from 'next/link';
|
||||
import { revalidatePath } from 'next/cache';
|
||||
import { db, companies, jobs } from '@workspace/db';
|
||||
|
||||
async function createCompany(formData: FormData) {
|
||||
'use server';
|
||||
@@ -19,7 +17,9 @@ async function createCompany(formData: FormData) {
|
||||
const email = String(formData.get('email') ?? '').trim();
|
||||
const link = String(formData.get('link') ?? '').trim();
|
||||
const description = String(formData.get('description') ?? '').trim() || 'N/A';
|
||||
const imageURL = String(formData.get('imageURL') ?? '').trim() || 'https://via.placeholder.com/200x200?text=Company';
|
||||
const imageURL =
|
||||
String(formData.get('imageURL') ?? '').trim() ||
|
||||
'https://via.placeholder.com/200x200?text=Company';
|
||||
|
||||
if (!name) return;
|
||||
|
||||
@@ -34,7 +34,9 @@ async function createJob(formData: FormData) {
|
||||
const link = String(formData.get('jobLink') ?? '').trim();
|
||||
const description = String(formData.get('jobDescription') ?? '').trim() || 'N/A';
|
||||
const location = String(formData.get('location') ?? '').trim() || 'N/A';
|
||||
const imageURL = String(formData.get('jobImageURL') ?? '').trim() || 'https://via.placeholder.com/100x100?text=Job';
|
||||
const imageURL =
|
||||
String(formData.get('jobImageURL') ?? '').trim() ||
|
||||
'https://via.placeholder.com/100x100?text=Job';
|
||||
const salary = String(formData.get('salary') ?? '').trim() || 'N/A';
|
||||
const deadlineRaw = formData.get('deadline');
|
||||
const applicationDeadline = deadlineRaw ? new Date(String(deadlineRaw)) : new Date();
|
||||
@@ -55,103 +57,62 @@ async function createJob(formData: FormData) {
|
||||
revalidatePath('/');
|
||||
}
|
||||
|
||||
// -----------------------
|
||||
// Component Helpers
|
||||
// -----------------------
|
||||
|
||||
async function getDashboardData() {
|
||||
const comps = await db.select().from(companies);
|
||||
const allJobs = await db.select().from(jobs);
|
||||
|
||||
return comps.map((comp) => ({
|
||||
...comp,
|
||||
jobs: allJobs.filter((j) => j.companyId === comp.id),
|
||||
}));
|
||||
return await db.query.companies.findMany({ with: { jobs: true } });
|
||||
}
|
||||
|
||||
export default async function DashboardPage() {
|
||||
const data = await getDashboardData();
|
||||
|
||||
return (
|
||||
<div className="space-y-12">
|
||||
<section className="flex flex-col md:flex-row md:justify-between md:items-center gap-6 md:gap-0">
|
||||
<div>
|
||||
<h1 className="text-4xl font-extrabold text-blue-700 tracking-tight mb-1">Companies Dashboard</h1>
|
||||
<p className="text-gray-500 text-lg">Manage companies and their job openings.</p>
|
||||
</div>
|
||||
<div className="space-y-16 px-4 md:px-16 py-8 bg-white min-h-screen">
|
||||
<section className="flex justify-between items-center">
|
||||
<h1 className="text-3xl font-bold text-gray-800">Companies Dashboard</h1>
|
||||
<Dialog>
|
||||
<DialogTrigger asChild>
|
||||
<Button className="bg-gradient-to-r from-blue-500 to-purple-500 text-white shadow-lg hover:from-blue-600 hover:to-purple-600 transition">Add New Company</Button>
|
||||
<Button>Add New Company</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>Add a new company</DialogTitle>
|
||||
<DialogDescription>
|
||||
Fill in the details below to add a new company to the portal.
|
||||
</DialogDescription>
|
||||
<DialogDescription>Fill in the details below to add a new company.</DialogDescription>
|
||||
</DialogHeader>
|
||||
<form action={createCompany} className="grid grid-cols-1 gap-4 py-4">
|
||||
<form action={createCompany} className="grid gap-4 py-4">
|
||||
<Input name="name" placeholder="Company name" required />
|
||||
<Input name="email" placeholder="Contact email" type="email" required />
|
||||
<Input name="link" placeholder="Website / careers link" />
|
||||
<Input name="imageURL" placeholder="Image URL" />
|
||||
<Textarea name="description" placeholder="Short description" />
|
||||
<Button type="submit" className="w-fit bg-blue-600 text-white hover:bg-blue-700">Add Company</Button>
|
||||
<Button type="submit">Add Company</Button>
|
||||
</form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</section>
|
||||
|
||||
<section className="space-y-8">
|
||||
{data.length === 0 && <Card className="p-10 text-gray-400 text-center shadow-lg border border-gray-200 bg-white">No companies yet. Add your first company to get started!</Card>}
|
||||
|
||||
<div className="grid gap-10 md:grid-cols-2 lg:grid-cols-3">
|
||||
{data.map((company) => (
|
||||
<Card key={company.id} className="flex flex-col shadow-xl border-l-8 border-blue-400 border border-gray-200 bg-white rounded-2xl overflow-hidden">
|
||||
<CardHeader className="p-6 pb-2 flex flex-row items-center gap-4">
|
||||
<img src={company.imageURL} alt={company.name} className="w-16 h-16 rounded-xl border-2 border-blue-200 object-cover shadow" />
|
||||
<div className="flex-1">
|
||||
<h3 className="font-bold text-xl text-blue-700">{company.name}</h3>
|
||||
<a href={company.link} target="_blank" rel="noopener noreferrer" className="text-sm text-blue-500 hover:underline">{company.link}</a>
|
||||
<section className="space-y-12">
|
||||
{data.map((company) => (
|
||||
<div key={company.id} className="space-y-4">
|
||||
<h2 className="text-xl font-semibold text-gray-700">{company.name}</h2>
|
||||
<div className="flex flex-wrap gap-4">
|
||||
{company.jobs.length > 0 ? (
|
||||
company.jobs.map((job) => (
|
||||
<Card key={job.id} className="w-48 p-4 border border-gray-200 bg-gray-50">
|
||||
<CardContent className="space-y-1">
|
||||
<div className="text-md font-medium text-gray-800 truncate">{job.title}</div>
|
||||
<div className="text-sm text-gray-500 truncate">{job.location}</div>
|
||||
<div className="text-sm text-gray-400 truncate">{job.salary}</div>
|
||||
<div className={`text-xs mt-2 px-2 py-1 rounded ${job.active ? 'bg-blue-100 text-blue-700' : 'bg-gray-100 text-gray-500'}`}>{job.active ? 'Active' : 'Inactive'}</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
))
|
||||
) : (
|
||||
<div className="w-48 h-24 flex items-center justify-center text-sm text-gray-400 border border-dashed border-gray-300">
|
||||
No jobs
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="px-6 pb-2 space-y-3">
|
||||
<div className="text-gray-500 text-sm mb-2">{company.description}</div>
|
||||
<h4 className="font-semibold text-gray-700 mb-1">Open Positions</h4>
|
||||
{company.jobs.length === 0 && <p className="text-sm text-gray-400">No jobs yet.</p>}
|
||||
<div className="flex flex-col gap-2">
|
||||
{company.jobs.map((job) => (
|
||||
<Link key={job.id} href={`/jobs/${job.id}`} className="flex justify-between items-center p-3 rounded-lg hover:bg-blue-50 transition-colors border border-transparent hover:border-blue-200">
|
||||
<span className="font-medium text-gray-800">{job.title}</span>
|
||||
<Badge variant={job.active ? "secondary" : "outline"} className={job.active ? 'bg-blue-100 text-blue-700 border-blue-200' : 'bg-gray-100 text-gray-500 border-gray-200'}>{job.active ? "Active" : "Inactive"}</Badge>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</CardContent>
|
||||
<CardFooter className="mt-auto p-0">
|
||||
<Accordion type="single" collapsible className="w-full">
|
||||
<AccordionItem value="add-job">
|
||||
<AccordionTrigger className="px-6 text-blue-700 hover:text-blue-900 font-semibold">
|
||||
Add New Job
|
||||
</AccordionTrigger>
|
||||
<AccordionContent className="p-6 bg-blue-50 border-t border-blue-100">
|
||||
<form action={createJob} className="flex flex-col w-full gap-3">
|
||||
<input type="hidden" name="companyId" value={company.id} />
|
||||
<Input name="title" placeholder="Job title" required />
|
||||
<Input name="jobLink" placeholder="Job link" />
|
||||
<Input name="location" placeholder="Location" />
|
||||
<Input name="salary" placeholder="Salary" />
|
||||
<Input name="deadline" type="date" />
|
||||
<Textarea name="jobDescription" placeholder="Job description" />
|
||||
<Button type="submit" size="sm" className="bg-gradient-to-r from-blue-500 to-purple-500 text-white hover:from-blue-600 hover:to-purple-600 transition self-start">Add Job</Button>
|
||||
</form>
|
||||
</AccordionContent>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -12,10 +12,12 @@
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@hookform/resolvers": "^5.1.1",
|
||||
"@tailwindcss/postcss": "^4.0.8",
|
||||
"@tanstack/react-table": "^8.21.3",
|
||||
"@workspace/db": "workspace:*",
|
||||
"@workspace/ui": "workspace:*",
|
||||
"date-fns": "^4.1.0",
|
||||
"framer-motion": "^12.22.0",
|
||||
"lucide-react": "^0.475.0",
|
||||
"next": "^15.3.4",
|
||||
@@ -23,6 +25,7 @@
|
||||
"next-themes": "^0.4.6",
|
||||
"react": "^19.1.0",
|
||||
"react-dom": "^19.1.0",
|
||||
"react-hook-form": "^7.59.0",
|
||||
"tailwindcss": "^4.0.8",
|
||||
"zod": "^3.25.67"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { drizzle } from 'drizzle-orm/neon-http';
|
||||
import * as schema from './schema.ts';
|
||||
|
||||
export const db = drizzle(process.env.DATABASE_URL!);
|
||||
export const db = drizzle(process.env.DATABASE_URL!, { schema });
|
||||
|
||||
export * from './schema.ts';
|
||||
30
packages/db/migrations/0006_mysterious_lionheart.sql
Normal file
30
packages/db/migrations/0006_mysterious_lionheart.sql
Normal file
@@ -0,0 +1,30 @@
|
||||
ALTER TABLE "applications" RENAME COLUMN "job_id" TO "jobId";--> statement-breakpoint
|
||||
ALTER TABLE "applications" RENAME COLUMN "student_id" TO "studentId";--> statement-breakpoint
|
||||
ALTER TABLE "applications" RENAME COLUMN "resume_id" TO "resumeId";--> statement-breakpoint
|
||||
ALTER TABLE "grades" RENAME COLUMN "student_id" TO "studentId";--> statement-breakpoint
|
||||
ALTER TABLE "internships" RENAME COLUMN "student_id" TO "studentId";--> statement-breakpoint
|
||||
ALTER TABLE "jobs" RENAME COLUMN "company_id" TO "companyId";--> statement-breakpoint
|
||||
ALTER TABLE "resumes" RENAME COLUMN "student_id" TO "studentId";--> statement-breakpoint
|
||||
ALTER TABLE "applications" DROP CONSTRAINT "applications_job_id_jobs_id_fk";
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "applications" DROP CONSTRAINT "applications_student_id_students_id_fk";
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "applications" DROP CONSTRAINT "applications_resume_id_resumes_id_fk";
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "grades" DROP CONSTRAINT "grades_student_id_students_id_fk";
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "internships" DROP CONSTRAINT "internships_student_id_students_id_fk";
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "jobs" DROP CONSTRAINT "jobs_company_id_companies_id_fk";
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "resumes" DROP CONSTRAINT "resumes_student_id_students_id_fk";
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "grades" DROP CONSTRAINT "grades_student_id_sem_pk";--> statement-breakpoint
|
||||
ALTER TABLE "grades" ADD CONSTRAINT "grades_studentId_sem_pk" PRIMARY KEY("studentId","sem");--> statement-breakpoint
|
||||
ALTER TABLE "applications" ADD CONSTRAINT "applications_jobId_jobs_id_fk" FOREIGN KEY ("jobId") REFERENCES "public"."jobs"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "applications" ADD CONSTRAINT "applications_studentId_students_id_fk" FOREIGN KEY ("studentId") REFERENCES "public"."students"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "applications" ADD CONSTRAINT "applications_resumeId_resumes_id_fk" FOREIGN KEY ("resumeId") REFERENCES "public"."resumes"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "grades" ADD CONSTRAINT "grades_studentId_students_id_fk" FOREIGN KEY ("studentId") REFERENCES "public"."students"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "internships" ADD CONSTRAINT "internships_studentId_students_id_fk" FOREIGN KEY ("studentId") REFERENCES "public"."students"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "jobs" ADD CONSTRAINT "jobs_companyId_companies_id_fk" FOREIGN KEY ("companyId") REFERENCES "public"."companies"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "resumes" ADD CONSTRAINT "resumes_studentId_students_id_fk" FOREIGN KEY ("studentId") REFERENCES "public"."students"("id") ON DELETE no action ON UPDATE no action;
|
||||
769
packages/db/migrations/meta/0006_snapshot.json
Normal file
769
packages/db/migrations/meta/0006_snapshot.json
Normal file
@@ -0,0 +1,769 @@
|
||||
{
|
||||
"id": "9394fab4-d946-45ac-ac5a-2fc22cf46a07",
|
||||
"prevId": "1506d00a-2620-44ac-af01-19e04c21f679",
|
||||
"version": "7",
|
||||
"dialect": "postgresql",
|
||||
"tables": {
|
||||
"public.admins": {
|
||||
"name": "admins",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "serial",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"email": {
|
||||
"name": "email",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"createdAt": {
|
||||
"name": "createdAt",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
},
|
||||
"updatedAt": {
|
||||
"name": "updatedAt",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {
|
||||
"admins_email_unique": {
|
||||
"name": "admins_email_unique",
|
||||
"nullsNotDistinct": false,
|
||||
"columns": [
|
||||
"email"
|
||||
]
|
||||
}
|
||||
},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.applications": {
|
||||
"name": "applications",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "serial",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"jobId": {
|
||||
"name": "jobId",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"studentId": {
|
||||
"name": "studentId",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"resumeId": {
|
||||
"name": "resumeId",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"status": {
|
||||
"name": "status",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'pending'"
|
||||
},
|
||||
"createdAt": {
|
||||
"name": "createdAt",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
},
|
||||
"updatedAt": {
|
||||
"name": "updatedAt",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"applications_jobId_jobs_id_fk": {
|
||||
"name": "applications_jobId_jobs_id_fk",
|
||||
"tableFrom": "applications",
|
||||
"tableTo": "jobs",
|
||||
"columnsFrom": [
|
||||
"jobId"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
"applications_studentId_students_id_fk": {
|
||||
"name": "applications_studentId_students_id_fk",
|
||||
"tableFrom": "applications",
|
||||
"tableTo": "students",
|
||||
"columnsFrom": [
|
||||
"studentId"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
"applications_resumeId_resumes_id_fk": {
|
||||
"name": "applications_resumeId_resumes_id_fk",
|
||||
"tableFrom": "applications",
|
||||
"tableTo": "resumes",
|
||||
"columnsFrom": [
|
||||
"resumeId"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.companies": {
|
||||
"name": "companies",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "serial",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"name": {
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"email": {
|
||||
"name": "email",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"link": {
|
||||
"name": "link",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"description": {
|
||||
"name": "description",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"imageURL": {
|
||||
"name": "imageURL",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"createdAt": {
|
||||
"name": "createdAt",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
},
|
||||
"updatedAt": {
|
||||
"name": "updatedAt",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.grades": {
|
||||
"name": "grades",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"studentId": {
|
||||
"name": "studentId",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"sem": {
|
||||
"name": "sem",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"sgpi": {
|
||||
"name": "sgpi",
|
||||
"type": "numeric(4, 2)",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"isKT": {
|
||||
"name": "isKT",
|
||||
"type": "boolean",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"deadKT": {
|
||||
"name": "deadKT",
|
||||
"type": "boolean",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"createdAt": {
|
||||
"name": "createdAt",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
},
|
||||
"updatedAt": {
|
||||
"name": "updatedAt",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"grades_studentId_students_id_fk": {
|
||||
"name": "grades_studentId_students_id_fk",
|
||||
"tableFrom": "grades",
|
||||
"tableTo": "students",
|
||||
"columnsFrom": [
|
||||
"studentId"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {
|
||||
"grades_studentId_sem_pk": {
|
||||
"name": "grades_studentId_sem_pk",
|
||||
"columns": [
|
||||
"studentId",
|
||||
"sem"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {
|
||||
"sem_check1": {
|
||||
"name": "sem_check1",
|
||||
"value": "\"grades\".\"sem\" < 9"
|
||||
}
|
||||
},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.internships": {
|
||||
"name": "internships",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "serial",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"studentId": {
|
||||
"name": "studentId",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"title": {
|
||||
"name": "title",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"company": {
|
||||
"name": "company",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"description": {
|
||||
"name": "description",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"location": {
|
||||
"name": "location",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"startDate": {
|
||||
"name": "startDate",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"endDate": {
|
||||
"name": "endDate",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"createdAt": {
|
||||
"name": "createdAt",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
},
|
||||
"updatedAt": {
|
||||
"name": "updatedAt",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"internships_studentId_students_id_fk": {
|
||||
"name": "internships_studentId_students_id_fk",
|
||||
"tableFrom": "internships",
|
||||
"tableTo": "students",
|
||||
"columnsFrom": [
|
||||
"studentId"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.jobs": {
|
||||
"name": "jobs",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "serial",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"companyId": {
|
||||
"name": "companyId",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"title": {
|
||||
"name": "title",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"link": {
|
||||
"name": "link",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"description": {
|
||||
"name": "description",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"location": {
|
||||
"name": "location",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"imageURL": {
|
||||
"name": "imageURL",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"salary": {
|
||||
"name": "salary",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"applicationDeadline": {
|
||||
"name": "applicationDeadline",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"active": {
|
||||
"name": "active",
|
||||
"type": "boolean",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": false
|
||||
},
|
||||
"minCGPA": {
|
||||
"name": "minCGPA",
|
||||
"type": "numeric(4, 2)",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'0'"
|
||||
},
|
||||
"minSSC": {
|
||||
"name": "minSSC",
|
||||
"type": "numeric(4, 2)",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'0'"
|
||||
},
|
||||
"minHSC": {
|
||||
"name": "minHSC",
|
||||
"type": "numeric(4, 2)",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'0'"
|
||||
},
|
||||
"allowDeadKT": {
|
||||
"name": "allowDeadKT",
|
||||
"type": "boolean",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": true
|
||||
},
|
||||
"allowLiveKT": {
|
||||
"name": "allowLiveKT",
|
||||
"type": "boolean",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": true
|
||||
},
|
||||
"createdAt": {
|
||||
"name": "createdAt",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
},
|
||||
"updatedAt": {
|
||||
"name": "updatedAt",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"jobs_companyId_companies_id_fk": {
|
||||
"name": "jobs_companyId_companies_id_fk",
|
||||
"tableFrom": "jobs",
|
||||
"tableTo": "companies",
|
||||
"columnsFrom": [
|
||||
"companyId"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.resumes": {
|
||||
"name": "resumes",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "serial",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"studentId": {
|
||||
"name": "studentId",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"title": {
|
||||
"name": "title",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"link": {
|
||||
"name": "link",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"createdAt": {
|
||||
"name": "createdAt",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
},
|
||||
"updatedAt": {
|
||||
"name": "updatedAt",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"resumes_studentId_students_id_fk": {
|
||||
"name": "resumes_studentId_students_id_fk",
|
||||
"tableFrom": "resumes",
|
||||
"tableTo": "students",
|
||||
"columnsFrom": [
|
||||
"studentId"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.students": {
|
||||
"name": "students",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "serial",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"email": {
|
||||
"name": "email",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"rollNumber": {
|
||||
"name": "rollNumber",
|
||||
"type": "varchar(12)",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"verified": {
|
||||
"name": "verified",
|
||||
"type": "boolean",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": false
|
||||
},
|
||||
"firstName": {
|
||||
"name": "firstName",
|
||||
"type": "varchar(255)",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"middleName": {
|
||||
"name": "middleName",
|
||||
"type": "varchar(255)",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"lastName": {
|
||||
"name": "lastName",
|
||||
"type": "varchar(255)",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"mothersName": {
|
||||
"name": "mothersName",
|
||||
"type": "varchar(255)",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"gender": {
|
||||
"name": "gender",
|
||||
"type": "varchar(10)",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"dob": {
|
||||
"name": "dob",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"personalGmail": {
|
||||
"name": "personalGmail",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"phoneNumber": {
|
||||
"name": "phoneNumber",
|
||||
"type": "varchar(10)",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"address": {
|
||||
"name": "address",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"profilePicture": {
|
||||
"name": "profilePicture",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"degree": {
|
||||
"name": "degree",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"branch": {
|
||||
"name": "branch",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"year": {
|
||||
"name": "year",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"skills": {
|
||||
"name": "skills",
|
||||
"type": "text[]",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "ARRAY[]::text[]"
|
||||
},
|
||||
"linkedin": {
|
||||
"name": "linkedin",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"github": {
|
||||
"name": "github",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"ssc": {
|
||||
"name": "ssc",
|
||||
"type": "numeric(4, 2)",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"hsc": {
|
||||
"name": "hsc",
|
||||
"type": "numeric(4, 2)",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"isDiploma": {
|
||||
"name": "isDiploma",
|
||||
"type": "boolean",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"createdAt": {
|
||||
"name": "createdAt",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
},
|
||||
"updatedAt": {
|
||||
"name": "updatedAt",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
}
|
||||
},
|
||||
"enums": {},
|
||||
"schemas": {},
|
||||
"sequences": {},
|
||||
"roles": {},
|
||||
"policies": {},
|
||||
"views": {},
|
||||
"_meta": {
|
||||
"columns": {},
|
||||
"schemas": {},
|
||||
"tables": {}
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,13 @@
|
||||
"when": 1751182452704,
|
||||
"tag": "0005_solid_photon",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 6,
|
||||
"version": "7",
|
||||
"when": 1751619273079,
|
||||
"tag": "0006_mysterious_lionheart",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
check,
|
||||
} from 'drizzle-orm/pg-core';
|
||||
|
||||
export { createSelectSchema } from 'drizzle-zod';
|
||||
export { createSelectSchema, createInsertSchema } from 'drizzle-zod';
|
||||
|
||||
export const students = pgTable('students', {
|
||||
id: serial().primaryKey(),
|
||||
@@ -49,7 +49,7 @@ export const students = pgTable('students', {
|
||||
|
||||
export const internships = pgTable('internships', {
|
||||
id: serial().primaryKey(),
|
||||
studentId: integer('student_id')
|
||||
studentId: integer()
|
||||
.notNull()
|
||||
.references(() => students.id),
|
||||
title: text().notNull(),
|
||||
@@ -101,7 +101,7 @@ export const internships = pgTable('internships', {
|
||||
|
||||
export const resumes = pgTable('resumes', {
|
||||
id: serial().primaryKey(),
|
||||
studentId: integer('student_id')
|
||||
studentId: integer()
|
||||
.notNull()
|
||||
.references(() => students.id),
|
||||
title: text().notNull(),
|
||||
@@ -116,7 +116,7 @@ export const resumes = pgTable('resumes', {
|
||||
export const grades = pgTable(
|
||||
'grades',
|
||||
{
|
||||
studentId: integer('student_id')
|
||||
studentId: integer()
|
||||
.notNull()
|
||||
.references(() => students.id),
|
||||
sem: integer().notNull(),
|
||||
@@ -196,7 +196,7 @@ export const companies = pgTable('companies', {
|
||||
|
||||
export const jobs = pgTable('jobs', {
|
||||
id: serial().primaryKey(),
|
||||
companyId: integer('company_id')
|
||||
companyId: integer()
|
||||
.notNull()
|
||||
.references(() => companies.id),
|
||||
title: text().notNull(),
|
||||
@@ -221,13 +221,13 @@ export const jobs = pgTable('jobs', {
|
||||
|
||||
export const applications = pgTable('applications', {
|
||||
id: serial().primaryKey(),
|
||||
jobId: integer('job_id')
|
||||
jobId: integer()
|
||||
.notNull()
|
||||
.references(() => jobs.id),
|
||||
studentId: integer('student_id')
|
||||
studentId: integer()
|
||||
.notNull()
|
||||
.references(() => students.id),
|
||||
resumeId: integer('resume_id')
|
||||
resumeId: integer()
|
||||
.notNull()
|
||||
.references(() => resumes.id),
|
||||
status: text().notNull().default('pending'),
|
||||
|
||||
@@ -12,15 +12,18 @@
|
||||
"@radix-ui/react-dialog": "^1.1.1",
|
||||
"@radix-ui/react-label": "^2.1.0",
|
||||
"@radix-ui/react-navigation-menu": "^1.2.0",
|
||||
"@radix-ui/react-popover": "^1.1.14",
|
||||
"@radix-ui/react-progress": "^1.1.7",
|
||||
"@radix-ui/react-select": "^2.2.5",
|
||||
"@radix-ui/react-separator": "^1.1.7",
|
||||
"@radix-ui/react-slot": "^1.2.3",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"date-fns": "^4.1.0",
|
||||
"lucide-react": "^0.475.0",
|
||||
"next-themes": "^0.4.4",
|
||||
"react": "^19.0.0",
|
||||
"react-day-picker": "^9.7.0",
|
||||
"react-dom": "^19.0.0",
|
||||
"react-hook-form": "^7.58.1",
|
||||
"tailwind-merge": "^3.0.1",
|
||||
|
||||
210
packages/ui/src/components/calendar.tsx
Normal file
210
packages/ui/src/components/calendar.tsx
Normal file
@@ -0,0 +1,210 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import {
|
||||
ChevronDownIcon,
|
||||
ChevronLeftIcon,
|
||||
ChevronRightIcon,
|
||||
} from "lucide-react"
|
||||
import { DayButton, DayPicker, getDefaultClassNames } from "react-day-picker"
|
||||
|
||||
import { cn } from "@workspace/ui/lib/utils"
|
||||
import { Button, buttonVariants } from "@workspace/ui/components/button"
|
||||
|
||||
function Calendar({
|
||||
className,
|
||||
classNames,
|
||||
showOutsideDays = true,
|
||||
captionLayout = "label",
|
||||
buttonVariant = "ghost",
|
||||
formatters,
|
||||
components,
|
||||
...props
|
||||
}: React.ComponentProps<typeof DayPicker> & {
|
||||
buttonVariant?: React.ComponentProps<typeof Button>["variant"]
|
||||
}) {
|
||||
const defaultClassNames = getDefaultClassNames()
|
||||
|
||||
return (
|
||||
<DayPicker
|
||||
showOutsideDays={showOutsideDays}
|
||||
className={cn(
|
||||
"bg-background group/calendar p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",
|
||||
String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
|
||||
String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
|
||||
className
|
||||
)}
|
||||
captionLayout={captionLayout}
|
||||
formatters={{
|
||||
formatMonthDropdown: (date) =>
|
||||
date.toLocaleString("default", { month: "short" }),
|
||||
...formatters,
|
||||
}}
|
||||
classNames={{
|
||||
root: cn("w-fit", defaultClassNames.root),
|
||||
months: cn(
|
||||
"flex gap-4 flex-col md:flex-row relative",
|
||||
defaultClassNames.months
|
||||
),
|
||||
month: cn("flex flex-col w-full gap-4", defaultClassNames.month),
|
||||
nav: cn(
|
||||
"flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between",
|
||||
defaultClassNames.nav
|
||||
),
|
||||
button_previous: cn(
|
||||
buttonVariants({ variant: buttonVariant }),
|
||||
"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",
|
||||
defaultClassNames.button_previous
|
||||
),
|
||||
button_next: cn(
|
||||
buttonVariants({ variant: buttonVariant }),
|
||||
"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",
|
||||
defaultClassNames.button_next
|
||||
),
|
||||
month_caption: cn(
|
||||
"flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)",
|
||||
defaultClassNames.month_caption
|
||||
),
|
||||
dropdowns: cn(
|
||||
"w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5",
|
||||
defaultClassNames.dropdowns
|
||||
),
|
||||
dropdown_root: cn(
|
||||
"relative has-focus:border-ring border border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] rounded-md",
|
||||
defaultClassNames.dropdown_root
|
||||
),
|
||||
dropdown: cn("absolute inset-0 opacity-0", defaultClassNames.dropdown),
|
||||
caption_label: cn(
|
||||
"select-none font-medium",
|
||||
captionLayout === "label"
|
||||
? "text-sm"
|
||||
: "rounded-md pl-2 pr-1 flex items-center gap-1 text-sm h-8 [&>svg]:text-muted-foreground [&>svg]:size-3.5",
|
||||
defaultClassNames.caption_label
|
||||
),
|
||||
table: "w-full border-collapse",
|
||||
weekdays: cn("flex", defaultClassNames.weekdays),
|
||||
weekday: cn(
|
||||
"text-muted-foreground rounded-md flex-1 font-normal text-[0.8rem] select-none",
|
||||
defaultClassNames.weekday
|
||||
),
|
||||
week: cn("flex w-full mt-2", defaultClassNames.week),
|
||||
week_number_header: cn(
|
||||
"select-none w-(--cell-size)",
|
||||
defaultClassNames.week_number_header
|
||||
),
|
||||
week_number: cn(
|
||||
"text-[0.8rem] select-none text-muted-foreground",
|
||||
defaultClassNames.week_number
|
||||
),
|
||||
day: cn(
|
||||
"relative w-full h-full p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md group/day aspect-square select-none",
|
||||
defaultClassNames.day
|
||||
),
|
||||
range_start: cn(
|
||||
"rounded-l-md bg-accent",
|
||||
defaultClassNames.range_start
|
||||
),
|
||||
range_middle: cn("rounded-none", defaultClassNames.range_middle),
|
||||
range_end: cn("rounded-r-md bg-accent", defaultClassNames.range_end),
|
||||
today: cn(
|
||||
"bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",
|
||||
defaultClassNames.today
|
||||
),
|
||||
outside: cn(
|
||||
"text-muted-foreground aria-selected:text-muted-foreground",
|
||||
defaultClassNames.outside
|
||||
),
|
||||
disabled: cn(
|
||||
"text-muted-foreground opacity-50",
|
||||
defaultClassNames.disabled
|
||||
),
|
||||
hidden: cn("invisible", defaultClassNames.hidden),
|
||||
...classNames,
|
||||
}}
|
||||
components={{
|
||||
Root: ({ className, rootRef, ...props }) => {
|
||||
return (
|
||||
<div
|
||||
data-slot="calendar"
|
||||
ref={rootRef}
|
||||
className={cn(className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
},
|
||||
Chevron: ({ className, orientation, ...props }) => {
|
||||
if (orientation === "left") {
|
||||
return (
|
||||
<ChevronLeftIcon className={cn("size-4", className)} {...props} />
|
||||
)
|
||||
}
|
||||
|
||||
if (orientation === "right") {
|
||||
return (
|
||||
<ChevronRightIcon
|
||||
className={cn("size-4", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<ChevronDownIcon className={cn("size-4", className)} {...props} />
|
||||
)
|
||||
},
|
||||
DayButton: CalendarDayButton,
|
||||
WeekNumber: ({ children, ...props }) => {
|
||||
return (
|
||||
<td {...props}>
|
||||
<div className="flex size-(--cell-size) items-center justify-center text-center">
|
||||
{children}
|
||||
</div>
|
||||
</td>
|
||||
)
|
||||
},
|
||||
...components,
|
||||
}}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function CalendarDayButton({
|
||||
className,
|
||||
day,
|
||||
modifiers,
|
||||
...props
|
||||
}: React.ComponentProps<typeof DayButton>) {
|
||||
const defaultClassNames = getDefaultClassNames()
|
||||
|
||||
const ref = React.useRef<HTMLButtonElement>(null)
|
||||
React.useEffect(() => {
|
||||
if (modifiers.focused) ref.current?.focus()
|
||||
}, [modifiers.focused])
|
||||
|
||||
return (
|
||||
<Button
|
||||
ref={ref}
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
data-day={day.date.toLocaleDateString()}
|
||||
data-selected-single={
|
||||
modifiers.selected &&
|
||||
!modifiers.range_start &&
|
||||
!modifiers.range_end &&
|
||||
!modifiers.range_middle
|
||||
}
|
||||
data-range-start={modifiers.range_start}
|
||||
data-range-end={modifiers.range_end}
|
||||
data-range-middle={modifiers.range_middle}
|
||||
className={cn(
|
||||
"data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 dark:hover:text-accent-foreground flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md [&>span]:text-xs [&>span]:opacity-70",
|
||||
defaultClassNames.day,
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export { Calendar, CalendarDayButton }
|
||||
48
packages/ui/src/components/popover.tsx
Normal file
48
packages/ui/src/components/popover.tsx
Normal file
@@ -0,0 +1,48 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import * as PopoverPrimitive from "@radix-ui/react-popover"
|
||||
|
||||
import { cn } from "@workspace/ui/lib/utils"
|
||||
|
||||
function Popover({
|
||||
...props
|
||||
}: React.ComponentProps<typeof PopoverPrimitive.Root>) {
|
||||
return <PopoverPrimitive.Root data-slot="popover" {...props} />
|
||||
}
|
||||
|
||||
function PopoverTrigger({
|
||||
...props
|
||||
}: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {
|
||||
return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />
|
||||
}
|
||||
|
||||
function PopoverContent({
|
||||
className,
|
||||
align = "center",
|
||||
sideOffset = 4,
|
||||
...props
|
||||
}: React.ComponentProps<typeof PopoverPrimitive.Content>) {
|
||||
return (
|
||||
<PopoverPrimitive.Portal>
|
||||
<PopoverPrimitive.Content
|
||||
data-slot="popover-content"
|
||||
align={align}
|
||||
sideOffset={sideOffset}
|
||||
className={cn(
|
||||
"bg-popover text-popover-foreground 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 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
</PopoverPrimitive.Portal>
|
||||
)
|
||||
}
|
||||
|
||||
function PopoverAnchor({
|
||||
...props
|
||||
}: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {
|
||||
return <PopoverPrimitive.Anchor data-slot="popover-anchor" {...props} />
|
||||
}
|
||||
|
||||
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor }
|
||||
82
pnpm-lock.yaml
generated
82
pnpm-lock.yaml
generated
@@ -26,6 +26,9 @@ importers:
|
||||
|
||||
apps/admin:
|
||||
dependencies:
|
||||
'@hookform/resolvers':
|
||||
specifier: ^5.1.1
|
||||
version: 5.1.1(react-hook-form@7.59.0(react@19.1.0))
|
||||
'@tailwindcss/postcss':
|
||||
specifier: ^4.0.8
|
||||
version: 4.1.11
|
||||
@@ -38,6 +41,9 @@ importers:
|
||||
'@workspace/ui':
|
||||
specifier: workspace:*
|
||||
version: link:../../packages/ui
|
||||
date-fns:
|
||||
specifier: ^4.1.0
|
||||
version: 4.1.0
|
||||
framer-motion:
|
||||
specifier: ^12.22.0
|
||||
version: 12.22.0(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
||||
@@ -59,6 +65,9 @@ importers:
|
||||
react-dom:
|
||||
specifier: ^19.1.0
|
||||
version: 19.1.0(react@19.1.0)
|
||||
react-hook-form:
|
||||
specifier: ^7.59.0
|
||||
version: 7.59.0(react@19.1.0)
|
||||
tailwindcss:
|
||||
specifier: ^4.0.8
|
||||
version: 4.1.11
|
||||
@@ -238,6 +247,9 @@ importers:
|
||||
'@radix-ui/react-navigation-menu':
|
||||
specifier: ^1.2.0
|
||||
version: 1.2.13(@types/react-dom@19.1.6(@types/react@19.1.8))(@types/react@19.1.8)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
||||
'@radix-ui/react-popover':
|
||||
specifier: ^1.1.14
|
||||
version: 1.1.14(@types/react-dom@19.1.6(@types/react@19.1.8))(@types/react@19.1.8)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
||||
'@radix-ui/react-progress':
|
||||
specifier: ^1.1.7
|
||||
version: 1.1.7(@types/react-dom@19.1.6(@types/react@19.1.8))(@types/react@19.1.8)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
||||
@@ -256,6 +268,9 @@ importers:
|
||||
clsx:
|
||||
specifier: ^2.1.1
|
||||
version: 2.1.1
|
||||
date-fns:
|
||||
specifier: ^4.1.0
|
||||
version: 4.1.0
|
||||
lucide-react:
|
||||
specifier: ^0.475.0
|
||||
version: 0.475.0(react@19.1.0)
|
||||
@@ -265,6 +280,9 @@ importers:
|
||||
react:
|
||||
specifier: ^19.0.0
|
||||
version: 19.1.0
|
||||
react-day-picker:
|
||||
specifier: ^9.7.0
|
||||
version: 9.7.0(react@19.1.0)
|
||||
react-dom:
|
||||
specifier: ^19.0.0
|
||||
version: 19.1.0(react@19.1.0)
|
||||
@@ -341,6 +359,9 @@ packages:
|
||||
resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
'@date-fns/tz@1.2.0':
|
||||
resolution: {integrity: sha512-LBrd7MiJZ9McsOgxqWX7AaxrDjcFVjWH/tIKJd7pnR7McaslGYOP1QmmiBXdJH/H/yLCT+rcQ7FaPBUxRGUtrg==}
|
||||
|
||||
'@drizzle-team/brocli@0.10.2':
|
||||
resolution: {integrity: sha512-z33Il7l5dKjUgGULTqBsQBQwckHh5AbIuxhdsIxDDiZAzBOrZO6q9ogcWC65kU382AfynTfgNumVcNIjuIua6w==}
|
||||
|
||||
@@ -1096,6 +1117,19 @@ packages:
|
||||
'@types/react-dom':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-popover@1.1.14':
|
||||
resolution: {integrity: sha512-ODz16+1iIbGUfFEfKx2HTPKizg2MN39uIOV8MXeHnmdd3i/N9Wt7vU46wbHsqA0xoaQyXVcs0KIlBdOA2Y95bw==}
|
||||
peerDependencies:
|
||||
'@types/react': '*'
|
||||
'@types/react-dom': '*'
|
||||
react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||
react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||
peerDependenciesMeta:
|
||||
'@types/react':
|
||||
optional: true
|
||||
'@types/react-dom':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-popper@1.2.7':
|
||||
resolution: {integrity: sha512-IUFAccz1JyKcf/RjB552PlWwxjeCJB8/4KxT7EhBHOJM+mN7LdW+B3kacJXILm32xawcMMjb2i0cIZpo+f9kiQ==}
|
||||
peerDependencies:
|
||||
@@ -1774,6 +1808,12 @@ packages:
|
||||
resolution: {integrity: sha512-BS8PfmtDGnrgYdOonGZQdLZslWIeCGFP9tpan0hi1Co2Zr2NKADsvGYA8XxuG/4UWgJ6Cjtv+YJnB6MM69QGlQ==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
date-fns-jalali@4.1.0-0:
|
||||
resolution: {integrity: sha512-hTIP/z+t+qKwBDcmmsnmjWTduxCg+5KfdqWQvb2X/8C9+knYY6epN/pfxdDuyVlSVeFz0sM5eEfwIUQ70U4ckg==}
|
||||
|
||||
date-fns@4.1.0:
|
||||
resolution: {integrity: sha512-Ukq0owbQXxa/U3EGtsdVBkR1w7KOQ5gIBqdH2hkvknzZPYvBxb/aa6E8L7tmjFtkwZBu3UXBbjIgPo/Ez4xaNg==}
|
||||
|
||||
debug@4.4.1:
|
||||
resolution: {integrity: sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==}
|
||||
engines: {node: '>=6.0'}
|
||||
@@ -2976,6 +3016,12 @@ packages:
|
||||
resolution: {integrity: sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==}
|
||||
hasBin: true
|
||||
|
||||
react-day-picker@9.7.0:
|
||||
resolution: {integrity: sha512-urlK4C9XJZVpQ81tmVgd2O7lZ0VQldZeHzNejbwLWZSkzHH498KnArT0EHNfKBOWwKc935iMLGZdxXPRISzUxQ==}
|
||||
engines: {node: '>=18'}
|
||||
peerDependencies:
|
||||
react: '>=16.8.0'
|
||||
|
||||
react-dom@19.1.0:
|
||||
resolution: {integrity: sha512-Xs1hdnE+DyKgeHJeJznQmYMIBG3TKIHJJT95Q58nHLSrElKlGQqDTR2HQ9fx5CN/Gk6Vh/kupBTDLU11/nDk/g==}
|
||||
peerDependencies:
|
||||
@@ -3559,6 +3605,8 @@ snapshots:
|
||||
dependencies:
|
||||
'@jridgewell/trace-mapping': 0.3.9
|
||||
|
||||
'@date-fns/tz@1.2.0': {}
|
||||
|
||||
'@drizzle-team/brocli@0.10.2': {}
|
||||
|
||||
'@emnapi/runtime@1.4.3':
|
||||
@@ -4119,6 +4167,29 @@ snapshots:
|
||||
'@types/react': 19.1.8
|
||||
'@types/react-dom': 19.1.6(@types/react@19.1.8)
|
||||
|
||||
'@radix-ui/react-popover@1.1.14(@types/react-dom@19.1.6(@types/react@19.1.8))(@types/react@19.1.8)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)':
|
||||
dependencies:
|
||||
'@radix-ui/primitive': 1.1.2
|
||||
'@radix-ui/react-compose-refs': 1.1.2(@types/react@19.1.8)(react@19.1.0)
|
||||
'@radix-ui/react-context': 1.1.2(@types/react@19.1.8)(react@19.1.0)
|
||||
'@radix-ui/react-dismissable-layer': 1.1.10(@types/react-dom@19.1.6(@types/react@19.1.8))(@types/react@19.1.8)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
||||
'@radix-ui/react-focus-guards': 1.1.2(@types/react@19.1.8)(react@19.1.0)
|
||||
'@radix-ui/react-focus-scope': 1.1.7(@types/react-dom@19.1.6(@types/react@19.1.8))(@types/react@19.1.8)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
||||
'@radix-ui/react-id': 1.1.1(@types/react@19.1.8)(react@19.1.0)
|
||||
'@radix-ui/react-popper': 1.2.7(@types/react-dom@19.1.6(@types/react@19.1.8))(@types/react@19.1.8)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
||||
'@radix-ui/react-portal': 1.1.9(@types/react-dom@19.1.6(@types/react@19.1.8))(@types/react@19.1.8)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
||||
'@radix-ui/react-presence': 1.1.4(@types/react-dom@19.1.6(@types/react@19.1.8))(@types/react@19.1.8)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
||||
'@radix-ui/react-primitive': 2.1.3(@types/react-dom@19.1.6(@types/react@19.1.8))(@types/react@19.1.8)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
||||
'@radix-ui/react-slot': 1.2.3(@types/react@19.1.8)(react@19.1.0)
|
||||
'@radix-ui/react-use-controllable-state': 1.2.2(@types/react@19.1.8)(react@19.1.0)
|
||||
aria-hidden: 1.2.6
|
||||
react: 19.1.0
|
||||
react-dom: 19.1.0(react@19.1.0)
|
||||
react-remove-scroll: 2.7.1(@types/react@19.1.8)(react@19.1.0)
|
||||
optionalDependencies:
|
||||
'@types/react': 19.1.8
|
||||
'@types/react-dom': 19.1.6(@types/react@19.1.8)
|
||||
|
||||
'@radix-ui/react-popper@1.2.7(@types/react-dom@19.1.6(@types/react@19.1.8))(@types/react@19.1.8)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)':
|
||||
dependencies:
|
||||
'@floating-ui/react-dom': 2.1.4(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
||||
@@ -4859,6 +4930,10 @@ snapshots:
|
||||
es-errors: 1.3.0
|
||||
is-data-view: 1.0.2
|
||||
|
||||
date-fns-jalali@4.1.0-0: {}
|
||||
|
||||
date-fns@4.1.0: {}
|
||||
|
||||
debug@4.4.1:
|
||||
dependencies:
|
||||
ms: 2.1.3
|
||||
@@ -6171,6 +6246,13 @@ snapshots:
|
||||
minimist: 1.2.8
|
||||
strip-json-comments: 2.0.1
|
||||
|
||||
react-day-picker@9.7.0(react@19.1.0):
|
||||
dependencies:
|
||||
'@date-fns/tz': 1.2.0
|
||||
date-fns: 4.1.0
|
||||
date-fns-jalali: 4.1.0-0
|
||||
react: 19.1.0
|
||||
|
||||
react-dom@19.1.0(react@19.1.0):
|
||||
dependencies:
|
||||
react: 19.1.0
|
||||
|
||||
Reference in New Issue
Block a user