Skip to content

Commit

Permalink
Merge branch 'main' into feat-job-seeker-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
devsharmagit authored Oct 31, 2024
2 parents c52ceb4 + 139175f commit 0bebe98
Show file tree
Hide file tree
Showing 58 changed files with 702 additions and 178 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,9 @@ bun.lockb
package-lock.json
yarn.lock

**/public/sw.js
**/public/workbox-*.js
**/public/worker-*.js
**/public/sw.js.map
**/public/workbox-*.js.map
**/public/worker-*.js.map
19 changes: 15 additions & 4 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ model User {
project Project[]
resume String?
oauthProvider OauthProvider? // Tracks OAuth provider (e.g., 'google')
oauthId String?
oauthProvider OauthProvider? // Tracks OAuth provider (e.g., 'google')
oauthId String?
createdAt DateTime @default(now())
blockedByAdmin DateTime?
onBoard Boolean @default(false)
onBoard Boolean @default(false)
bookmark Bookmark[]
githubLink String?
Expand All @@ -45,6 +45,17 @@ model User {
education Education[]
resumeUpdateDate DateTime?
companyId String? @unique
company Company? @relation(fields: [companyId], references: [id])
}

model Company {
id String @id @default(cuid())
companyName String
companyLogo String?
companyEmail String
companyBio String
user User?
}

enum OauthProvider {
Expand Down
51 changes: 37 additions & 14 deletions prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,21 @@ import bcrypt from 'bcryptjs';
const prisma = new PrismaClient();

const users = [
{ id: '1', name: 'Jack', email: '[email protected]', role: Role.USER },
{
id: '2',
name: 'Admin',
email: '[email protected]',
role: Role.ADMIN,
onBoard: true,
},
{
id: '3',
name: 'Hr',
email: '[email protected]',
role: Role.HR,
},
{ id: '1', name: 'Jack', email: '[email protected]' },
{ id: '2', name: 'Admin', email: '[email protected]', role: Role.ADMIN, onBoard: true },
{ id: '3', companyId: '1', name: 'Hr', email: '[email protected]', role: Role.HR, onBoard: true },
{ id: '4', companyId: '2', name: 'John', email: '[email protected]', role: Role.HR, onBoard: true },
{ id: '5', companyId: '3', name: 'Jane', email: '[email protected]', role: Role.HR, onBoard: true },
];


const companies = [
{ id: '1', compnayEmail: "[email protected]", companyName: 'Tech Corp', companyBio: 'Leading tech solutions provider specializing in innovative web development.', companyLogo: '/main.svg' },
{ id: '2', companyEmail: "[email protected]", companyName: 'Global Solutions', companyBio: 'Global Solutions offers comprehensive IT services for businesses worldwide.', companyLogo: '/main.svg' },
{ id: '3', companyEmail: '[email protected]', companyName: 'Innovatech', companyBio: 'Innovatech specializes in backend systems and cloud-based solutions.', companyLogo: '/main.svg' },
]


let jobs = [
{
id: '1',
Expand Down Expand Up @@ -332,6 +331,7 @@ async function seedUsers() {
password: hashedPassword,
role: u.role || Role.USER,
emailVerified: new Date(),
companyId: u.companyId
},
});
console.log(`User created or updated: ${u.email}`);
Expand All @@ -344,6 +344,28 @@ async function seedUsers() {
console.error('Error seeding users:', error);
}
}
async function seedCompanies() {
try {
await Promise.all(
companies.map(async (c) =>
prisma.company.upsert({
where: { id: c.id },
create: {
id: c.id,
companyName: c.companyName,
companyEmail: c.companyEmail ?? "[email protected]",
companyBio: c.companyBio,
companyLogo: c.companyLogo,
},
update: {},
})
)
);
console.log('✅ Company seed completed successfully');
} catch (error) {
console.error('Error seeding companies:', error);
}
}

async function seedJobs() {
try {
Expand Down Expand Up @@ -405,6 +427,7 @@ async function seedJobs() {
}

async function main() {
await seedCompanies();
await seedUsers();
await seedJobs();
}
Expand Down
6 changes: 6 additions & 0 deletions public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
User-agent: *
Allow: /
Disallow: /admin/*
Disallow: /manage/*

Sitemap: https://job.vineet.tech/sitemap.xml
6 changes: 6 additions & 0 deletions src/actions/job.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export const getAllJobs = withSession<
skills: true,
address: true,
workMode: true,
expired: true,
category: true,
minSalary: true,
maxSalary: true,
Expand Down Expand Up @@ -219,6 +220,7 @@ export const getRecommendedJobs = withServerActionAsyncCatcher<
maxSalary: true,
postedAt: true,
skills: true,
expired: true,
isVerifiedJob: true,
companyLogo: true,
},
Expand Down Expand Up @@ -252,6 +254,7 @@ export const getRecommendedJobs = withServerActionAsyncCatcher<
companyLogo: true,
minExperience: true,
maxExperience: true,
expired: true,
isVerifiedJob: true,
category: true,
},
Expand Down Expand Up @@ -294,6 +297,7 @@ export const getJobById = withServerActionAsyncCatcher<
minExperience: true,
maxExperience: true,
skills: true,
expired: true,
address: true,
workMode: true,
hasSalaryRange: true,
Expand Down Expand Up @@ -352,6 +356,7 @@ export const getRecentJobs = async () => {
minExperience: true,
maxExperience: true,
skills: true,
expired: true,
postedAt: true,
companyLogo: true,
type: true,
Expand Down Expand Up @@ -601,6 +606,7 @@ export async function GetBookmarkByUserId() {
minSalary: true,
maxSalary: true,
postedAt: true,
expired: true,
companyLogo: true,
},
},
Expand Down
34 changes: 34 additions & 0 deletions src/actions/user.profile.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ export const getUserDetails = async () => {
}
};


export const getUserDetailsWithId = async (id: string) => {
try {
const res = await prisma.user.findFirst({
Expand Down Expand Up @@ -621,6 +622,39 @@ export const deleteEducation = async (educationId: number) => {
});
revalidatePath(`/newProfile/${auth.user.id}`);
return new SuccessResponse('Project Deleted Successfully', 200).serialize();

export const getUserRecruiters = async () => {
const auth = await getServerSession(authOptions);

if (!auth || !auth?.user?.id || auth?.user?.role !== 'ADMIN')
throw new ErrorHandler('Not Authorized', 'UNAUTHORIZED');
try {
const res = await prisma.user.findMany({
where: {
role: 'HR',
},
select: {
id: true,
email: true,
name: true,
createdAt: true,
_count: {
select: {
jobs: true,
},
},
company: {
select: {
companyName: true,
companyEmail: true,
},
},
},
});
return new SuccessResponse('Recruiter SuccessFully Fetched', 200, {
recruiters: res,
}).serialize();

} catch (_error) {
return new ErrorHandler('Internal server error', 'DATABASE_ERROR');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,19 @@ export const EmailVerificationLinkExpired = ({ token }: { token: string }) => {
>
{!isEmailSent ? (
<Link href={APP_PATHS.SIGNIN}>
<Button className="w-full" disabled={isLoading}>
<Button
className="w-full"
disabled={isLoading}
aria-label="login-redirect"
>
Go to Login
</Button>
</Link>
) : (
<Link href={APP_PATHS.SIGNIN} onClick={handleResendClick}>
<Button className="w-full">Resend Verification Email</Button>
<Button className="w-full" aria-label="resend">
Resend Verification Email
</Button>
</Link>
)}
</FormContainer>
Expand Down
8 changes: 6 additions & 2 deletions src/app/(auth)/verify-email/[token]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ const EmailVerifiedSuccess = () => {
}
>
<Link href={APP_PATHS.SIGNIN}>
<Button className="w-full">Go to Login</Button>
<Button className="w-full" aria-label="login">
Go to Login
</Button>
</Link>
</FormContainer>
</div>
Expand All @@ -44,7 +46,9 @@ const EmailVerificationLinkNotFound = () => {
description={'The verification link you used is invalid or not found.'}
>
<Link href={APP_PATHS.SIGNUP}>
<Button className="w-full">Go to Signup</Button>
<Button className="w-full" aria-label="signip-redirect">
Go to Signup
</Button>
</Link>
</FormContainer>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/app/[...404]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const Custom404Page = () => {
<Button
asChild
className="bg-blue-600 hover:bg-blue-700 text-white font-semibold py-2 px-6 rounded-full transition-colors duration-300"
aria-label="home-redirect"
>
<Link href="/">
<span className="flex items-center">
Expand Down
1 change: 1 addition & 0 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const satoshi = localFont({
export const metadata: Metadata = {
title: '100xJobs',
description: 'Get your dream job',
// icons: '/main.png',
};

export default async function RootLayout({
Expand Down
6 changes: 1 addition & 5 deletions src/app/manage/page.tsx → src/app/manage/jobs/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ const ManageJob = async ({
redirect('/jobs');
}
const searchParamss = parsedData.data;
return (
<div className="container">
<JobManagement searchParams={searchParamss} />
</div>
);
return <JobManagement searchParams={searchParamss} />;
};

export default ManageJob;
22 changes: 22 additions & 0 deletions src/app/manage/recruiters/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { getUserRecruiters } from '@/actions/user.profile.actions';
import ManageRecruiters from '@/components/ManageRecruiters';

import { options } from '@/lib/auth';
import { getServerSession } from 'next-auth';
import { redirect } from 'next/navigation';
import React from 'react';

const RecruitersPage = async () => {
const server = await getServerSession(options);
if (!server?.user) {
redirect('/api/auth/signin');
} else if (server.user.role !== 'ADMIN') {
redirect('/jobs');
}

const Recruiters = await getUserRecruiters();

return <ManageRecruiters recruiters={Recruiters} />;
};

export default RecruitersPage;
1 change: 1 addition & 0 deletions src/components/ApproveJobDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const ApproveJobDialog = ({
className="mt-2"
variant={'secondary'}
onClick={handleClick}
aria-label="approve"
>
Approve
</Button>
Expand Down
11 changes: 8 additions & 3 deletions src/components/DeleteDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Button } from './ui/button';
import { useToast } from './ui/use-toast';
import { toggleDeleteJobById } from '@/actions/job.action';
import { JobType } from '@/types/jobs.types';
import icons from '@/lib/icons';
import {
Dialog,
DialogTrigger,
Expand All @@ -13,7 +14,6 @@ import {
DialogDescription,
DialogFooter,
} from './ui/dialog';
import { ArchiveRestore, Trash } from 'lucide-react';

const JobDialog = ({ job }: { job: JobType }) => {
const [dialogOpen, setDialogOpen] = useState(false); // State to manage dialog visibility
Expand Down Expand Up @@ -42,15 +42,19 @@ const JobDialog = ({ job }: { job: JobType }) => {
role="button"
onClick={() => setDialogOpen(true)}
>
<ArchiveRestore /> {/* Icon for restoring the job */}
<Button variant="ghost" size="icon">
<icons.ArchiveRestore className="h-7 w-5 text-green-500" />
</Button>
</span>
) : (
<span
className="mr-5"
role="button"
onClick={() => setDialogOpen(true)}
>
<Trash /> {/* Icon for deleting the job */}
<Button variant="ghost" size="icon">
<icons.trash className="h-7 w-5 text-red-500" />
</Button>
</span>
)}
</DialogTrigger>
Expand All @@ -74,6 +78,7 @@ const JobDialog = ({ job }: { job: JobType }) => {
className="mt-2"
variant={job.deleted ? 'secondary' : 'destructive'}
onClick={handelToggle}
aria-label="delete"
>
{job.deleted ? 'Restore' : 'Delete'}
</Button>
Expand Down
1 change: 1 addition & 0 deletions src/components/Faqs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default function Faqs() {
className="flex w-full justify-between items-center cursor-pointer focus:outline-none dark:bg-[#0F172A] bg-[#F1F5F9] p-4 rounded-xl"
onClick={() => toggleExpand(i)}
aria-expanded={expandedIndex === i}
aria-label="toggle-expand"
>
<p className="text-left font-medium dark:text-white text-gray-900">
{faq.question}
Expand Down
4 changes: 3 additions & 1 deletion src/components/FaqsGetintouchCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ export default function FaqsGetintouchCard() {
<p className="font-semibold md:text-base text-xs">
Can&apos;t find what you&apos;re looking for?
</p>
<Button className="md:text-base text-xs">Get in touch</Button>
<Button className="md:text-base text-xs" aria-label="get-in-touch">
Get in touch
</Button>
</div>
);
}
Loading

0 comments on commit 0bebe98

Please sign in to comment.