Add login api

This commit is contained in:
pikiou
2022-01-03 17:55:47 +01:00
parent 4540e92171
commit 395955f32a
36 changed files with 340 additions and 437 deletions

View File

@@ -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>
)
}

View File

@@ -24,3 +24,7 @@
padding: 5px 0;
text-align: center;
}
.error {
color: rgb(255, 0, 0);
}

View File

@@ -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",
}}
/>

View File

@@ -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",
},

View File

@@ -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",
}}
/>

View File

@@ -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,