1
1
import Head from "next/head" ;
2
- import React , { useContext } from "react" ;
2
+ import React , { useContext , useState } from "react" ;
3
3
import styles from "styles/Home.module.css" ;
4
4
import AppBar from "@material-ui/core/AppBar" ;
5
5
import Toolbar from "@material-ui/core/Toolbar" ;
6
6
import Typography from "@material-ui/core/Typography" ;
7
- import { InputBase } from "@material-ui/core" ;
7
+ import { Button , InputBase } from "@material-ui/core" ;
8
8
import { GlobalContextType , GlobalContext } from "services/GlobalContext" ;
9
9
import { sha256 } from "js-sha256" ;
10
+ import IconButton from "@material-ui/core/IconButton" ;
11
+ import HttpsRoundedIcon from "@material-ui/icons/HttpsRounded" ;
10
12
11
13
export const PageContainer : React . FunctionComponent = ( { children } ) => {
14
+ const [ url , setUrl ] = useState ( "" ) ;
15
+ const [ key , setKey ] = useState ( "" ) ;
12
16
const { setServerUrl, setServerKey } = useContext < GlobalContextType > (
13
17
GlobalContext
14
18
) ;
@@ -22,16 +26,24 @@ export const PageContainer: React.FunctionComponent = ({ children }) => {
22
26
< InputBase
23
27
autoFocus = { true }
24
28
placeholder = "Server URL"
25
- onChange = { ( event ) => setServerUrl ( event . target . value ) }
29
+ onChange = { ( event ) => setUrl ( event . target . value ) }
26
30
/>
27
31
</ div >
28
32
< div className = { styles . search } >
29
33
< InputBase
30
34
type = "password"
31
35
placeholder = "Password"
32
- onChange = { ( event ) => setServerKey ( sha256 ( event . target . value ) ) }
36
+ onChange = { ( event ) => setKey ( sha256 ( event . target . value ) ) }
33
37
/>
34
38
</ div >
39
+ < IconButton
40
+ onClick = { ( ) => {
41
+ setServerUrl ( url ) ;
42
+ setServerKey ( key ) ;
43
+ } }
44
+ >
45
+ < HttpsRoundedIcon />
46
+ </ IconButton >
35
47
</ Toolbar >
36
48
</ AppBar >
37
49
0 commit comments