diff options
Diffstat (limited to 'src/components/Card.js')
| -rw-r--r-- | src/components/Card.js | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/components/Card.js b/src/components/Card.js index 7409d6c..50db589 100644 --- a/src/components/Card.js +++ b/src/components/Card.js | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | import QRCode from 'qrcode.react'; | 1 | import QRCode from 'qrcode.react'; |
| 2 | import { useEffect, useRef, useState } from 'react'; | 2 | import { useEffect, useRef, useState } from 'react'; |
| 3 | import { useTranslation } from 'react-i18next'; | ||
| 3 | import './style.css'; | 4 | import './style.css'; |
| 4 | 5 | ||
| 5 | export const Card = () => { | 6 | export const Card = () => { |
| @@ -12,7 +13,7 @@ export const Card = () => { | |||
| 12 | hidePassword: false, | 13 | hidePassword: false, |
| 13 | }); | 14 | }); |
| 14 | const [portrait, setPortrait] = useState(false); | 15 | const [portrait, setPortrait] = useState(false); |
| 15 | 16 | const { t } = useTranslation(); | |
| 16 | const escape = (v) => { | 17 | const escape = (v) => { |
| 17 | const needsEscape = ['"', ';', ',', ':', '\\']; | 18 | const needsEscape = ['"', ';', ',', ':', '\\']; |
| 18 | 19 | ||
| @@ -31,17 +32,17 @@ export const Card = () => { | |||
| 31 | const onPrint = () => { | 32 | const onPrint = () => { |
| 32 | if (network.ssid.length > 0) { | 33 | if (network.ssid.length > 0) { |
| 33 | if (network.password.length < 8 && network.encryptionMode === 'WPA') { | 34 | if (network.password.length < 8 && network.encryptionMode === 'WPA') { |
| 34 | alert('Password must be at least 8 characters'); | 35 | alert(t('wifi.alert.password.8')); |
| 35 | } else if ( | 36 | } else if ( |
| 36 | network.password.length < 5 && | 37 | network.password.length < 5 && |
| 37 | network.encryptionMode === 'WEP' | 38 | network.encryptionMode === 'WEP' |
| 38 | ) { | 39 | ) { |
| 39 | alert('Password must be at least 5 characters'); | 40 | alert(t('wifi.alert.password.5')); |
| 40 | } else { | 41 | } else { |
| 41 | window.print(); | 42 | window.print(); |
| 42 | } | 43 | } |
| 43 | } else { | 44 | } else { |
| 44 | alert('Network name cannot be empty'); | 45 | alert(t('wifi.alert.name')); |
| 45 | } | 46 | } |
| 46 | }; | 47 | }; |
| 47 | 48 | ||
| @@ -62,7 +63,9 @@ export const Card = () => { | |||
| 62 | id="print-area" | 63 | id="print-area" |
| 63 | style={{ maxWidth: portrait ? '350px' : '100%' }} | 64 | style={{ maxWidth: portrait ? '350px' : '100%' }} |
| 64 | > | 65 | > |
| 65 | <h1 style={{ textAlign: portrait ? 'center' : 'left' }}>WiFi Login</h1> | 66 | <h1 style={{ textAlign: portrait ? 'center' : 'left' }}> |
| 67 | {t('wifi.login')} | ||
| 68 | </h1> | ||
| 66 | 69 | ||
| 67 | <div | 70 | <div |
| 68 | className="details" | 71 | className="details" |
| @@ -76,12 +79,12 @@ export const Card = () => { | |||
| 76 | /> | 79 | /> |
| 77 | 80 | ||
| 78 | <div className="inputs"> | 81 | <div className="inputs"> |
| 79 | <label>Network name</label> | 82 | <label>{t('wifi.name')}</label> |
| 80 | <textarea | 83 | <textarea |
| 81 | id="ssid" | 84 | id="ssid" |
| 82 | type="text" | 85 | type="text" |
| 83 | maxLength="32" | 86 | maxLength="32" |
| 84 | placeholder="WiFi Network name" | 87 | placeholder={t('wifi.name.placeholder')} |
| 85 | autoComplete="off" | 88 | autoComplete="off" |
| 86 | autoCorrect="off" | 89 | autoCorrect="off" |
| 87 | autoCapitalize="none" | 90 | autoCapitalize="none" |
| @@ -95,7 +98,7 @@ export const Card = () => { | |||
| 95 | ${network.encryptionMode === 'nopass' && 'hidden'} | 98 | ${network.encryptionMode === 'nopass' && 'hidden'} |
| 96 | `} | 99 | `} |
| 97 | > | 100 | > |
| 98 | Password | 101 | {t('wifi.password')} |
| 99 | </label> | 102 | </label> |
| 100 | <textarea | 103 | <textarea |
| 101 | id="password" | 104 | id="password" |
| @@ -109,7 +112,7 @@ export const Card = () => { | |||
| 109 | portrait && network.password.length > 40 ? '5em' : 'auto', | 112 | portrait && network.password.length > 40 ? '5em' : 'auto', |
| 110 | }} | 113 | }} |
| 111 | maxLength="63" | 114 | maxLength="63" |
| 112 | placeholder="Password" | 115 | placeholder={t('wifi.password.placeholder')} |
| 113 | autoComplete="off" | 116 | autoComplete="off" |
| 114 | autoCorrect="off" | 117 | autoCorrect="off" |
| 115 | autoCapitalize="none" | 118 | autoCapitalize="none" |
| @@ -136,12 +139,12 @@ export const Card = () => { | |||
| 136 | for="hide-password-checkbox" | 139 | for="hide-password-checkbox" |
| 137 | className={network.encryptionMode === 'nopass' ? 'hidden' : ''} | 140 | className={network.encryptionMode === 'nopass' ? 'hidden' : ''} |
| 138 | > | 141 | > |
| 139 | Hide password | 142 | {t('wifi.password.hide')} |
| 140 | </label> | 143 | </label> |
| 141 | </div> | 144 | </div> |
| 142 | 145 | ||
| 143 | <div className="no-print"> | 146 | <div className="no-print"> |
| 144 | <label>Encryption:</label> | 147 | <label>{t('wifi.password.encryption')}:</label> |
| 145 | <input | 148 | <input |
| 146 | type="radio" | 149 | type="radio" |
| 147 | name="encrypt-select" | 150 | name="encrypt-select" |
| @@ -181,16 +184,16 @@ export const Card = () => { | |||
| 181 | <span role="img" aria-label="mobile-phone"> | 184 | <span role="img" aria-label="mobile-phone"> |
| 182 | πΈπ± | 185 | πΈπ± |
| 183 | </span> | 186 | </span> |
| 184 | Point your phone's camera at the QR Code to connect automatically | 187 | {t('wifi.tip')} |
| 185 | </p> | 188 | </p> |
| 186 | </fieldset> | 189 | </fieldset> |
| 187 | 190 | ||
| 188 | <div className="buttons"> | 191 | <div className="buttons"> |
| 189 | <button id="rotate" onClick={() => setPortrait(!portrait)}> | 192 | <button id="rotate" onClick={() => setPortrait(!portrait)}> |
| 190 | Rotate | 193 | {t('button.rotate')} |
| 191 | </button> | 194 | </button> |
| 192 | <button id="print" onClick={onPrint}> | 195 | <button id="print" onClick={onPrint}> |
| 193 | 196 | {t('button.print')} | |
| 194 | </button> | 197 | </button> |
| 195 | </div> | 198 | </div> |
| 196 | </div> | 199 | </div> |
