From 64c374cb55a0edb3f442db7b053ff88b20591c77 Mon Sep 17 00:00:00 2001 From: Lvyshnevska Date: Thu, 9 May 2024 14:21:56 +0200 Subject: [PATCH] optional chaining --- .../src/components/ProfilePage/FormComponents/UserInfo.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/FrontEnd/src/components/ProfilePage/FormComponents/UserInfo.js b/FrontEnd/src/components/ProfilePage/FormComponents/UserInfo.js index 2eeaf420a..39ad2f792 100644 --- a/FrontEnd/src/components/ProfilePage/FormComponents/UserInfo.js +++ b/FrontEnd/src/components/ProfilePage/FormComponents/UserInfo.js @@ -79,7 +79,7 @@ const UserInfo = (props) => { })); }; - const errorsInNameSurname = formStateErr['name']['message'].length > 1 || formStateErr['surname']['message'].length > 1; + const errorsInNameSurname = formStateErr['name']['message']?.length > 1 || formStateErr['surname']['message']?.length > 1; const checkRequiredFields = () => { let isValid = true; @@ -100,10 +100,10 @@ const UserInfo = (props) => { } setFormStateErr({ ...formStateErr, ...newFormState }); - if (updateUser.name.length < 2 || updateUser.surname.length < 2) { + if (updateUser.name?.length < 2 || updateUser.surname?.length < 2) { isValid = false; } - if (updateProfile.person_position.length !== 0 && updateProfile.person_position.length < 2) { + if (updateProfile.person_position?.length !== 0 && updateProfile.person_position?.length < 2) { isValid = false; }