frontend: Hotfix inputState pour modifier profil

This commit is contained in:
Divlo 2020-04-09 11:32:33 +02:00
parent 42672399ff
commit 84dae869ef

View File

@ -1,5 +1,5 @@
import Link from 'next/link'; import Link from 'next/link';
import { Fragment, useContext, useState } from 'react'; import { Fragment, useContext, useState, useEffect } from 'react';
import { UserContext } from '../../contexts/UserContext'; import { UserContext } from '../../contexts/UserContext';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faPen, faTimes } from '@fortawesome/free-solid-svg-icons'; import { faPen, faTimes } from '@fortawesome/free-solid-svg-icons';
@ -22,15 +22,15 @@ const Profile = (props) => {
const { isAuth, user, logoutUser } = useContext(UserContext); const { isAuth, user, logoutUser } = useContext(UserContext);
const [isOpen, setIsOpen] = useState(false); const [isOpen, setIsOpen] = useState(false);
const [inputState, setInputState] = useState({});
let defaultInputState = {}; const [message, setMessage] = useState("");
if (isAuth) { const [isLoading, setIsLoading] = useState(false);
defaultInputState = { name: user.name, email: user.email, biography: user.biography, isPublicEmail: user.isPublicEmail };
} useEffect(() => {
const [inputState, setInputState] = useState(defaultInputState); if (isAuth) {
setInputState({ name: user.name, email: user.email, biography: user.biography, isPublicEmail: user.isPublicEmail });
const [message, setMessage] = useState(""); }
const [isLoading, setIsLoading] = useState(false); }, [isAuth]);
const toggleModal = () => setIsOpen(!isOpen); const toggleModal = () => setIsOpen(!isOpen);