1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
import React from 'react';
import { PropTypes } from 'prop-types';
import { Helmet } from 'react-helmet';
import brand from 'ba-api/brand';
import SearchIcon from '@material-ui/icons/Search';
import SettingsIcon from '@material-ui/icons/SettingsApplications';
import { withStyles } from '@material-ui/core/styles';
import settingList from 'ba-api/settingList';
import { AppBar, Grid, Toolbar, Typography, Button, Icon } from '@material-ui/core';
import DetailSettings from './DetailSettings';
import styles from './settings-jss';
class Settings extends React.Component {
state = {
open: false,
checked: ['switch', 'check2'],
keyword: ''
};
handleToggle = value => () => {
const { checked } = this.state;
const currentIndex = checked.indexOf(value);
const newChecked = [...checked];
if (currentIndex === -1) {
newChecked.push(value);
} else {
newChecked.splice(currentIndex, 1);
}
this.setState({
checked: newChecked,
});
};
handleChange = name => event => {
this.setState({
[name]: event.target.value,
});
};
handleClickOpen = () => {
this.setState({ open: true });
};
handleClose = () => {
this.setState({ open: false });
};
handleSearch = event => {
this.setState({ keyword: event.target.value.toLowerCase() });
}
render() {
const title = brand.name;
const description = brand.desc;
const { classes } = this.props;
const { keyword } = this.state;
return (
<div>
<Helmet>
<title>{title}</title>
<meta name="description" content={description} />
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
<meta property="twitter:title" content={title} />
<meta property="twitter:description" content={description} />
</Helmet>
<Typography variant="h5" className={classes.title}>
<SettingsIcon className={classes.iconTitle} />
Appication Settings
</Typography>
<AppBar position="static" color="inherit" className={classes.searchSettings}>
<Toolbar>
<div className={classes.flex}>
<div className={classes.wrapper}>
<div className={classes.search}>
<SearchIcon />
</div>
<input className={classes.input} placeholder="Find a setting" onChange={(event) => this.handleSearch(event)} />
</div>
</div>
</Toolbar>
</AppBar>
<section className={classes.settingList}>
<Grid container spacing={2}>
{settingList.map(menu => {
const rawKey = menu.name + menu.caption;
if (rawKey.toLowerCase().indexOf(keyword) === -1) {
return false;
}
return (
<Grid item md={3} sm={4} xs={12} key={menu.name}>
<Button variant="outlined" onClick={this.handleClickOpen} color="secondary" className={classes.button}>
<Icon className={classes.icon}>{menu.icon}</Icon>
{menu.name}
<Typography variant="caption" noWrap className={classes.info}>
{menu.caption}
</Typography>
</Button>
</Grid>
);
})}
</Grid>
</section>
<DetailSettings open={this.state.open} handleClose={this.handleClose} />
</div>
);
}
}
Settings.propTypes = {
classes: PropTypes.object.isRequired,
};
export default withStyles(styles)(Settings);
|