diff --git a/.env.example b/.env.example index f8f03c54..c9deb5b8 100644 --- a/.env.example +++ b/.env.example @@ -15,7 +15,3 @@ NEXTAUTH_URL="http://localhost:3000" CDN_API_KEY=api-key CDN_BASE_UPLOAD_URL=https://sg.storage.bunnycdn.com/job-board/assets CDN_BASE_ACCESS_URL=https://job-board.b-cdn.net/assets - - -NEXT_PUBLIC_GOOGLE_MAPS_API_KEY= - diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d189e867..424c68cc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -27,10 +27,6 @@ jobs: - name: Run format check run: npm run check - - - name: Run format fix if check fails - if: ${{ failure() }} - run: npm run format - name: Run build - run: npm run build + run: npm run build \ No newline at end of file diff --git a/package.json b/package.json index 9ccd4412..36636e1b 100644 --- a/package.json +++ b/package.json @@ -9,27 +9,16 @@ "lint": "next lint", "dev:docker": "npm run db:seed & next dev", "db:seed": "npx prisma db push & npx prisma db seed", - "check": "prettier --check \"**/*.{ts,tsx,js,jsx,md,mdx,css}\"", "format": "prettier --write \"**/*.{ts,tsx,js,jsx,md,mdx,css}\"", + "check": "prettier --check \"**/*.{ts,tsx,js,jsx,md,mdx,css}\"", "prepare": "husky" }, - "husky": { - "hooks": { - "pre-commit": "lint-staged" - } - }, - "lint-staged": { - "**/*.{ts,tsx,js,jsx,md,mdx,css}": [ - "prettier --write" - ] - }, "prisma": { "seed": "ts-node --compiler-options {\"module\":\"CommonJS\"} prisma/seed.ts" }, "dependencies": { "@aws-sdk/client-s3": "^3.645.0", "@aws-sdk/s3-request-presigner": "^3.645.0", - "@faker-js/faker": "^9.0.0", "@hookform/resolvers": "^3.9.0", "@prisma/client": "5.18.0", "@radix-ui/react-accordion": "^1.2.0", diff --git a/prisma/schema.prisma b/prisma/schema.prisma index e3eba55e..baec4f15 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -30,8 +30,7 @@ model Job { type String workMode WorkMode @map("work_mode") currency Currency @default(INR) - city String - address String + location JobLocations application String companyLogo String hasSalaryRange Boolean @default(false) @map("has_salary_range") @@ -59,3 +58,15 @@ enum Role { ADMIN } +enum JobLocations { + BANGLORE + DELHI + MUMBAI + CHENNAI + PUNE + HYDERABAD + KOLKATA + AHMEDABAD + JAIPUR + SURAT +} diff --git a/prisma/seed.ts b/prisma/seed.ts index 3f01a17b..347cfcfc 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -1,14 +1,16 @@ /* eslint-disable no-console */ import { Currency, Role, WorkMode } from '@prisma/client'; -import { faker } from '@faker-js/faker'; import bcrypt from 'bcryptjs'; import prisma from '../src/config/prisma.config'; +import { JobLocations } from '@prisma/client'; const users = [ { id: '1', name: 'Jack', email: 'user@gmail.com' }, { id: '2', name: 'Admin', email: 'admin@gmail.com', role: Role.ADMIN }, ]; +const locationArr = Object.keys(JobLocations); + let jobs = [ { id: '1', @@ -284,6 +286,13 @@ 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) => @@ -302,8 +311,8 @@ async function seedJobs() { workMode: j.workMode, currency: j.currency, application: j.application, - city: faker.location.city(), - address: faker.location.streetAddress(), + //@ts-ignore + location: j.location, companyLogo: j.companyLogo, hasSalaryRange: j.hasSalaryRange, minSalary: j.minSalary, diff --git a/src/actions/job.action.ts b/src/actions/job.action.ts index 3b752977..693740fb 100644 --- a/src/actions/job.action.ts +++ b/src/actions/job.action.ts @@ -29,8 +29,7 @@ export const createJob = withServerActionAsyncCatcher< type, category, application, - city, - address, + location, companyLogo, title, workMode, @@ -53,8 +52,7 @@ export const createJob = withServerActionAsyncCatcher< hasSalaryRange, minSalary, maxSalary, - city, - address, + location, companyLogo, workMode, isVerifiedJob: false, // Default to false since there's no session to check for admin role @@ -75,8 +73,8 @@ export const getAllJobs = withServerActionAsyncCatcher< if (data?.salaryrange && !Array.isArray(data?.salaryrange)) { data.salaryrange = Array.of(data?.salaryrange); } - if (data?.city && !Array.isArray(data?.city)) { - data.city = Array.of(data?.city); + if (data?.location && !Array.isArray(data?.location)) { + data.location = Array.of(data?.location); } const result = JobQuerySchema.parse(data); const { filterQueries, orderBy, pagination } = getJobFilters(result); @@ -92,8 +90,7 @@ export const getAllJobs = withServerActionAsyncCatcher< title: true, description: true, companyName: true, - city: true, - address: true, + location: true, workMode: true, minSalary: true, maxSalary: true, @@ -134,8 +131,7 @@ export const getJobById = withServerActionAsyncCatcher< companyBio: true, companyEmail: true, companyLogo: true, - city: true, - address: true, + location: true, workMode: true, minSalary: true, maxSalary: true, @@ -146,15 +142,3 @@ export const getJobById = withServerActionAsyncCatcher< job, }).serialize(); }); - -export const getCityFilters = async () => { - const response = await prisma.job.findMany({ - select: { - city: true, - }, - }); - const cities = Array.from(new Set(response.map((res) => res.city))); - return new SuccessResponse(`Cities fetched successfully`, 200, { - cities, - }).serialize(); -}; diff --git a/src/app/globals.css b/src/app/globals.css index 301c0d12..b3c421ed 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -345,30 +345,3 @@ overflow-x: hidden !important; /* Allow horizontal scrolling */ overflow-y: hidden !important; /* Hide vertical overflow */ } - -.pac-container { - background-color: black !important; - color: #fff; - border-radius: 8px; - padding-top: 5px; - padding-bottom: 5px; - font-family: '__Inter_36bd41', '__Inter_Fallback', sans-serif !important; - font-size: 14px !important; -} -.pac-item { - color: #fff !important; - border: none; - font-size: 14px; -} -.pac-item:hover { - background-color: hsl(0, 0%, 14.9%) !important; - cursor: pointer; -} -.pac-item-query { - color: white; - font-weight: bold; -} - -.pac-logo.hdpi::after { - content: none; -} diff --git a/src/components/all-jobs.tsx b/src/components/all-jobs.tsx index 67123e2c..ce519806 100644 --- a/src/components/all-jobs.tsx +++ b/src/components/all-jobs.tsx @@ -40,7 +40,7 @@ const AllJobs = async ({ searchParams }: PaginatorProps) => {
- {job.address}{' '} + {job.location}{' '} ({job.workMode}) diff --git a/src/components/gmaps-autosuggest.tsx b/src/components/gmaps-autosuggest.tsx deleted file mode 100644 index a13f04ee..00000000 --- a/src/components/gmaps-autosuggest.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import Script from 'next/script'; -import { Input } from './ui/input'; - -export type TgmapsAddress = { city: string; fullAddress: string }; - -export function GmapsAutocompleteAddress({ form }: { form: any }) { - let autocomplete: any = null; - - function onPlaceChanged() { - const { name, formatted_address } = autocomplete.getPlace(); - form.setValue('city', name); - form.setValue('address', formatted_address); - } - - function initializeGmaps() { - if ((window as any).google) { - autocomplete = new (window as any).google.maps.places.Autocomplete( - document.getElementById('autocomplete'), - { - types: ['(cities)'], - } - ); - autocomplete.addListener('place_changed', onPlaceChanged); - } - } - return ( - <> -