From 9e76afd90b8b5e07872dc3a58059d8bb76b89518 Mon Sep 17 00:00:00 2001 From: Lebret Audrey Date: Mon, 16 Jan 2023 15:16:55 +0100 Subject: [PATCH] =?UTF-8?q?fix(ressources):=20validit=C3=A9=20des=20inputs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/ressources.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/pages/ressources.js b/src/pages/ressources.js index 1e8a17f..9fe8170 100644 --- a/src/pages/ressources.js +++ b/src/pages/ressources.js @@ -75,12 +75,14 @@ export default function Ressources() { const [phoneNumberValue, setPhoneNumberValue] = useState(""); const handleValidEmail = (event) => { - setEmailValid(event.currentTarget.validity.valid) - setEmailValue(event.currentTarget.value) + const emailTarger = event.currentTarget + setEmailValid(emailTarger.validity.valid && emailTarger.value.length > 0) + setEmailValue(emailTarger.value) } const handleValidPhone = (event) => { - setPhoneNumberValid(event.currentTarget.validity.valid) - setPhoneNumberValue(event.currentTarget.value) + const phoneTarger = event.currentTarget + setPhoneNumberValid(phoneTarger.validity.valid && phoneTarger.value.length > 0) + setPhoneNumberValue(phoneTarger.value) } useEffect(() => { @@ -89,7 +91,7 @@ export default function Ressources() { const [sendEmailContactQuery] = useMutation(EPDS_CONTACT_INFORMATION, { client: client, - onCompleted: (data) => { + onCompleted: () => { setSendingMessage("La demande a été envoyée") setLoading(false) saveContactRequest()