-
Notifications
You must be signed in to change notification settings - Fork 456
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEAT/Added Job Management Page (#300)
* inited job management feature * delete feat with TypeSafe * addded pagination * deactivated delete functionality * Resolved conflicts and Updated code * new feat job approve * made isVerfied field optional jobType * fixed some ui bugs * fixed conflicts_and_bugs * made Datatable SSR --------- Co-authored-by: Dev <[email protected]>
- Loading branch information
1 parent
facca11
commit b195ae9
Showing
18 changed files
with
597 additions
and
16 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
prisma/migrations/20241007041046_added_deleted_field_job/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterTable | ||
ALTER TABLE "Job" ADD COLUMN "deleted" BOOLEAN NOT NULL DEFAULT false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import JobManagement from '@/components/JobManagement'; | ||
import { options } from '@/lib/auth'; | ||
import { | ||
JobQuerySchema, | ||
JobQuerySchemaType, | ||
} from '@/lib/validators/jobs.validator'; | ||
import { getServerSession } from 'next-auth'; | ||
import { redirect } from 'next/navigation'; | ||
import React from 'react'; | ||
|
||
const ManageJob = async ({ | ||
searchParams, | ||
}: { | ||
searchParams: JobQuerySchemaType; | ||
}) => { | ||
const parsedData = JobQuerySchema.safeParse(searchParams); | ||
const server = await getServerSession(options); | ||
if (!server?.user) { | ||
redirect('/api/auth/signin'); | ||
} else if (server.user.role !== 'ADMIN') { | ||
redirect('/jobs'); | ||
} | ||
if (!(parsedData.success && parsedData.data)) { | ||
console.error(parsedData.error); | ||
redirect('/jobs'); | ||
} | ||
const searchParamss = parsedData.data; | ||
return ( | ||
<div className="container"> | ||
<JobManagement searchParams={searchParamss} /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ManageJob; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
'use client'; | ||
import React from 'react'; | ||
import { | ||
Dialog, | ||
DialogClose, | ||
DialogContent, | ||
DialogDescription, | ||
DialogFooter, | ||
DialogHeader, | ||
DialogTitle, | ||
DialogTrigger, | ||
} from './ui/dialog'; | ||
import { Button } from './ui/button'; | ||
|
||
const ApproveJobDialog = ({ | ||
title, | ||
description, | ||
handleClick, | ||
}: { | ||
title: string; | ||
description: string; | ||
handleClick: () => void; | ||
}) => { | ||
return ( | ||
<> | ||
<Dialog> | ||
<DialogTrigger> | ||
<span | ||
role="button" | ||
className="p-1 py-1 px-3 bg-primary text-primary-foreground rounded-md cursor-pointer tracking-wide" | ||
> | ||
Approve Now | ||
</span> | ||
</DialogTrigger> | ||
<DialogContent> | ||
<DialogHeader> | ||
<DialogTitle>{title}</DialogTitle> | ||
<DialogDescription>{description}</DialogDescription> | ||
</DialogHeader> | ||
<DialogFooter> | ||
<DialogClose> | ||
<Button | ||
className="mt-2" | ||
variant={'secondary'} | ||
onClick={handleClick} | ||
> | ||
Approve | ||
</Button> | ||
</DialogClose> | ||
</DialogFooter> | ||
</DialogContent> | ||
</Dialog> | ||
</> | ||
); | ||
}; | ||
|
||
export default ApproveJobDialog; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from 'react'; | ||
import { getAllJobs } from '@/actions/job.action'; | ||
import JobManagementHeader from './JobManagementHeader'; | ||
import JobManagementTable from './JobManagementTable'; | ||
import { JobQuerySchemaType } from '@/lib/validators/jobs.validator'; | ||
|
||
const JobManagement = async ({ | ||
searchParams, | ||
}: { | ||
searchParams: JobQuerySchemaType; | ||
}) => { | ||
const jobs = await getAllJobs(searchParams); | ||
if (!jobs.status) { | ||
return <div>Error {jobs.message}</div>; | ||
} | ||
return ( | ||
<div className="pt-2 px-6 mt-10"> | ||
<JobManagementHeader /> | ||
<JobManagementTable jobs={jobs} searchParams={searchParams} /> | ||
</div> | ||
); | ||
}; | ||
export default JobManagement; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from 'react'; | ||
import Link from 'next/link'; | ||
import { Button } from './ui/button'; | ||
|
||
const JobManagementHeader = () => { | ||
return ( | ||
<> | ||
<header className="pt-4 px-6 flex justify-between items-center"> | ||
<div> | ||
<p className="text-2xl font-semibold">Active Job Posting</p> | ||
<span className="text-slate-500"> | ||
View and Manage all active job posting. | ||
</span> | ||
</div> | ||
<div> | ||
<Button> | ||
<Link href={'/create'}>Post new Job</Link> | ||
</Button> | ||
</div> | ||
</header> | ||
</> | ||
); | ||
}; | ||
|
||
export default JobManagementHeader; |
Oops, something went wrong.