mirror of
https://github.com/Paris-est-Ludique/intranet.git
synced 2025-09-11 22:06:29 +02:00
Add login api
This commit is contained in:
@@ -1,20 +1,28 @@
|
||||
import React, { memo, useCallback } from "react"
|
||||
import styles from "./styles.module.scss"
|
||||
import { AppDispatch } from "../../store"
|
||||
import { fetchVolunteerLogin } from "../../store/volunteerLogin"
|
||||
|
||||
const LoginForm = (): 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
|
||||
interface Props {
|
||||
dispatch: AppDispatch
|
||||
error: string
|
||||
}
|
||||
|
||||
console.log("email and password checked", email, password)
|
||||
const LoginForm = ({ dispatch, error }: 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
|
||||
|
||||
// call service with email & password
|
||||
}, [])
|
||||
dispatch(fetchVolunteerLogin({ email, password }))
|
||||
},
|
||||
[dispatch]
|
||||
)
|
||||
|
||||
return (
|
||||
<form onSubmit={onSubmit}>
|
||||
@@ -23,15 +31,16 @@ const LoginForm = (): JSX.Element => {
|
||||
</div>
|
||||
<div className={styles.formLine} key="line-email">
|
||||
<label htmlFor="email">Email</label>
|
||||
<input type="email" id="email" />
|
||||
<input type="email" id="email" name="utilisateur" />
|
||||
</div>
|
||||
<div className={styles.formLine} key="line-password">
|
||||
<label htmlFor="password">Mot de passe</label>
|
||||
<input type="password" id="password" />
|
||||
<input type="password" id="password" name="motdepasse" />
|
||||
</div>
|
||||
<div className={styles.formButtons}>
|
||||
<button type="submit">Connexion</button>
|
||||
</div>
|
||||
<div className={styles.error}>{error}</div>
|
||||
</form>
|
||||
)
|
||||
}
|
||||
|
@@ -24,3 +24,7 @@
|
||||
padding: 5px 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.error {
|
||||
color: rgb(255, 0, 0);
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ describe("<VolunteerInfo />", () => {
|
||||
privileges: 0,
|
||||
active: 0,
|
||||
comment: "",
|
||||
timestamp: "0000-00-00",
|
||||
timestamp: new Date(0),
|
||||
password: "$2y$10$fSxY9AIuxSiEjwF.J3eXGubIxUPkdq9d5fqpbl8ASimSjNj4SR.9O",
|
||||
}}
|
||||
/>
|
||||
|
@@ -24,7 +24,7 @@ describe("<VolunteerList />", () => {
|
||||
privileges: 0,
|
||||
active: 0,
|
||||
comment: "",
|
||||
timestamp: "0000-00-00",
|
||||
timestamp: new Date(0),
|
||||
password:
|
||||
"$2y$10$fSxY9AIuxSiEjwF.J3eXGubIxUPkdq9d5fqpbl8ASimSjNj4SR.9O",
|
||||
},
|
||||
|
@@ -25,7 +25,7 @@ describe("<SetVolunteer />", () => {
|
||||
privileges: 0,
|
||||
active: 0,
|
||||
comment: "",
|
||||
timestamp: "0000-00-00",
|
||||
timestamp: new Date(0),
|
||||
password: "$2y$10$fSxY9AIuxSiEjwF.J3eXGubIxUPkdq9d5fqpbl8ASimSjNj4SR.9O",
|
||||
}}
|
||||
/>
|
||||
|
@@ -43,7 +43,7 @@ const WishAdd = ({ dispatch }: Props) => {
|
||||
setTeams([""])
|
||||
setAddedDate("")
|
||||
} else {
|
||||
toast.warning("Il faut au moins préciser un domain et l'wish", {
|
||||
toast.warning("Il faut au moins préciser un domaine et l'envie", {
|
||||
position: "top-center",
|
||||
autoClose: 6000,
|
||||
hideProgressBar: true,
|
||||
|
Reference in New Issue
Block a user