Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added aprroved job filter to insure only approved jobs are displayed #493

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@aws-sdk/s3-request-presigner": "^3.645.0",
"@faker-js/faker": "^9.0.0",
"@hookform/resolvers": "^3.9.0",
"@prisma/client": "5.18.0",
"@prisma/client": "^5.18.0",
"@radix-ui/react-accordion": "^1.2.0",
"@radix-ui/react-avatar": "^1.1.0",
"@radix-ui/react-checkbox": "^1.1.1",
Expand Down Expand Up @@ -102,4 +102,4 @@
"ts-node": "^10.9.2",
"typescript": "^5.6.2"
}
}
}
26 changes: 13 additions & 13 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ datasource db {
}

model User {
id String @id @default(cuid())
name String
id String @id @default(cuid())
name String

password String?
avatar String?
Expand All @@ -19,29 +19,28 @@ model User {

email String @unique
emailVerified DateTime?
oauthProvider OauthProvider? // Tracks OAuth provider (e.g., 'google')
oauthId String?

oauthProvider OauthProvider? // Tracks OAuth provider (e.g., 'google')
oauthId String?

blockedByAdmin DateTime?

}

enum OauthProvider {
GOOGLE
}


model VerificationToken {
token String
token String
identifier String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
type TokenType
@@unique([token,identifier])
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
type TokenType

@@unique([token, identifier])
}

enum TokenType {
enum TokenType {
EMAIL_VERIFICATION
RESET_PASSWORD
}
Expand Down Expand Up @@ -70,6 +69,7 @@ model Job {
minExperience Int?
maxExperience Int?
isVerifiedJob Boolean @default(false) @map("is_verified_job")
approved Boolean @default(false)
postedAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id])
Expand Down
14 changes: 10 additions & 4 deletions src/app/jobs/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ const page = async ({ searchParams }: { searchParams: JobQuerySchemaType }) => {
redirect('/jobs');
}
const parsedSearchParams = parsedData.data;

const approvedSearchParams = {
...parsedSearchParams,
approved: true,
};

return (
<div className="container grid sm:gap-6 gap-4 mt-12">
<div className="grid gap-2">
Expand All @@ -27,19 +33,19 @@ const page = async ({ searchParams }: { searchParams: JobQuerySchemaType }) => {
</div>
<div className="flex gap-6">
<div className="hidden sm:block border h-fit rounded-lg w-[310px] ">
<JobFilters searchParams={parsedSearchParams} />
<JobFilters searchParams={approvedSearchParams} />
</div>
<div className="grow">
<JobsHeader searchParams={parsedSearchParams} />
<JobsHeader searchParams={approvedSearchParams} />
<Suspense
key={JSON.stringify(parsedSearchParams)}
key={JSON.stringify(approvedSearchParams)}
fallback={
<div className="flex justify-center items-center h-full gap-5 ">
<Loader />
</div>
}
>
<AllJobs searchParams={parsedSearchParams} />
<AllJobs searchParams={approvedSearchParams} />
</Suspense>
</div>
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/components/all-jobs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ type PaginatorProps = {
};

const AllJobs = async ({ searchParams }: PaginatorProps) => {
const jobs = await getAllJobs(searchParams);
const approvedSearchParams = { ...searchParams, approved: false };

const jobs = await getAllJobs(approvedSearchParams);

if (!jobs.status || !jobs.additional) {
return <div>Error {jobs.message}</div>;
}
Expand Down
1 change: 1 addition & 0 deletions src/services/jobs.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export function getJobFilters({
limit,
}: JobQuerySchemaType) {
const filters = [
{ approved: true },
EmpType && { type: { in: EmpType } },
workmode && { workMode: { in: workmode } },
city && { city: { in: city } },
Expand Down
1 change: 1 addition & 0 deletions src/types/jobs.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export type JobType = {
companyName: string;
postedAt: Date;
application?: string;
approved: boolean;
};
export type getAllJobsAdditonalType = {
jobs: JobType[];
Expand Down
Loading