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

feature & fix : added admin job management and fixed add job form #224

Prev Previous commit
Next Next commit
fixed conflicts
zakiabdullahi committed Sep 5, 2024
commit 7816908cd806e592a60fa65267a75fdbf03ab467
13 changes: 0 additions & 13 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -51,16 +51,3 @@ enum Role {
USER
ADMIN
}

enum JobLocations {
BANGLORE
DELHI
MUMBAI
PUNE
CHENNAI
HYDERABAD
KOLKATA
AHMEDABAD
JAIPUR
SURAT
}
43 changes: 31 additions & 12 deletions prisma/seed.ts
Original file line number Diff line number Diff line change
@@ -2,16 +2,13 @@
import { Currency, Role, WorkMode } from '@prisma/client';
import bcrypt from 'bcryptjs';
import prisma from '../src/config/prisma.config';
import { JobLocations } from '@prisma/client';

const users = [
{ id: '1', name: 'Jack', email: '[email protected]' },
{ id: '2', name: 'Admin', email: '[email protected]', role: Role.ADMIN },
];

const locationArr = Object.keys(JobLocations);

let jobs = [
const jobs = [
{
id: '1',
userId: '1',
@@ -20,6 +17,7 @@ let jobs = [
companyName: 'Tech Corp',
workMode: WorkMode.remote,
currency: Currency.USD,
location: 'New York',
hasSalaryRange: true,
minSalary: 60000,
maxSalary: 80000,
@@ -33,6 +31,7 @@ let jobs = [
companyName: 'Innovatech',
workMode: WorkMode.office,
currency: Currency.INR,
location: 'Bangalore',
hasSalaryRange: false,
minSalary: null,
maxSalary: null,
@@ -46,6 +45,7 @@ let jobs = [
companyName: 'Global Solutions',
workMode: WorkMode.hybrid,
currency: Currency.USD,
location: 'San Francisco',
hasSalaryRange: true,
minSalary: 90000,
maxSalary: 120000,
@@ -60,6 +60,7 @@ let jobs = [
companyName: 'DevOps Ltd.',
workMode: WorkMode.remote,
currency: Currency.INR,
location: 'Mumbai',
hasSalaryRange: true,
minSalary: 50000,
maxSalary: 70000,
@@ -74,6 +75,7 @@ let jobs = [
companyName: 'Productive Minds',
workMode: WorkMode.hybrid,
currency: Currency.USD,
location: 'Chicago',
hasSalaryRange: true,
minSalary: 110000,
maxSalary: 150000,
@@ -88,6 +90,7 @@ let jobs = [
companyName: 'Data Insights',
workMode: WorkMode.office,
currency: Currency.INR,
location: 'Hyderabad',
hasSalaryRange: true,
minSalary: 80000,
maxSalary: 100000,
@@ -102,6 +105,7 @@ let jobs = [
companyName: 'Creative Designs',
workMode: WorkMode.remote,
currency: Currency.USD,
location: 'Seattle',
hasSalaryRange: true,
minSalary: 70000,
maxSalary: 90000,
@@ -115,6 +119,7 @@ let jobs = [
companyName: 'App Innovators',
workMode: WorkMode.hybrid,
currency: Currency.INR,
location: 'Delhi',
hasSalaryRange: false,
minSalary: null,
maxSalary: null,
@@ -128,6 +133,7 @@ let jobs = [
companyName: 'Cloud Works',
workMode: WorkMode.office,
currency: Currency.USD,
location: 'Austin',
hasSalaryRange: true,
minSalary: 100000,
maxSalary: 130000,
@@ -141,6 +147,7 @@ let jobs = [
companyName: 'SecureTech',
workMode: WorkMode.remote,
currency: Currency.INR,
location: 'Pune',
hasSalaryRange: true,
minSalary: 75000,
maxSalary: 95000,
@@ -154,6 +161,7 @@ let jobs = [
companyName: 'QA Solutions',
workMode: WorkMode.remote,
currency: Currency.USD,
location: 'Boston',
hasSalaryRange: true,
minSalary: 45000,
maxSalary: 50000,
@@ -167,6 +175,7 @@ let jobs = [
companyName: 'Tech Docs',
workMode: WorkMode.hybrid,
currency: Currency.USD,
location: 'San Diego',
hasSalaryRange: true,
minSalary: 30000,
maxSalary: 35000,
@@ -180,6 +189,7 @@ let jobs = [
companyName: 'Support Corp',
workMode: WorkMode.office,
currency: Currency.USD,
location: 'Dallas',
hasSalaryRange: true,
minSalary: 20000,
maxSalary: 25000,
@@ -193,6 +203,7 @@ let jobs = [
companyName: 'Net Admins',
workMode: WorkMode.remote,
currency: Currency.USD,
location: 'Houston',
hasSalaryRange: true,
minSalary: 35000,
maxSalary: 40000,
@@ -206,6 +217,7 @@ let jobs = [
companyName: 'Sys Solutions',
workMode: WorkMode.hybrid,
currency: Currency.USD,
location: 'Miami',
hasSalaryRange: true,
minSalary: 27000,
maxSalary: 32000,
@@ -219,6 +231,7 @@ let jobs = [
companyName: 'Sales Tech',
workMode: WorkMode.office,
currency: Currency.USD,
location: 'Chicago',
hasSalaryRange: true,
minSalary: 30000,
maxSalary: 35000,
@@ -232,6 +245,7 @@ let jobs = [
companyName: 'Market Pro',
workMode: WorkMode.remote,
currency: Currency.USD,
location: 'Los Angeles',
hasSalaryRange: true,
minSalary: 20000,
maxSalary: 25000,
@@ -245,6 +259,7 @@ let jobs = [
companyName: 'Content Creators',
workMode: WorkMode.hybrid,
currency: Currency.USD,
location: 'New York',
hasSalaryRange: true,
minSalary: 25000,
maxSalary: 30000,
@@ -258,6 +273,7 @@ let jobs = [
companyName: 'Design Pros',
workMode: WorkMode.office,
currency: Currency.USD,
location: 'San Francisco',
hasSalaryRange: true,
minSalary: 22000,
maxSalary: 27000,
@@ -271,6 +287,7 @@ let jobs = [
companyName: 'Business Solutions',
workMode: WorkMode.remote,
currency: Currency.USD,
location: 'Seattle',
hasSalaryRange: true,
minSalary: 38000,
maxSalary: 43000,
@@ -284,6 +301,7 @@ let jobs = [
companyName: 'SEO Experts',
workMode: WorkMode.hybrid,
currency: Currency.USD,
location: 'Denver',
hasSalaryRange: true,
minSalary: 15000,
maxSalary: 20000,
@@ -297,6 +315,7 @@ let jobs = [
companyName: 'DataPro',
workMode: WorkMode.office,
currency: Currency.USD,
location: 'Atlanta',
hasSalaryRange: true,
minSalary: 23000,
maxSalary: 28000,
@@ -310,6 +329,7 @@ let jobs = [
companyName: 'OpsCorp',
workMode: WorkMode.remote,
currency: Currency.USD,
location: 'Phoenix',
hasSalaryRange: true,
minSalary: 29000,
maxSalary: 34000,
@@ -323,6 +343,7 @@ let jobs = [
companyName: 'Customer Care Inc.',
workMode: WorkMode.hybrid,
currency: Currency.USD,
location: 'Orlando',
hasSalaryRange: true,
minSalary: 26000,
maxSalary: 31000,
@@ -336,6 +357,7 @@ let jobs = [
companyName: 'Product Innovators',
workMode: WorkMode.office,
currency: Currency.USD,
location: 'Portland',
hasSalaryRange: true,
minSalary: 32000,
maxSalary: 37000,
@@ -349,6 +371,7 @@ let jobs = [
companyName: 'Social Media Pros',
workMode: WorkMode.remote,
currency: Currency.USD,
location: 'Las Vegas',
hasSalaryRange: true,
minSalary: 18000,
maxSalary: 23000,
@@ -362,6 +385,7 @@ let jobs = [
companyName: 'HR Hub',
workMode: WorkMode.hybrid,
currency: Currency.USD,
location: 'Charlotte',
hasSalaryRange: true,
minSalary: 24000,
maxSalary: 29000,
@@ -375,6 +399,7 @@ let jobs = [
companyName: 'Supply Chain Solutions',
workMode: WorkMode.office,
currency: Currency.USD,
location: 'Detroit',
hasSalaryRange: true,
minSalary: 30000,
maxSalary: 35000,
@@ -388,6 +413,7 @@ let jobs = [
companyName: 'E-commerce Pros',
workMode: WorkMode.remote,
currency: Currency.USD,
location: 'Philadelphia',
hasSalaryRange: true,
minSalary: 27000,
maxSalary: 32000,
@@ -401,6 +427,7 @@ let jobs = [
companyName: 'Project Managers Inc.',
workMode: WorkMode.hybrid,
currency: Currency.USD,
location: 'Nashville',
hasSalaryRange: true,
minSalary: 12000,
maxSalary: 17000,
@@ -437,13 +464,6 @@ async function seedUsers() {
}

async function seedJobs() {
jobs = jobs.map((j, index) => {
return {
...j,
location:
locationArr[index] !== undefined ? locationArr[index] : locationArr[3],
};
});
try {
await Promise.all(
jobs.map(async (j) =>
@@ -457,7 +477,6 @@ async function seedJobs() {
companyName: j.companyName,
workMode: j.workMode,
currency: j.currency,
//@ts-ignore
location: j.location,
hasSalaryRange: j.hasSalaryRange,
minSalary: j.minSalary,
1 change: 1 addition & 0 deletions src/actions/job.action.ts
Original file line number Diff line number Diff line change
@@ -45,6 +45,7 @@ export const createJob = withServerActionAsyncCatcher<
location,
workMode,
currency,
isVerifiedJob: false, // Default to false since there's no session to check for admin role
},
});
const message = 'Job created successfully, waiting for admin approval';
51 changes: 51 additions & 0 deletions src/lib/constant/jobs.constant.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,47 @@
export const workMode = {
remote: 'remote',
office: 'office',
hybrid: 'hybrid',
};
export enum WorkModeEnums {
REMOTE = 'remote',
OFFICE = 'office',
HYBRID = 'hybrid',
}
export enum SortByEnums {
POSTEDAT_ASC = 'postedat_asc',
POSTEDAT_DESC = 'postedat_desc',
}
export const filters = {
workMode: [
{
id: 1,
label: 'Remote',
value: workMode.remote,
},
{
id: 2,
label: 'Office',
value: workMode.office,
},
{
id: 3,
label: 'Hybrid',
value: workMode.hybrid,
},
],
chooseCurrency: [
{
id: 1,
label: 'INR',
value: 'INR',
},
{
id: 2,
label: 'USD',
value: 'USD',
},
],
salaryRange: [
{
id: 1,
@@ -30,6 +69,18 @@ export const filters = {
value: '50000-above',
},
],
location: [
{ id: 1, label: 'Bangalore', value: 'bangalore' },
{ id: 2, label: 'New Delhi', value: 'new delhi' },
{ id: 3, label: 'Mumbai', value: 'mumbai' },
{ id: 4, label: 'Pune', value: 'pune' },
{ id: 5, label: 'Hyderabad', value: 'hyderabad' },
{ id: 6, label: 'Chennai', value: 'chennai' },
{ id: 7, label: 'Kolkata', value: 'kolkata' },
{ id: 8, label: 'Ahmedabad', value: 'ahmedabad' },
{ id: 9, label: 'Jaipur', value: 'jaipur' },
{ id: 10, label: 'Surat', value: 'surat' },
],
};

export const jobSorting = [
4 changes: 2 additions & 2 deletions src/lib/validators/jobs.validator.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { z } from 'zod';
import { JobLocations, WorkMode } from '@prisma/client';
import { WorkMode } from '@prisma/client';

export const JobPostSchema = z
.object({
title: z.string().min(1, 'Title is required'),
description: z.string().min(1, 'Description is required'),
companyName: z.string().min(1, 'Company Name is required'),
location: z.string().min(1, 'Location is required'),
hasSalaryRange: z.boolean().default(false),
hasSalaryRange: z.boolean(),
minSalary: z.coerce
.number({ message: 'Min salary must be a number' })
.nonnegative()
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.