feat: updated the settings page design (#215)
This commit is contained in:
@@ -6,6 +6,7 @@ const useStyles = makeStyles((theme: Theme) =>
|
|||||||
createStyles({
|
createStyles({
|
||||||
action: {
|
action: {
|
||||||
marginTop: theme.spacing(0.75),
|
marginTop: theme.spacing(0.75),
|
||||||
|
marginBottom: theme.spacing(1),
|
||||||
marginRight: theme.spacing(1),
|
marginRight: theme.spacing(1),
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -1,69 +1,15 @@
|
|||||||
import { ReactElement, useState, useContext } from 'react'
|
import { ReactElement, useContext } from 'react'
|
||||||
import { makeStyles, createStyles, Theme } from '@material-ui/core/styles'
|
|
||||||
import { TextField, Typography, Button } from '@material-ui/core'
|
|
||||||
import { Context as SettingsContext } from '../../providers/Settings'
|
import { Context as SettingsContext } from '../../providers/Settings'
|
||||||
|
import ExpandableList from '../../components/ExpandableList'
|
||||||
const useStyles = makeStyles((theme: Theme) =>
|
import ExpandableListItemInput from '../../components/ExpandableListItemInput'
|
||||||
createStyles({
|
|
||||||
item: {
|
|
||||||
margin: 0,
|
|
||||||
marginTop: theme.spacing(4),
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
|
|
||||||
export default function Settings(): ReactElement {
|
export default function Settings(): ReactElement {
|
||||||
const classes = useStyles()
|
|
||||||
const { apiUrl, apiDebugUrl, setApiUrl, setDebugApiUrl } = useContext(SettingsContext)
|
const { apiUrl, apiDebugUrl, setApiUrl, setDebugApiUrl } = useContext(SettingsContext)
|
||||||
const [host, setHost] = useState(apiUrl)
|
|
||||||
const [debugHost, setDebugHost] = useState(apiDebugUrl)
|
|
||||||
|
|
||||||
const submit = () => {
|
|
||||||
if (host !== apiUrl) setApiUrl(host)
|
|
||||||
|
|
||||||
if (debugHost !== apiDebugUrl) setDebugApiUrl(debugHost)
|
|
||||||
}
|
|
||||||
|
|
||||||
const touched = host !== apiUrl || debugHost !== apiDebugUrl
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<ExpandableList label="API Settings" defaultOpen>
|
||||||
<Typography variant="h4" gutterBottom>
|
<ExpandableListItemInput label="Bee API" value={apiUrl} onConfirm={setApiUrl} />
|
||||||
Settings
|
<ExpandableListItemInput label="Bee Debug API" value={apiDebugUrl} onConfirm={setDebugApiUrl} />
|
||||||
</Typography>
|
</ExpandableList>
|
||||||
<TextField
|
|
||||||
label="API Endpoint"
|
|
||||||
className={classes.item}
|
|
||||||
placeholder="ex: 127.0.0.0.1:1633"
|
|
||||||
fullWidth
|
|
||||||
defaultValue={apiUrl}
|
|
||||||
margin="normal"
|
|
||||||
InputLabelProps={{
|
|
||||||
shrink: true,
|
|
||||||
}}
|
|
||||||
onChange={e => {
|
|
||||||
setHost(e.target.value)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<TextField
|
|
||||||
label="Debug API Endpoint"
|
|
||||||
className={classes.item}
|
|
||||||
placeholder="ex: 127.0.0.0.1:1635"
|
|
||||||
fullWidth
|
|
||||||
defaultValue={apiDebugUrl}
|
|
||||||
onChange={e => {
|
|
||||||
setDebugHost(e.target.value)
|
|
||||||
}}
|
|
||||||
margin="normal"
|
|
||||||
InputLabelProps={{
|
|
||||||
shrink: true,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
{touched && (
|
|
||||||
<Button variant="outlined" color="primary" className={classes.item} onClick={submit}>
|
|
||||||
Save
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user