Merge branch 'react-version' of https://github.com/MarcEricMartel/420-5DW-HY-TP into react-version

This commit is contained in:
Victor Turgeon
2022-11-06 13:15:39 -05:00
5 changed files with 49 additions and 7 deletions

View File

@@ -10,6 +10,7 @@ import { useCookies } from "react-cookie";
const Topbar = () => {
const [cookies, setCookie, removeCookie] = useCookies(['name']);
const [user, setLogin] = useState(null);
useEffect(() => {
async function reset() {
await setLogin(await cookies.GMGM ?? null);
@@ -22,9 +23,8 @@ const Topbar = () => {
method: 'POST',
credentials: 'include'
})
await removeCookie("GMGM");
await setLogin(null); // Y U NO WORK?!?
await removeCookie("GMGM");
await setLogin(null); // Y U NO WORK?!?
}
return (

View File

@@ -25,7 +25,17 @@ import { useForm } from "react-hook-form";
export default function App() {
const { register, handleSubmit, watch, formState: { errors } } = useForm();
const onSubmit = data => console.log(data);
const onSubmit = data => {
const response = fetch(`https://localhost:7292/api/User`, {
method: 'POST',
headers: {
'Accept': 'text/json',
'Content-Type': 'text/json'
},
body: JSON.stringify(data)
})
}
return (
<div className="inventaire-form-container">
<form onSubmit={handleSubmit(onSubmit)}>