frontend: Hotfix inputState pour modifier profil
This commit is contained in:
parent
42672399ff
commit
84dae869ef
@ -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,16 +22,16 @@ 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 = {};
|
|
||||||
if (isAuth) {
|
|
||||||
defaultInputState = { name: user.name, email: user.email, biography: user.biography, isPublicEmail: user.isPublicEmail };
|
|
||||||
}
|
|
||||||
const [inputState, setInputState] = useState(defaultInputState);
|
|
||||||
|
|
||||||
const [message, setMessage] = useState("");
|
const [message, setMessage] = useState("");
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isAuth) {
|
||||||
|
setInputState({ name: user.name, email: user.email, biography: user.biography, isPublicEmail: user.isPublicEmail });
|
||||||
|
}
|
||||||
|
}, [isAuth]);
|
||||||
|
|
||||||
const toggleModal = () => setIsOpen(!isOpen);
|
const toggleModal = () => setIsOpen(!isOpen);
|
||||||
|
|
||||||
const handleChange = (event, isTypeCheck = false) => {
|
const handleChange = (event, isTypeCheck = false) => {
|
||||||
|
Reference in New Issue
Block a user