mirror of
https://github.com/Paris-est-Ludique/intranet.git
synced 2025-06-08 08:34:20 +02:00
add login route and login form
This commit is contained in:
parent
b906f80d4e
commit
7ecb2e70a1
@ -49,6 +49,7 @@ module.exports = {
|
||||
"@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
|
||||
"testing-library/no-node-access": "off",
|
||||
"testing-library/render-result-naming-convention": "off",
|
||||
"jsx-a11y/label-has-associated-control": "off",
|
||||
},
|
||||
globals: {
|
||||
__CLIENT__: true,
|
||||
|
46
src/pages/Login/Login.tsx
Normal file
46
src/pages/Login/Login.tsx
Normal file
@ -0,0 +1,46 @@
|
||||
import { RouteComponentProps } from "react-router-dom"
|
||||
import React, { memo, useCallback } from "react"
|
||||
import { Helmet } from "react-helmet"
|
||||
import styles from "./styles.module.scss"
|
||||
|
||||
export type Props = RouteComponentProps
|
||||
|
||||
const Login: React.FC<Props> = (): JSX.Element => {
|
||||
const onSubmit = useCallback((event: React.SyntheticEvent): void => {
|
||||
event.preventDefault()
|
||||
const target = event.target as typeof event.target & {
|
||||
email: { value: string }
|
||||
password: { value: string }
|
||||
}
|
||||
const email = target.email.value
|
||||
const password = target.password.value
|
||||
|
||||
console.log("email and password checked", email, password)
|
||||
|
||||
// call service with email & password
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div className={styles.Login}>
|
||||
<Helmet title="Login" />
|
||||
<form onSubmit={onSubmit} className={styles.form}>
|
||||
<div className={styles.LoginIntro} key="login-intro">
|
||||
Connectez-vous pour accéder à votre espace.
|
||||
</div>
|
||||
<div className={styles.formLine} key="line-email">
|
||||
<label htmlFor="email">Email</label>
|
||||
<input type="email" id="email" />
|
||||
</div>
|
||||
<div className={styles.formLine} key="line-password">
|
||||
<label htmlFor="password">Mot de passe</label>
|
||||
<input type="password" id="password" />
|
||||
</div>
|
||||
<div className={styles.formButtons}>
|
||||
<button type="submit">Connexion</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default memo(Login)
|
14
src/pages/Login/index.tsx
Executable file
14
src/pages/Login/index.tsx
Executable file
@ -0,0 +1,14 @@
|
||||
import loadable from "@loadable/component"
|
||||
|
||||
import { Loading, ErrorBoundary } from "../../components"
|
||||
import { Props } from "./Login"
|
||||
|
||||
const Login = loadable(() => import("./Login"), {
|
||||
fallback: <Loading />,
|
||||
})
|
||||
|
||||
export default (props: Props): JSX.Element => (
|
||||
<ErrorBoundary>
|
||||
<Login {...props} />
|
||||
</ErrorBoundary>
|
||||
)
|
36
src/pages/Login/styles.module.scss
Executable file
36
src/pages/Login/styles.module.scss
Executable file
@ -0,0 +1,36 @@
|
||||
@import "../../theme/variables";
|
||||
@import "../../theme/mixins";
|
||||
|
||||
.Login {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-content: center;
|
||||
}
|
||||
|
||||
.form {
|
||||
@include page-content-wrapper;
|
||||
}
|
||||
|
||||
.LoginIntro {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.formLine {
|
||||
padding: 5px 0;
|
||||
|
||||
label {
|
||||
display: block;
|
||||
margin-left: 5px;
|
||||
}
|
||||
input {
|
||||
width: 100%;
|
||||
border: 1px solid #333;
|
||||
border-radius: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.formButtons {
|
||||
margin-top: 10px;
|
||||
padding: 5px 0;
|
||||
text-align: center;
|
||||
}
|
@ -3,6 +3,7 @@ import { RouteConfig } from "react-router-config"
|
||||
import App from "../app"
|
||||
import AsyncHome, { loadData as loadHomeData } from "../pages/Home"
|
||||
import AsyncMembrePage, { loadData as loadMembrePageData } from "../pages/MembrePage"
|
||||
import Login from "../pages/Login"
|
||||
import NotFound from "../pages/NotFound"
|
||||
|
||||
export default [
|
||||
@ -20,6 +21,10 @@ export default [
|
||||
component: AsyncMembrePage,
|
||||
loadData: loadMembrePageData,
|
||||
},
|
||||
{
|
||||
path: "/login",
|
||||
component: Login,
|
||||
},
|
||||
{
|
||||
component: NotFound,
|
||||
},
|
||||
|
@ -1,5 +1,20 @@
|
||||
@import "./variables";
|
||||
|
||||
@mixin desktop {
|
||||
@media (min-width: 800px) {
|
||||
@content;
|
||||
}
|
||||
}
|
||||
|
||||
@mixin page-content-wrapper {
|
||||
margin: 10px;
|
||||
padding: 10px;
|
||||
background-color: $color-white;
|
||||
border-radius: 15px;
|
||||
border: $border-large;
|
||||
|
||||
@include desktop {
|
||||
padding: 20px;
|
||||
width: 400px;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user