From 981bbac7ff97127ae073fb410b52859fcc11b79b Mon Sep 17 00:00:00 2001 From: olekstomek Date: Tue, 27 Jul 2021 00:44:21 +0200 Subject: hide password option is possible when password has correct length for… (#103) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * hide password option is possible when password has correct length for WEP and WPA * refactor, logic is factored out into a function instead of in-lined in the markup * refactor of function because Sonar warning * improvement after code review - move function --- src/components/Card.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/components/Card.js') diff --git a/src/components/Card.js b/src/components/Card.js index ab0ec3f..4e7b0de 100644 --- a/src/components/Card.js +++ b/src/components/Card.js @@ -47,6 +47,18 @@ export const Card = ({ direction = 'ltr' }) => { } }; + const disableHidePassword = () => { + const isWEPWithPasswordLengthShorterThat5Characters = () => { + return network.encryptionMode === 'WEP' && network.password.length < 5 + ? true + : false; + }; + + return network.encryptionMode === 'WPA' && network.password.length < 8 + ? true + : isWEPWithPasswordLengthShorterThat5Characters(); + }; + useEffect(() => { if (firstLoad.current && window.innerWidth < 500) { firstLoad.current = false; @@ -134,6 +146,7 @@ export const Card = ({ direction = 'ltr' }) => { setNetwork({ -- cgit v1.2.3