diff --git a/website/package.json b/website/package.json index abbe07bf..33ee6c7f 100644 --- a/website/package.json +++ b/website/package.json @@ -24,7 +24,8 @@ "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", - "eject": "react-scripts eject" + "eject": "react-scripts eject", + "prettier": "prettier ./src/**/*.{ts,tsx} --write" }, "eslintConfig": { "extends": "react-app" diff --git a/website/src/components/AddDevice.tsx b/website/src/components/AddDevice.tsx index aa54706a..3825739d 100644 --- a/website/src/components/AddDevice.tsx +++ b/website/src/components/AddDevice.tsx @@ -19,7 +19,6 @@ import { GetConnected } from './GetConnected'; import { IDevice, AppState } from '../Store'; class AddDevice extends React.Component { - state = { name: '', open: false, @@ -31,8 +30,8 @@ class AddDevice extends React.Component { onAdd = async (event: React.FormEvent) => { event.preventDefault(); const keypair = box_keyPair(); - const b64PublicKey = window.btoa(String.fromCharCode(...new Uint8Array(keypair.publicKey) as any)); - const b64PrivateKey = window.btoa(String.fromCharCode(...new Uint8Array(keypair.secretKey) as any)); + const b64PublicKey = window.btoa(String.fromCharCode(...(new Uint8Array(keypair.publicKey) as any))); + const b64PrivateKey = window.btoa(String.fromCharCode(...(new Uint8Array(keypair.secretKey) as any))); const res = await fetch('/api/devices', { method: 'POST', @@ -45,7 +44,7 @@ class AddDevice extends React.Component { this.setState({ error: await res.text() }); return; } - const { device } = await res.json() as { device: IDevice }; + const { device } = (await res.json()) as { device: IDevice }; AppState.devices.push(device); @@ -66,47 +65,32 @@ class AddDevice extends React.Component { qrCodeUri: await qrcode.toDataURL(configFile), configFileUri: URL.createObjectURL(new Blob([configFile])), }); - } + }; render() { return (
- + this.setState({ name: event.currentTarget.value })} + onChange={event => this.setState({ name: event.currentTarget.value })} style={{ marginTop: -20, marginBottom: 8 }} fullWidth /> {this.state.error !== '' && {this.state.error}} - - + Get Connected - + { anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }} transformOrigin={{ vertical: 'top', horizontal: 'center' }} > -
- {this.props.children} -
+
{this.props.children}
- ) + ); } }