import { NextAuthOptions } from "next-auth";
import NextAuth from "next-auth/next";
import  CredentialsProvider  from "next-auth/providers/credentials";

const authOptions: NextAuthOptions = {
    session: {
        strategy: 'jwt',
    },
    providers: [
        CredentialsProvider({
            type: "credentials",
            credentials: {},
            authorize(credentials, req){
                const {email, password} = credentials as {
                    email: string;
                    password: string;
                }

                if( email !== "johndoe@gmail.com" || password !=="qweqwe"){
                    throw new Error('Invalid Credentials')
                }
                return{
                    id: '123', firstName: "John", lastName: "Doe", name: "John Doe", email: "test@gmail.com", role: "admin"
                }
            }
        })
    ],
    pages: {
        signIn: "/auth/login/"
    }, 
    
}

export default NextAuth(authOptions)