-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from LinumLabs/feature/rr/FAIR-85
Feature/rr/fair 85
- Loading branch information
Showing
15 changed files
with
251 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
type InputTypes = 'text' | 'password'; | ||
|
||
type Props = { | ||
type?: InputTypes; | ||
label?: string; | ||
placeholder?: string; | ||
}; | ||
|
||
const TextInput = ({ type = 'text', label, placeholder }: Props) => { | ||
return ( | ||
<div className="mb-8"> | ||
{!!label && <label className="block mb-3">{label}</label>} | ||
<input | ||
type={type} | ||
placeholder={placeholder} | ||
className="text-purple border-blue border-2 rounded-lg py-2.5 px-4 w-full md:w-1/3" | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default TextInput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@import 'styles/theme'; | ||
|
||
.root { | ||
@apply inline-block; | ||
@apply font-semibold; | ||
@apply text-2xl; | ||
@apply my-6; | ||
|
||
&:after { | ||
content: ''; | ||
width: 70%; | ||
border-bottom: 1px solid $color-purple; | ||
@apply inline-block; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { ReactNode } from 'react'; | ||
import classes from './Title.module.scss'; | ||
|
||
type Props = { | ||
children: ReactNode; | ||
}; | ||
|
||
const Title = ({ children }: Props) => { | ||
return <h1 className={`${classes.root} text-purple`}>{children}</h1>; | ||
}; | ||
|
||
export default Title; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
import { createContext, Dispatch, SetStateAction } from 'react'; | ||
|
||
export type ContextProps = { | ||
theme: string; | ||
setTheme?: Dispatch<SetStateAction<string>>; | ||
}; | ||
export interface ContextProps { | ||
sidebarVisible: boolean; | ||
setSidebarVisible: Dispatch<SetStateAction<boolean>>; | ||
} | ||
|
||
export const AppContext = createContext<ContextProps>({ | ||
theme: 'dark', | ||
}); | ||
export const AppContext = createContext<ContextProps>({} as ContextProps); | ||
|
||
export default AppContext.Provider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
import { createContext, Dispatch, SetStateAction } from 'react'; | ||
|
||
export type UserContextProps = { | ||
user: any; | ||
setUser?: Dispatch<SetStateAction<any>>; | ||
export type UserObject = { | ||
username: string; | ||
}; | ||
|
||
export const UserContext = createContext<UserContextProps>({ | ||
user: null, | ||
}); | ||
export interface UserContextProps { | ||
user: UserObject; | ||
setUser: Dispatch<SetStateAction<UserObject>>; | ||
logout: () => void; | ||
isAuthenticated: boolean; | ||
} | ||
|
||
export const UserContext = createContext<UserContextProps>( | ||
{} as UserContextProps | ||
); | ||
|
||
export default UserContext.Provider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import type { NextPage } from 'next'; | ||
import Layout from 'components/Layout'; | ||
import Title from 'components/Title'; | ||
import TextInput from 'components/TextInput'; | ||
import Button from 'components/Button'; | ||
import useUser from 'hooks/useUser'; | ||
import Router from 'next/router'; | ||
import { SyntheticEvent, useEffect } from 'react'; | ||
import useApp from 'hooks/useApp'; | ||
|
||
const Login: NextPage = () => { | ||
const { setUser, isAuthenticated } = useUser(); | ||
const { setSidebarVisible } = useApp(); | ||
|
||
useEffect(() => { | ||
if (isAuthenticated) { | ||
Router.push('/'); | ||
} | ||
}, [isAuthenticated]); | ||
|
||
const onSubmitHandler = (event: SyntheticEvent) => { | ||
event.preventDefault(); | ||
console.log('onSubmitHandler'); | ||
setSidebarVisible(true); | ||
setUser({ | ||
username: 'johndoe', | ||
}); | ||
Router.push('/'); | ||
}; | ||
|
||
return ( | ||
<Layout> | ||
<Title>Login page</Title> | ||
|
||
<form onSubmit={onSubmitHandler}> | ||
<TextInput placeholder="Username" /> | ||
<TextInput type="password" placeholder="Password" /> | ||
<Button type="submit" className="w-full md:w-1/3"> | ||
Login | ||
</Button> | ||
</form> | ||
</Layout> | ||
); | ||
}; | ||
|
||
export default Login; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { NextPage } from 'next'; | ||
import Layout from 'components/Layout'; | ||
import Title from 'components/Title'; | ||
import useUser from 'hooks/useUser'; | ||
import { useEffect } from 'react'; | ||
|
||
const Login: NextPage = () => { | ||
const { setUser } = useUser(); | ||
|
||
useEffect(() => { | ||
setUser(null); | ||
}, [setUser]); | ||
|
||
return ( | ||
<Layout> | ||
<Title>Logout page</Title> | ||
</Layout> | ||
); | ||
}; | ||
|
||
export default Login; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
$color-purple: #434d7e; | ||
$color-gray: #e2e8f8; | ||
$color-blue: #e2e8f8; |
Oops, something went wrong.