diff options
| author | olekstomek <olekstomek@gmail.com> | 2021-07-27 00:44:21 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-26 15:44:21 -0700 |
| commit | 981bbac7ff97127ae073fb410b52859fcc11b79b (patch) | |
| tree | b567e7217f387cdb0bcd9895ef33b08b632d51a0 /src/components/Card.js | |
| parent | e688d6845bfb4bb825294e569545923988682f47 (diff) | |
hide password option is possible when password has correct length for… (#103)
* 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
Diffstat (limited to 'src/components/Card.js')
| -rw-r--r-- | src/components/Card.js | 13 |
1 files changed, 13 insertions, 0 deletions
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' }) => { | |||
| 47 | } | 47 | } |
| 48 | }; | 48 | }; |
| 49 | 49 | ||
| 50 | const disableHidePassword = () => { | ||
| 51 | const isWEPWithPasswordLengthShorterThat5Characters = () => { | ||
| 52 | return network.encryptionMode === 'WEP' && network.password.length < 5 | ||
| 53 | ? true | ||
| 54 | : false; | ||
| 55 | }; | ||
| 56 | |||
| 57 | return network.encryptionMode === 'WPA' && network.password.length < 8 | ||
| 58 | ? true | ||
| 59 | : isWEPWithPasswordLengthShorterThat5Characters(); | ||
| 60 | }; | ||
| 61 | |||
| 50 | useEffect(() => { | 62 | useEffect(() => { |
| 51 | if (firstLoad.current && window.innerWidth < 500) { | 63 | if (firstLoad.current && window.innerWidth < 500) { |
| 52 | firstLoad.current = false; | 64 | firstLoad.current = false; |
| @@ -134,6 +146,7 @@ export const Card = ({ direction = 'ltr' }) => { | |||
| 134 | <input | 146 | <input |
| 135 | type="checkbox" | 147 | type="checkbox" |
| 136 | id="hide-password-checkbox" | 148 | id="hide-password-checkbox" |
| 149 | disabled={disableHidePassword()} | ||
| 137 | className={network.encryptionMode === 'nopass' ? 'hidden' : ''} | 150 | className={network.encryptionMode === 'nopass' ? 'hidden' : ''} |
| 138 | onChange={() => | 151 | onChange={() => |
| 139 | setNetwork({ | 152 | setNetwork({ |
