From 041b85bb30a9879ad80a2183dcdad9d0a2236343 Mon Sep 17 00:00:00 2001 From: Anurag Negi <115611556+anuragnegi000@users.noreply.github.com> Date: Tue, 3 Sep 2024 19:33:46 +0530 Subject: [PATCH] removed login workflow (#295) * removed login and ModeToggle button(for dark/light mode switch) added infinite scroll for companies logo added debouncing and skeleton in place of jobs on load of screen * removed unwanted images * fixes * removed login workflow * fixed prettier * removed unwanted files --- src/actions/job.action.ts | 17 +-- src/app/(auth)/signin/page.tsx | 17 --- src/app/(auth)/signup/page.tsx | 15 --- src/app/api/auth/[...nextauth]/route.ts | 5 - src/components/auth/signin.tsx | 125 --------------------- src/components/auth/signup.tsx | 139 ------------------------ src/middleware.tsx | 26 +---- tailwind.config.ts | 2 +- 8 files changed, 8 insertions(+), 338 deletions(-) delete mode 100644 src/app/(auth)/signin/page.tsx delete mode 100644 src/app/(auth)/signup/page.tsx delete mode 100644 src/app/api/auth/[...nextauth]/route.ts delete mode 100644 src/components/auth/signin.tsx delete mode 100644 src/components/auth/signup.tsx diff --git a/src/actions/job.action.ts b/src/actions/job.action.ts index bdfbb921..ccea7d26 100644 --- a/src/actions/job.action.ts +++ b/src/actions/job.action.ts @@ -1,7 +1,5 @@ 'use server'; -import { ADMIN_ROLE } from '@/config/app.config'; import prisma from '@/config/prisma.config'; -import { withSession } from '@/lib/session'; import { withServerActionAsyncCatcher } from '@/lib/async-catch'; import { SuccessResponse } from '@/lib/success'; import { @@ -19,12 +17,11 @@ import { getAllJobsAdditonalType, getJobType } from '@/types/jobs.types'; type additional = { isVerifiedJob: boolean; }; -export const createJob = withSession< +export const createJob = withServerActionAsyncCatcher< JobPostSchemaType, ServerActionReturnType ->(async (session, data) => { +>(async (data) => { const result = JobPostSchema.parse(data); - const isVerifiedJob = session.user.role === ADMIN_ROLE; const { companyName, location, @@ -37,22 +34,20 @@ export const createJob = withSession< } = result; await prisma.job.create({ data: { - userId: session.user.id, + userId: '1', // Default to 1 since there's no session to check for user id title, description, companyName, hasSalaryRange, minSalary, maxSalary, - isVerifiedJob, location, workMode, + isVerifiedJob: false, // Default to false since there's no session to check for admin role }, }); - const message = isVerifiedJob - ? 'Job created successfully' - : 'Job created successfully, waiting for admin approval'; - const additonal = { isVerifiedJob }; + const message = 'Job created successfully, waiting for admin approval'; + const additonal = { isVerifiedJob: false }; return new SuccessResponse(message, 201, additonal).serialize(); }); diff --git a/src/app/(auth)/signin/page.tsx b/src/app/(auth)/signin/page.tsx deleted file mode 100644 index 83ad0731..00000000 --- a/src/app/(auth)/signin/page.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import Signin from '@/components/auth/signin'; -import { FormContainer } from '@/layouts/form-container'; - -const LoginPage = () => { - return ( -
- - - -
- ); -}; - -export default LoginPage; diff --git a/src/app/(auth)/signup/page.tsx b/src/app/(auth)/signup/page.tsx deleted file mode 100644 index ae0be0ef..00000000 --- a/src/app/(auth)/signup/page.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import Signup from '@/components/auth/signup'; -import { FormContainer } from '@/layouts/form-container'; - -const SignupPage = () => { - return ( - - - - ); -}; - -export default SignupPage; diff --git a/src/app/api/auth/[...nextauth]/route.ts b/src/app/api/auth/[...nextauth]/route.ts deleted file mode 100644 index adb3b89d..00000000 --- a/src/app/api/auth/[...nextauth]/route.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { options } from '@/lib/auth'; -import NextAuth from 'next-auth'; -const handler = NextAuth(options); - -export { handler as GET, handler as POST }; diff --git a/src/components/auth/signin.tsx b/src/components/auth/signin.tsx deleted file mode 100644 index cb360827..00000000 --- a/src/components/auth/signin.tsx +++ /dev/null @@ -1,125 +0,0 @@ -'use client'; -import { Button } from '@/components/ui/button'; -import { Input } from '@/components/ui/input'; -import APP_PATHS from '@/config/path.config'; -import { - SigninSchema, - SigninSchemaType, -} from '@/lib/validators/auth.validator'; -import { zodResolver } from '@hookform/resolvers/zod'; -import { signIn } from 'next-auth/react'; -import Link from 'next/link'; -import { useRouter } from 'next/navigation'; -import { useForm } from 'react-hook-form'; -import { - Form, - FormControl, - FormField, - FormItem, - FormLabel, - FormMessage, -} from '../ui/form'; -import { useToast } from '../ui/use-toast'; - -const Signin = () => { - const { toast } = useToast(); - const router = useRouter(); - const form = useForm({ - resolver: zodResolver(SigninSchema), - defaultValues: { - email: '', - password: '', - }, - }); - - async function signinHandler(data: SigninSchemaType) { - try { - const response = await signIn('signin', { ...data, redirect: false }); - if (!response?.ok) { - return toast({ - title: response?.error || 'Internal server error', - variant: 'destructive', - }); - } - toast({ - title: 'Login successful! Welcome back!', - variant: 'success', - }); - // const redirect = searchParams.get('next') || APP_PATHS.HOME; - const searchParams = new URLSearchParams(window.location.search); - const redirect = searchParams.get('next') || APP_PATHS.HOME; - router.push(redirect); - } catch (_error) { - return toast({ - title: 'Internal server error', - variant: 'destructive', - }); - } - } - - return ( -
-
- - ( - - Email address - - - - - - )} - /> - ( - - Password - - - - - - )} - /> -
- - Forget your password? - -
- - - -
- - Don't have an account yet?{' '} - - Sign Up - - -
-
- ); -}; - -export default Signin; diff --git a/src/components/auth/signup.tsx b/src/components/auth/signup.tsx deleted file mode 100644 index 03f3216c..00000000 --- a/src/components/auth/signup.tsx +++ /dev/null @@ -1,139 +0,0 @@ -'use client'; -import { Button } from '@/components/ui/button'; -import { Input } from '@/components/ui/input'; -import APP_PATHS from '@/config/path.config'; -import { - SignupSchema, - SignupSchemaType, -} from '@/lib/validators/auth.validator'; -import { zodResolver } from '@hookform/resolvers/zod'; -import { signIn } from 'next-auth/react'; -import Link from 'next/link'; -import { useRouter } from 'next/navigation'; -import { useForm } from 'react-hook-form'; -import { - Form, - FormControl, - FormField, - FormItem, - FormLabel, - FormMessage, -} from '../ui/form'; -import { useToast } from '../ui/use-toast'; - -const Signup = () => { - // const searchParams = useSearchParams(); - const { toast } = useToast(); - const router = useRouter(); - const form = useForm({ - resolver: zodResolver(SignupSchema), - defaultValues: { - name: '', - email: '', - password: '', - }, - }); - - async function signupHandler(data: SignupSchemaType) { - try { - const response = await signIn('signup', { ...data, redirect: false }); - if (!response?.ok) { - return toast({ - title: response?.error || 'Internal server error', - variant: 'destructive', - }); - } - toast({ - title: 'Signup successful! Welcome to 100xJobs!', - variant: 'success', - }); - const searchParams = new URLSearchParams(window.location.search); - const redirect = searchParams.get('next') || APP_PATHS.HOME; - router.push(redirect); - } catch (_error) { - toast({ - title: 'something went wrong', - variant: 'destructive', - }); - } - } - - return ( -
-
- - ( - - Name - - - - - - )} - /> - ( - - Email address - - - - - - )} - /> - ( - - Password - - - - - - )} - /> -
- - Forget your password? - -
- - - -
- - Already have an account?{' '} - - Sign In - - -
-
- ); -}; - -export default Signup; diff --git a/src/middleware.tsx b/src/middleware.tsx index a786795b..a639af34 100644 --- a/src/middleware.tsx +++ b/src/middleware.tsx @@ -1,28 +1,4 @@ -import APP_PATHS from '@/config/path.config'; -import { getToken } from 'next-auth/jwt'; -import { NextRequest, NextResponse } from 'next/server'; - -const authRoutes = ['/signup', '/signin']; -const privateRoutes = ['/create', '/setting']; -export async function middleware(request: NextRequest) { - const session = await getToken({ - req: request, - secret: process.env.NEXTAUTH_SECRET, - }); - const currentPath = request.nextUrl.pathname; - if (!session && privateRoutes.includes(currentPath)) { - return NextResponse.redirect( - new URL( - `${APP_PATHS.SIGNIN}?next=${encodeURIComponent(currentPath)}`, - request.url - ) - ); - } - if (authRoutes.includes(currentPath) && session) { - return NextResponse.redirect(new URL(`${APP_PATHS.HOME}`, request.url)); - } - return NextResponse.next(); -} +export async function middleware() {} export const config = { matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)'], diff --git a/tailwind.config.ts b/tailwind.config.ts index 9c6cc61d..096c1de8 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -23,7 +23,7 @@ const config = { fontFamily: { sans: ['var(--font-sans)', ...fontFamily.sans], }, - + colors: { 'stroke-primary': 'hsl(var(--stroke-primary))', 'stroke-secondary': 'hsl(var(--stroke-secondary))',