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

fix: bug fixes and ui updates #421

Merged
merged 6 commits into from
Sep 29, 2024
Merged
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
6 changes: 4 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
BASE_URL=http://localhost:3000
#
# Database
#
Expand All @@ -20,8 +19,11 @@ NEXT_PUBLIC_GOOGLE_MAPS_API_KEY=maps-api-key
#
# Email SMTP credentials
#
EMAIL_USER=user@gmail.com
EMAIL_USER= # your email ex: vineetagarwal@gmail.com
EMAIL_PASSWORD=
EMAIL_SERVICE=gmail
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587

#
# Google OAuth credentials
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@hookform/resolvers": "^3.9.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",
"@radix-ui/react-dialog": "^1.1.1",
"@radix-ui/react-dropdown-menu": "^2.1.1",
Expand Down
16 changes: 0 additions & 16 deletions prisma/migrations/20240921165842_update/migration.sql

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-- CreateEnum
CREATE TYPE "OauthProvider" AS ENUM ('GOOGLE');

-- CreateEnum
CREATE TYPE "TokenType" AS ENUM ('EMAIL_VERIFICATION', 'RESET_PASSWORD');

-- CreateEnum
CREATE TYPE "Currency" AS ENUM ('INR', 'USD');

Expand All @@ -7,19 +13,35 @@ CREATE TYPE "WorkMode" AS ENUM ('remote', 'hybrid', 'office');
-- CreateEnum
CREATE TYPE "Role" AS ENUM ('USER', 'ADMIN');

-- CreateEnum
CREATE TYPE "EmployementType" AS ENUM ('Full_time', 'Part_time', 'Internship', 'Contract');

-- CreateTable
CREATE TABLE "User" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"email" TEXT NOT NULL,
"password" TEXT NOT NULL,
"password" TEXT,
"avatar" TEXT,
"isVerified" BOOLEAN NOT NULL DEFAULT false,
"role" "Role" NOT NULL DEFAULT 'USER',
"email" TEXT NOT NULL,
"emailVerified" TIMESTAMP(3),
"oauthProvider" "OauthProvider",
"oauthId" TEXT,
"blockedByAdmin" TIMESTAMP(3),

CONSTRAINT "User_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "VerificationToken" (
"token" TEXT NOT NULL,
"identifier" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"type" "TokenType" NOT NULL
);

-- CreateTable
CREATE TABLE "Job" (
"id" TEXT NOT NULL,
Expand All @@ -30,16 +52,20 @@ CREATE TABLE "Job" (
"company_bio" TEXT NOT NULL,
"company_email" TEXT NOT NULL,
"category" TEXT NOT NULL,
"type" TEXT NOT NULL,
"type" "EmployementType" NOT NULL,
"work_mode" "WorkMode" NOT NULL,
"currency" "Currency" NOT NULL DEFAULT 'INR',
"city" TEXT NOT NULL,
"address" TEXT NOT NULL,
"application" TEXT NOT NULL,
"companyLogo" TEXT NOT NULL,
"skills" TEXT[],
"has_salary_range" BOOLEAN NOT NULL DEFAULT false,
"minSalary" INTEGER,
"maxSalary" INTEGER,
"has_experience_range" BOOLEAN NOT NULL DEFAULT false,
"minExperience" INTEGER,
"maxExperience" INTEGER,
"is_verified_job" BOOLEAN NOT NULL DEFAULT false,
"postedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
Expand All @@ -50,5 +76,8 @@ CREATE TABLE "Job" (
-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");

-- CreateIndex
CREATE UNIQUE INDEX "VerificationToken_token_identifier_key" ON "VerificationToken"("token", "identifier");

-- AddForeignKey
ALTER TABLE "Job" ADD CONSTRAINT "Job_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
29 changes: 14 additions & 15 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -47,32 +47,32 @@ enum TokenType {
}

model Job {
id String @id @default(cuid())
id String @id @default(cuid())
userId String
title String
description String?
companyName String @map("company_name")
companyBio String @map("company_bio")
companyEmail String @map("company_email")
category String
companyName String @map("company_name")
companyBio String @map("company_bio")
companyEmail String @map("company_email")
category String
type EmployementType
workMode WorkMode @map("work_mode")
currency Currency @default(INR)
workMode WorkMode @map("work_mode")
currency Currency @default(INR)
city String
address String
application String
companyLogo String
companyLogo String
skills String[]
hasSalaryRange Boolean @default(false) @map("has_salary_range")
hasSalaryRange Boolean @default(false) @map("has_salary_range")
minSalary Int?
maxSalary Int?
hasExperiencerange Boolean @default(false) @map("has_experience_range")
hasExperiencerange Boolean @default(false) @map("has_experience_range")
minExperience Int?
maxExperience Int?
isVerifiedJob Boolean @default(false) @map("is_verified_job")
postedAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id])
isVerifiedJob Boolean @default(false) @map("is_verified_job")
postedAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id])
}

enum Currency {
Expand All @@ -97,4 +97,3 @@ enum EmployementType {
Internship
Contract
}

8 changes: 3 additions & 5 deletions src/actions/auth.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
} from '@/config/auth.config';
import APP_PATHS from '@/config/path.config';
import prisma from '@/config/prisma.config';
import { serverEnv } from '@/env/server';
import { withServerActionAsyncCatcher } from '@/lib/async-catch';
import { ErrorHandler } from '@/lib/error';
import {
Expand Down Expand Up @@ -53,8 +52,7 @@ export const signUp = withServerActionAsyncCatcher<
},
});

const confirmationLink = `${serverEnv.BASE_URL}/${APP_PATHS.VERIFY_EMAIL}/${verificationToken.token}`;

const confirmationLink = `${process.env.NEXTAUTH_URL}${APP_PATHS.VERIFY_EMAIL}/${verificationToken.token}`;
await sendConfirmationEmail(
data.email,
confirmationLink,
Expand Down Expand Up @@ -160,7 +158,7 @@ const resendVerificationLinkUtil = async ({
data: { token: newToken, ...(reIssue ? { createdAt: new Date() } : {}) },
});

const confirmationLink = `${serverEnv.BASE_URL}/${APP_PATHS.VERIFY_EMAIL}/${newToken}`;
const confirmationLink = `${process.env.NEXTAUTH_URL}/${APP_PATHS.VERIFY_EMAIL}/${newToken}`;
await sendConfirmationEmail(email, confirmationLink, type);
};

Expand Down Expand Up @@ -246,7 +244,7 @@ export const forgetPassword = withServerActionAsyncCatcher<
},
});

const resetPasswordLink = `${serverEnv.BASE_URL}/${APP_PATHS.RESET_PASSWORD}/${verificationToken.token}`;
const resetPasswordLink = `${process.env.NEXTAUTH_URL}/${APP_PATHS.RESET_PASSWORD}/${verificationToken.token}`;

await sendConfirmationEmail(email, resetPasswordLink, 'RESET_PASSWORD');

Expand Down
7 changes: 3 additions & 4 deletions src/actions/job.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@ import {
} from '@/lib/validators/jobs.validator';
import { getJobFilters } from '@/services/jobs.services';
import { ServerActionReturnType } from '@/types/api.types';

import { getServerSession } from 'next-auth';
import { authOptions } from '@/lib/authOptions';

import {
getAllJobsAdditonalType,
getAllRecommendedJobs,
getJobType,
} from '@/types/jobs.types';


type additional = {
isVerifiedJob: boolean;
Expand Down Expand Up @@ -73,7 +72,7 @@ export const createJob = withServerActionAsyncCatcher<
address,
companyLogo,
workMode,
isVerifiedJob: false, // Default to false since there's no session to check for admin role
isVerifiedJob: false,
},
});
const message = 'Job created successfully, waiting for admin approval';
Expand Down
2 changes: 1 addition & 1 deletion src/components/DescriptionEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const DescriptionEditor: React.FC<DescriptionEditorProps> = ({
style={{ width: '100%' }}
onChange={handleChange}
placeholder={placeholder}
className="text-white bg-gray-800 overflow-hidden job-description-editor text-wrap max-w-[537px]"
className="text-white bg-gray-800 job-description-editor text-wrap max-w-[537px]"
/>
);
};
Expand Down
1 change: 0 additions & 1 deletion src/components/auth/signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export const Signup = () => {
async function signupHandler(data: SignupSchemaType) {
try {
const response = await signUp(data);

if (!response.status) {
toast({
title: response.message || 'Something went wrong',
Expand Down
4 changes: 2 additions & 2 deletions src/components/job-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ export default function JobCard({ job }: { job: JobType }) {
{/* job card */}
<div className="border-2 transition-all duration-115 ease-linear hover:bg-lightBgSecondary dark:hover:bg-darkBgSecondary flex flex-col gap-6 h-fit max-h-[10rem] p-4 rounded-xl">
<div className="flex gap-4 items-center">
<div className="w-[4rem] h-[4rem] bg-primary/20 rounded-md">
<div className="w-[4rem] h-[4rem] rounded-md">
{job.companyLogo && (
<Image
className="size-full object-cover dark:invert"
className="size-full object-cover "
src={job.companyLogo || ''}
width={'500'}
height={'500'}
Expand Down
6 changes: 3 additions & 3 deletions src/components/job-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ const PostJobForm = () => {
(await submitImage(file)) ?? 'https://wwww.example.com';
``;
const response = await createJob(data);

if (!response.status) {
return toast({
title: response.message || 'Error',
Expand Down Expand Up @@ -182,14 +183,14 @@ const PostJobForm = () => {
<div className="bg-gray-800/90 backdrop-blur-sm p-4 rounded-lg text-center text-white w-full md:w-48">
<MailOpenIcon className="w-8 h-8 mb-3 mx-auto text-purple-500" />
<p className="text-base font-semibold mb-1">Emailed to</p>
<p className="text-gray-400 text-sm">290,301 subscribers</p>
<p className="text-gray-400 text-sm">17,000 subscribers</p>
</div>

<div className="bg-gray-800/90 backdrop-blur-sm p-4 rounded-lg text-center text-white w-full md:w-48">
<LucideRocket className="w-8 h-8 mb-3 mx-auto text-orange-500" />
<p className="text-base font-semibold mb-1">Reach</p>
<p className="text-gray-400 text-sm">
300,000<span className="text-blue-500">+</span>
500,000<span className="text-blue-500">+</span>
</p>
</div>
</div>
Expand Down Expand Up @@ -382,7 +383,6 @@ const PostJobForm = () => {
innerRef={gmapsInputRef}
form={form}
></DynamicGmapsAutoSuggest>

<FormField
control={form.control}
name="application"
Expand Down
Loading
Loading