@@ -6,8 +6,11 @@ import {
66 Stack ,
77 IStackTokens ,
88} from 'office-ui-fabric-react' ;
9+ import { remote } from 'electron' ;
910import routes from '../constants/routes.json' ;
1011
12+ const { dialog } = remote ;
13+
1114export interface IButtonExampleProps {
1215 // These are set based on the toggles shown above the examples (not needed in real code)
1316 disabled ?: boolean ;
@@ -18,12 +21,19 @@ export interface IButtonExampleProps {
1821const stackTokens : IStackTokens = { childrenGap : 40 } ;
1922
2023export default function Home ( ) : JSX . Element {
21- const [ state ] = useState < string > ( 'Hi' ) ;
24+ const [ state ] = useState < string > ( 'Please select backup directory' ) ;
25+ const [ directory , setDirectory ] = useState < string > ( 't' ) ;
2226
2327 const alertClicked = ( ) : void => {
2428 alert ( 'Clicked' ) ;
2529 } ;
26-
30+ const onButtonClick = ( ) => {
31+ const path = dialog . showOpenDialog ( {
32+ properties : [ 'openDirectory' ] ,
33+ } ) ;
34+ // eslint-disable-next-line promise/catch-or-return
35+ path . then ( ( res ) => setDirectory ( res . filePaths [ 0 ] ) ) ;
36+ } ;
2737 useEffect ( ( ) => {
2838 // axios
2939 // .get('http://localhost:5000')
@@ -36,16 +46,17 @@ export default function Home(): JSX.Element {
3646 < h2 > { state } </ h2 >
3747 < Stack horizontal tokens = { stackTokens } >
3848 < DefaultButton
39- text = "Standard "
40- onClick = { alertClicked }
49+ text = "Directory "
50+ onClick = { onButtonClick }
4151 allowDisabledFocus
4252 />
4353 < PrimaryButton
44- text = "Primary "
54+ text = "BACKUP "
4555 onClick = { alertClicked }
4656 allowDisabledFocus
4757 />
4858 </ Stack >
59+ < div > { directory } </ div >
4960 < Link to = { routes . COUNTER } > counter</ Link >
5061 </ div >
5162 ) ;
0 commit comments