From c6fb2f011505a3e1892e1fb24f4df850c55bb57d Mon Sep 17 00:00:00 2001 From: Lionel Karlen <45311125+LionelKarlen@users.noreply.github.com> Date: Thu, 15 Jul 2021 20:21:01 +0200 Subject: [PATCH] Add check for non-null network name (#52) --- src/components/Card.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/components/Card.js b/src/components/Card.js index 0011ca81..c301bbe6 100644 --- a/src/components/Card.js +++ b/src/components/Card.js @@ -29,15 +29,19 @@ export const Card = () => { }; const onPrint = () => { - if (network.password.length < 8 && network.encryptionMode === 'WPA') { - alert('Password must be at least 8 characters'); - } else if ( - network.password.length < 5 && - network.encryptionMode === 'WEP' - ) { - alert('Password must be at least 5 characters'); + if (network.ssid.length > 0) { + if (network.password.length < 8 && network.encryptionMode === 'WPA') { + alert('Password must be at least 8 characters'); + } else if ( + network.password.length < 5 && + network.encryptionMode === 'WEP' + ) { + alert('Password must be at least 5 characters'); + } else { + window.print(); + } } else { - window.print(); + alert('Network name cannot be empty'); } };