feat(admin): fixed next async param error
This commit is contained in:
@@ -29,14 +29,17 @@ async function getAllJobsWithCompany() {
|
|||||||
export default async function JobsListPage({
|
export default async function JobsListPage({
|
||||||
searchParams,
|
searchParams,
|
||||||
}: {
|
}: {
|
||||||
searchParams?: { q?: string; status?: string; companyId?: string };
|
searchParams?: Promise<{ q?: string; status?: string; companyId?: string }>;
|
||||||
}) {
|
}) {
|
||||||
const jobsWithCompany = await getAllJobsWithCompany();
|
const jobsWithCompany = await getAllJobsWithCompany();
|
||||||
const companiesList = await db.query.companies.findMany({ columns: { id: true, name: true } });
|
const companiesList = await db.query.companies.findMany({ columns: { id: true, name: true } });
|
||||||
|
|
||||||
const q = (searchParams?.q ?? '').toLowerCase();
|
// Await searchParams before accessing its properties
|
||||||
const status = searchParams?.status ?? 'all';
|
const params = await searchParams;
|
||||||
const companyId = Number(searchParams?.companyId ?? '0');
|
|
||||||
|
const q = (params?.q ?? '').toLowerCase();
|
||||||
|
const status = params?.status ?? 'all';
|
||||||
|
const companyId = Number(params?.companyId ?? '0');
|
||||||
|
|
||||||
const filteredJobs = jobsWithCompany.filter((job) => {
|
const filteredJobs = jobsWithCompany.filter((job) => {
|
||||||
if (status === 'active' && !job.active) return false;
|
if (status === 'active' && !job.active) return false;
|
||||||
@@ -77,7 +80,7 @@ export default async function JobsListPage({
|
|||||||
<Search className="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4" />
|
<Search className="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4" />
|
||||||
<Input
|
<Input
|
||||||
name="q"
|
name="q"
|
||||||
defaultValue={searchParams?.q ?? ''}
|
defaultValue={params?.q ?? ''}
|
||||||
placeholder="Search by title, company, or location"
|
placeholder="Search by title, company, or location"
|
||||||
className="pl-10 h-11 w-[320px] border-gray-300 focus:border-blue-500 focus:ring-blue-500"
|
className="pl-10 h-11 w-[320px] border-gray-300 focus:border-blue-500 focus:ring-blue-500"
|
||||||
/>
|
/>
|
||||||
@@ -96,7 +99,7 @@ export default async function JobsListPage({
|
|||||||
<div>
|
<div>
|
||||||
<select
|
<select
|
||||||
name="companyId"
|
name="companyId"
|
||||||
defaultValue={searchParams?.companyId ?? ''}
|
defaultValue={params?.companyId ?? ''}
|
||||||
className="h-11 w-[220px] rounded-md border border-gray-300 bg-white px-3 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500"
|
className="h-11 w-[220px] rounded-md border border-gray-300 bg-white px-3 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500"
|
||||||
>
|
>
|
||||||
<option value="">All Companies</option>
|
<option value="">All Companies</option>
|
||||||
|
|||||||
Reference in New Issue
Block a user