Skip to content

Commit

Permalink
fix_build
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepanshuMishraa committed Sep 4, 2024
1 parent a5da4aa commit 0936123
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 33 deletions.
43 changes: 31 additions & 12 deletions prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -20,6 +17,7 @@ let jobs = [
companyName: 'Tech Corp',
workMode: WorkMode.remote,
currency: Currency.USD,
location: 'New York',
hasSalaryRange: true,
minSalary: 60000,
maxSalary: 80000,
Expand All @@ -33,6 +31,7 @@ let jobs = [
companyName: 'Innovatech',
workMode: WorkMode.office,
currency: Currency.INR,
location: 'Bangalore',
hasSalaryRange: false,
minSalary: null,
maxSalary: null,
Expand All @@ -46,6 +45,7 @@ let jobs = [
companyName: 'Global Solutions',
workMode: WorkMode.hybrid,
currency: Currency.USD,
location: 'San Francisco',
hasSalaryRange: true,
minSalary: 90000,
maxSalary: 120000,
Expand All @@ -60,6 +60,7 @@ let jobs = [
companyName: 'DevOps Ltd.',
workMode: WorkMode.remote,
currency: Currency.INR,
location: 'Mumbai',
hasSalaryRange: true,
minSalary: 50000,
maxSalary: 70000,
Expand All @@ -74,6 +75,7 @@ let jobs = [
companyName: 'Productive Minds',
workMode: WorkMode.hybrid,
currency: Currency.USD,
location: 'Chicago',
hasSalaryRange: true,
minSalary: 110000,
maxSalary: 150000,
Expand All @@ -88,6 +90,7 @@ let jobs = [
companyName: 'Data Insights',
workMode: WorkMode.office,
currency: Currency.INR,
location: 'Hyderabad',
hasSalaryRange: true,
minSalary: 80000,
maxSalary: 100000,
Expand All @@ -102,6 +105,7 @@ let jobs = [
companyName: 'Creative Designs',
workMode: WorkMode.remote,
currency: Currency.USD,
location: 'Seattle',
hasSalaryRange: true,
minSalary: 70000,
maxSalary: 90000,
Expand All @@ -115,6 +119,7 @@ let jobs = [
companyName: 'App Innovators',
workMode: WorkMode.hybrid,
currency: Currency.INR,
location: 'Delhi',
hasSalaryRange: false,
minSalary: null,
maxSalary: null,
Expand All @@ -128,6 +133,7 @@ let jobs = [
companyName: 'Cloud Works',
workMode: WorkMode.office,
currency: Currency.USD,
location: 'Austin',
hasSalaryRange: true,
minSalary: 100000,
maxSalary: 130000,
Expand All @@ -141,6 +147,7 @@ let jobs = [
companyName: 'SecureTech',
workMode: WorkMode.remote,
currency: Currency.INR,
location: 'Pune',
hasSalaryRange: true,
minSalary: 75000,
maxSalary: 95000,
Expand All @@ -154,6 +161,7 @@ let jobs = [
companyName: 'QA Solutions',
workMode: WorkMode.remote,
currency: Currency.USD,
location: 'Boston',
hasSalaryRange: true,
minSalary: 45000,
maxSalary: 50000,
Expand All @@ -167,6 +175,7 @@ let jobs = [
companyName: 'Tech Docs',
workMode: WorkMode.hybrid,
currency: Currency.USD,
location: 'San Diego',
hasSalaryRange: true,
minSalary: 30000,
maxSalary: 35000,
Expand All @@ -180,6 +189,7 @@ let jobs = [
companyName: 'Support Corp',
workMode: WorkMode.office,
currency: Currency.USD,
location: 'Dallas',
hasSalaryRange: true,
minSalary: 20000,
maxSalary: 25000,
Expand All @@ -193,6 +203,7 @@ let jobs = [
companyName: 'Net Admins',
workMode: WorkMode.remote,
currency: Currency.USD,
location: 'Houston',
hasSalaryRange: true,
minSalary: 35000,
maxSalary: 40000,
Expand All @@ -206,6 +217,7 @@ let jobs = [
companyName: 'Sys Solutions',
workMode: WorkMode.hybrid,
currency: Currency.USD,
location: 'Miami',
hasSalaryRange: true,
minSalary: 27000,
maxSalary: 32000,
Expand All @@ -219,6 +231,7 @@ let jobs = [
companyName: 'Sales Tech',
workMode: WorkMode.office,
currency: Currency.USD,
location: 'Chicago',
hasSalaryRange: true,
minSalary: 30000,
maxSalary: 35000,
Expand All @@ -232,6 +245,7 @@ let jobs = [
companyName: 'Market Pro',
workMode: WorkMode.remote,
currency: Currency.USD,
location: 'Los Angeles',
hasSalaryRange: true,
minSalary: 20000,
maxSalary: 25000,
Expand All @@ -245,6 +259,7 @@ let jobs = [
companyName: 'Content Creators',
workMode: WorkMode.hybrid,
currency: Currency.USD,
location: 'New York',
hasSalaryRange: true,
minSalary: 25000,
maxSalary: 30000,
Expand All @@ -258,6 +273,7 @@ let jobs = [
companyName: 'Design Pros',
workMode: WorkMode.office,
currency: Currency.USD,
location: 'San Francisco',
hasSalaryRange: true,
minSalary: 22000,
maxSalary: 27000,
Expand All @@ -271,6 +287,7 @@ let jobs = [
companyName: 'Business Solutions',
workMode: WorkMode.remote,
currency: Currency.USD,
location: 'Seattle',
hasSalaryRange: true,
minSalary: 38000,
maxSalary: 43000,
Expand All @@ -284,6 +301,7 @@ let jobs = [
companyName: 'SEO Experts',
workMode: WorkMode.hybrid,
currency: Currency.USD,
location: 'Denver',
hasSalaryRange: true,
minSalary: 15000,
maxSalary: 20000,
Expand All @@ -297,6 +315,7 @@ let jobs = [
companyName: 'DataPro',
workMode: WorkMode.office,
currency: Currency.USD,
location: 'Atlanta',
hasSalaryRange: true,
minSalary: 23000,
maxSalary: 28000,
Expand All @@ -310,6 +329,7 @@ let jobs = [
companyName: 'OpsCorp',
workMode: WorkMode.remote,
currency: Currency.USD,
location: 'Phoenix',
hasSalaryRange: true,
minSalary: 29000,
maxSalary: 34000,
Expand All @@ -323,6 +343,7 @@ let jobs = [
companyName: 'Customer Care Inc.',
workMode: WorkMode.hybrid,
currency: Currency.USD,
location: 'Orlando',
hasSalaryRange: true,
minSalary: 26000,
maxSalary: 31000,
Expand All @@ -336,6 +357,7 @@ let jobs = [
companyName: 'Product Innovators',
workMode: WorkMode.office,
currency: Currency.USD,
location: 'Portland',
hasSalaryRange: true,
minSalary: 32000,
maxSalary: 37000,
Expand All @@ -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,
Expand All @@ -362,6 +385,7 @@ let jobs = [
companyName: 'HR Hub',
workMode: WorkMode.hybrid,
currency: Currency.USD,
location: 'Charlotte',
hasSalaryRange: true,
minSalary: 24000,
maxSalary: 29000,
Expand All @@ -375,6 +399,7 @@ let jobs = [
companyName: 'Supply Chain Solutions',
workMode: WorkMode.office,
currency: Currency.USD,
location: 'Detroit',
hasSalaryRange: true,
minSalary: 30000,
maxSalary: 35000,
Expand All @@ -388,6 +413,7 @@ let jobs = [
companyName: 'E-commerce Pros',
workMode: WorkMode.remote,
currency: Currency.USD,
location: 'Philadelphia',
hasSalaryRange: true,
minSalary: 27000,
maxSalary: 32000,
Expand All @@ -401,6 +427,7 @@ let jobs = [
companyName: 'Project Managers Inc.',
workMode: WorkMode.hybrid,
currency: Currency.USD,
location: 'Nashville',
hasSalaryRange: true,
minSalary: 12000,
maxSalary: 17000,
Expand Down Expand Up @@ -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) =>
Expand All @@ -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,
Expand Down
41 changes: 22 additions & 19 deletions src/layouts/job-filters.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
'use client';
import { filters } from '@/lib/constant/jobs.constant';
import { filters, WorkMode } from '@/lib/constant/jobs.constant';
import {
JobQuerySchema,
JobQuerySchemaType,
} from '@/lib/validators/jobs.validator';
import { zodResolver } from '@hookform/resolvers/zod';
import { useForm } from 'react-hook-form';
import { JobLocations } from '@prisma/client';
import {
Accordion,
AccordionContent,
Expand All @@ -27,8 +26,6 @@ import { ScrollArea } from '@/components/ui/scroll-area';
import { cn } from '@/lib/utils';
import useSetQueryParams from '@/hooks/useSetQueryParams';
import { useEffect } from 'react';
import { WorkMode } from '@prisma/client';
import _ from 'lodash';

const JobFilters = ({ searchParams }: { searchParams: JobQuerySchemaType }) => {
const setQueryParams = useSetQueryParams();
Expand Down Expand Up @@ -82,36 +79,38 @@ const JobFilters = ({ searchParams }: { searchParams: JobQuerySchemaType }) => {
name="workmode"
render={() => (
<FormItem>
{Object.keys(WorkMode).map((item, index) => (
{filters.workMode.map((item) => (
<FormField
key={index}
key={item.id}
control={form.control}
name="workmode"
render={({ field }) => {
return (
<FormItem
key={index}
key={item.id}
className="flex items-center space-x-3 space-y-0"
>
<FormControl>
<Checkbox
checked={field.value?.includes(item)}
checked={field.value?.includes(
item.value as WorkMode
)}
onCheckedChange={(checked) => {
checked
? field.onChange([
...(field.value || []),
item,
item.value,
])
: field.onChange(
field.value?.filter(
(value) => value !== item
(value) => value !== item.value
)
);
}}
/>
</FormControl>
<FormLabel className="text-sm font-normal">
{_.startCase(item)}
{item.label}
</FormLabel>
</FormItem>
);
Expand Down Expand Up @@ -188,38 +187,42 @@ const JobFilters = ({ searchParams }: { searchParams: JobQuerySchemaType }) => {
name="location"
render={() => (
<FormItem className="flex flex-wrap gap-2 space-y-0">
{Object.keys(JobLocations).map((item, index) => (
{filters.location.map((item) => (
<FormField
key={index}
key={item.id}
control={form.control}
name="location"
render={({ field }) => {
return (
<FormItem
key={index}
key={item.id}
className="flex items-center space-y-0 group"
aria-checked={field.value?.includes(item)}
aria-checked={field.value?.includes(
item.value
)}
>
<FormControl>
<Checkbox
checked={field.value?.includes(item)}
checked={field.value?.includes(
item.value
)}
onCheckedChange={(checked) => {
checked
? field.onChange([
...(field.value || []),
item,
item.value,
])
: field.onChange(
field.value?.filter(
(value) => value !== item
(value) => value !== item.value
)
);
}}
hidden
/>
</FormControl>
<FormLabel className="text-primary-text font-normal text-xs cursor-pointer group-aria-checked:bg-primary group-aria-checked:text-primary-foreground flex items-center justify-start py-2 px-4 rounded-full border">
{_.startCase(item.toLowerCase())}
{item.label}
</FormLabel>
</FormItem>
);
Expand Down
Loading

0 comments on commit 0936123

Please sign in to comment.