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

7 comp 7 login form frontend #53

Merged
merged 2 commits into from
Nov 2, 2023
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
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"postcss": "8.4.28",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-icons": "^4.11.0",
"tailwindcss": "3.3.3"
},
"devDependencies": {
Expand Down
3 changes: 3 additions & 0 deletions src/components/Logo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function CompoundLogo(){
return <>LOGO HERE</>
}
50 changes: 50 additions & 0 deletions src/components/SignInForm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { Text, Button, Input, Divider, VStack, HStack, InputGroup, InputRightElement, Center, AbsoluteCenter, Flex } from "@chakra-ui/react";
import CompoundLogo from "./Logo";
import { FcGoogle } from 'react-icons/fc'
import { FaFacebook } from 'react-icons/fa'
import { SiLinkedin } from 'react-icons/si'
import { signIn } from "next-auth/react";
import { useState } from "react";

export default function SignInForm(): JSX.Element {
const [show, setShow] = useState(false)
const handleClick = () => setShow(!show)

return (
<Flex
width="100vw"
height="75vh"
alignItems="center"
justifyContent="center"
>
<Center>
<VStack spacing='24px'>
<CompoundLogo></CompoundLogo>
<Input variant='outline' placeholder='Email'></Input>
<InputGroup size='md'>
<Input
pr='4.5rem'
type={show ? 'text' : 'password'}
placeholder='Enter password'
/>
<InputRightElement width='4.5rem'>
<Button h='1.75rem' size='sm' onClick={handleClick}>
{show ? 'Hide' : 'Show'}
</Button>
</InputRightElement>
</InputGroup>
<Button> Login </Button>
<Divider borderWidth={'2px'} orientation="horizontal"></Divider>
<Text textColor={'black'}>Or Log In With One Of: </Text>
<HStack spacing='10px'>
{/* Providers Here */}
<Button w={'full'} leftIcon={<FcGoogle />} onClick={() => signIn("google")}>Google</Button>
<Button w={'full'} colorScheme={'facebook'} leftIcon={<FaFacebook />}>Facebook</Button>
<Button w={'full'} colorScheme={'messenger'} leftIcon={<SiLinkedin />}>LinkedIn</Button>
</HStack>
<Divider borderWidth={'2px'} orientation="horizontal"></Divider>
<Button>Sign Up</Button>
</VStack>
</Center>
</Flex>)
}
8 changes: 4 additions & 4 deletions src/models/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { PrismaClient, User } from "@prisma/client";
import isEmail from "isemail";
import { PrismaClientKnownRequestError } from "@prisma/client/runtime/library";
import { UserData, UserReturnType } from "../../lib/CompoundTypes";
import { data } from "autoprefixer";
import prisma from "../../lib/client";

// Uer Information that is Insensitive
export interface InsensitiveUserInformation {
Expand Down Expand Up @@ -159,11 +159,11 @@ export default class Users {
}

public async isUserInDatabase(email: string): Promise<boolean> {
const userExists = this.usersDB.findUnique({
const userExists = await this.usersDB.findUnique({
where: {
email: email,
},
});
return userExists instanceof Users;
return userExists !== null;
}
}
}
6 changes: 4 additions & 2 deletions src/pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@ export const authOptions: NextAuthOptions = {
async signIn({ user }) {
if (user.email) {
const isUserinDB = await persistentUserInstance.isUserInDatabase(user.email)
console.log(isUserinDB)
if(isUserinDB === false) {
const dummyUserData: UserData = {
email: user.email,
phoneNumber: "null",
phoneNumber: null,
firstName: user.name?.split(" ")[0] as string,
lastName: user.name?.split(" ")[1] as string,
dob: new Date(),
};
await persistentUserInstance.signUpProviderDetails(dummyUserData);
return '/auth-frontend/signUp'
}
else {
return true
return '/dashboard'
}
}
return true;
Expand Down
5 changes: 5 additions & 0 deletions src/pages/auth-frontend/signIn.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import SignInForm from "@/components/SignInForm";

export default function SignInPage(): JSX.Element {
return (<SignInForm></SignInForm>)
}
3 changes: 3 additions & 0 deletions src/pages/auth-frontend/signUp.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function SignInPage(): JSX.Element {
return (<>Sign Up Flow Here</>)
}
3 changes: 3 additions & 0 deletions src/pages/dashboard/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function SignInPage(): JSX.Element {
return (<>dashboard here</>)
}
11 changes: 6 additions & 5 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import SignUpBar from "@/components/SignUpBar";
import { signIn } from "next-auth/react";
import SignInPage from "./auth-frontend/signIn";
import { Button } from "@chakra-ui/react";

export default function Home() {
function button(text: string) {
Expand All @@ -9,16 +11,15 @@ export default function Home() {
</button>
);
}


return (
<main className="bg-black flex min-h-screen flex-col items-center justify-between p-12">
<h1>Home!</h1>
<div onClick={signIn} href={"/auth-frontend/signUp"}>
{button("Sign Up")}
<div onClick={() => signIn("google")} >
{button("Sign In")}
</div>
<div onClick={signIn} href={"/auth-frontend/signIn"}>
{button("Sign In")}
<div onClick={() => signIn("google")} >
{ button("Sign Up") }
</div>
</main>
);
Expand Down
Loading