diff --git a/src/actions/job.action.ts b/src/actions/job.action.ts index f0a9c066..7705ad41 100644 --- a/src/actions/job.action.ts +++ b/src/actions/job.action.ts @@ -15,16 +15,15 @@ import { } from '@/lib/validators/jobs.validator'; import { getJobFilters } from '@/services/jobs.services'; import { ServerActionReturnType } from '@/types/api.types'; - + import { getServerSession } from 'next-auth'; import { authOptions } from '@/lib/authOptions'; - + import { getAllJobsAdditonalType, getAllRecommendedJobs, getJobType, } from '@/types/jobs.types'; - type additional = { isVerifiedJob: boolean; @@ -73,7 +72,7 @@ export const createJob = withServerActionAsyncCatcher< address, companyLogo, workMode, - isVerifiedJob: false, // Default to false since there's no session to check for admin role + isVerifiedJob: false, }, }); const message = 'Job created successfully, waiting for admin approval'; diff --git a/src/components/job-form.tsx b/src/components/job-form.tsx index 9787c3e2..749cccce 100644 --- a/src/components/job-form.tsx +++ b/src/components/job-form.tsx @@ -132,6 +132,7 @@ const PostJobForm = () => { (await submitImage(file)) ?? 'https://wwww.example.com'; ``; const response = await createJob(data); + if (!response.status) { return toast({ title: response.message || 'Error', diff --git a/src/lib/validators/jobs.validator.ts b/src/lib/validators/jobs.validator.ts index 36c3af6e..47fe08bd 100644 --- a/src/lib/validators/jobs.validator.ts +++ b/src/lib/validators/jobs.validator.ts @@ -12,7 +12,7 @@ export const JobPostSchema = z type: z.nativeEnum(EmployementType, { message: 'Employment Type is Required', }), - skills: z.array(z.string()), + skills: z.array(z.string()).optional(), category: z.string(), companyEmail: z.string().email('Invalid email').min(1, 'Email is required'), companyBio: z.string().min(1, 'Company Bio is required'), diff --git a/src/middleware.tsx b/src/middleware.tsx index 43b014c0..a1e051ca 100644 --- a/src/middleware.tsx +++ b/src/middleware.tsx @@ -9,7 +9,7 @@ export async function middleware(req: NextRequest) { return NextResponse.redirect(new URL('/signin', req.url)); } if (pathname === '/create' && token?.role !== 'ADMIN') { - return NextResponse.redirect(new URL('/', req.url)); // Redirect to an unauthorized page + return NextResponse.redirect(new URL('/', req.url)); } return NextResponse.next(); }