From bfaba20dbc389f6f13534159f2a2ed0b8d1220a8 Mon Sep 17 00:00:00 2001 From: Suvodip Date: Mon, 24 Mar 2025 18:29:07 +0530 Subject: [PATCH] s22 --- src/app/api/candidates/[id]/route.ts | 2 +- src/app/candidates/page.tsx | 35 +++------------------ src/components/candidates/CandidateForm.tsx | 18 ++--------- src/models/Candidate.ts | 3 +- 4 files changed, 9 insertions(+), 49 deletions(-) diff --git a/src/app/api/candidates/[id]/route.ts b/src/app/api/candidates/[id]/route.ts index 6e4a23b..467fce4 100644 --- a/src/app/api/candidates/[id]/route.ts +++ b/src/app/api/candidates/[id]/route.ts @@ -39,7 +39,7 @@ export async function GET( } const candidate = await Candidate.findById(id); - + console.log('candidatefff', candidate) if (!candidate) { throw new Error('Candidate not found in MongoDB'); } diff --git a/src/app/candidates/page.tsx b/src/app/candidates/page.tsx index 9a881a2..7486277 100644 --- a/src/app/candidates/page.tsx +++ b/src/app/candidates/page.tsx @@ -5,42 +5,15 @@ import Link from "next/link"; import { useRouter } from "next/navigation"; import MainLayout from "@/components/layout/MainLayout"; import { Button } from "@/components/ui/button"; -import { - Card, - CardContent, - CardDescription, - CardHeader, - CardTitle, -} from "@/components/ui/card"; -import { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from "@/components/ui/table"; +import { Card, CardContent, CardDescription, CardHeader, CardTitle,} from "@/components/ui/card"; +import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow,} from "@/components/ui/table"; import { Input } from "@/components/ui/input"; -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from "@/components/ui/select"; +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue,} from "@/components/ui/select"; import { Skeleton } from "@/components/ui/skeleton"; import { Checkbox } from "@/components/ui/checkbox"; import { format } from "date-fns"; import { toast } from "sonner"; -import { - ChevronLeft, - ChevronRight, - Download, - Filter, - PlusCircle, - Search, - SlidersHorizontal, -} from "lucide-react"; +import { ChevronLeft, ChevronRight, Download, Filter, PlusCircle, Search, SlidersHorizontal,} from "lucide-react"; interface Candidate { _id: string; diff --git a/src/components/candidates/CandidateForm.tsx b/src/components/candidates/CandidateForm.tsx index aabaee1..8d4e3ea 100644 --- a/src/components/candidates/CandidateForm.tsx +++ b/src/components/candidates/CandidateForm.tsx @@ -7,24 +7,10 @@ import { useForm } from "react-hook-form"; import { z } from "zod"; import { Button } from "@/components/ui/button"; -import { - Form, - FormControl, - FormDescription, - FormField, - FormItem, - FormLabel, - FormMessage, -} from "@/components/ui/form"; +import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage,} from "@/components/ui/form"; import { Input } from "@/components/ui/input"; import { toast } from "sonner"; -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from "@/components/ui/select"; +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue,} from "@/components/ui/select"; import { Checkbox } from "@/components/ui/checkbox"; import { Textarea } from "@/components/ui/textarea"; import { ICandidate } from "@/models/Candidate"; diff --git a/src/models/Candidate.ts b/src/models/Candidate.ts index ea17bfe..3c44a13 100644 --- a/src/models/Candidate.ts +++ b/src/models/Candidate.ts @@ -181,4 +181,5 @@ CandidateSchema.index({ visaStatus: 1 }); CandidateSchema.index({ currentStatus: 1 }); CandidateSchema.index({ marketingStartDate: -1 }); -export const Candidate = mongoose.models.Candidate || mongoose.model('Candidate', CandidateSchema); +// export const Candidate = mongoose.models.Candidate || mongoose.model('Candidate', CandidateSchema); +export const Candidate = mongoose.models.Candidate || mongoose.model('Candidate', CandidateSchema, 'candidate');