From 52ff61635b1cbd4b024ae882b606cfb64d6cc897 Mon Sep 17 00:00:00 2001 From: Ben Woodward Date: Sun, 4 Jul 2021 16:48:10 -0700 Subject: Prettier formatting (#33) * Add prettier * Format code --- src/components/Card.js | 56 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 18 deletions(-) (limited to 'src/components/Card.js') diff --git a/src/components/Card.js b/src/components/Card.js index 6c2c745..16f94a4 100644 --- a/src/components/Card.js +++ b/src/components/Card.js @@ -2,14 +2,16 @@ import React, { useState, useEffect } from 'react'; import QRCode from 'qrcode.react'; import './style.css'; -const Card = () => { - const [ssid, setSsid] = useState(''); - const [password, setPassword] = useState(''); +export const Card = () => { + const [network, setNetwork] = useState({ + ssid: '', + password: '', + }); const [qrvalue, setQrvalue] = useState(''); const escape = (v) => { const needsEscape = ['"', ';', ',', ':', '\\']; - + let escaped = ''; for (let i = 0; i < v.length; i++) { let c = v[i]; @@ -20,14 +22,13 @@ const Card = () => { } return escaped; - } + }; useEffect(() => { - let _ssid = escape(ssid), - _password = escape(password); - - setQrvalue(`WIFI:T:WPA;S:${_ssid};P:${_password};;`); - }, [ssid, password]); + const ssid = escape(network.ssid); + const password = escape(network.password); + setQrvalue(`WIFI:T:WPA;S:${ssid};P:${password};;`); + }, [network]); return (
@@ -35,26 +36,45 @@ const Card = () => {

WiFi Login

-
+
- setSsid(event.target.value)} /> + setNetwork({ ...network, ssid: e.target.value })} + /> - setPassword(event.target.value)} /> + + setNetwork({ ...network, password: e.target.value }) + } + />
-

πŸ“ΈπŸ“±Point your phone's camera at the QR Code to connect automatically

+

+ + πŸ“ΈπŸ“± + + Point your phone's camera at the QR Code to connect automatically +

- ) -} - -export default Card; + ); +}; -- cgit v1.2.3