37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
import React, { Component } from 'react';
|
|
import { Redirect, Switch, RouteComponentProps } from 'react-router-dom'
|
|
|
|
import { Tabs, Tab } from '@material-ui/core';
|
|
|
|
import { PROJECT_PATH } from '../api';
|
|
import { MenuAppBar } from '../components';
|
|
import { AuthenticatedRoute } from '../authentication';
|
|
import FanCtlControl from './FanCtlControl';
|
|
import FanCtlSettings from './FanCtlSettings';
|
|
|
|
class FanCtlProject extends Component<RouteComponentProps> {
|
|
|
|
handleTabChange = (event: React.ChangeEvent<{}>, path: string) => {
|
|
this.props.history.push(path);
|
|
};
|
|
|
|
render() {
|
|
return (
|
|
<MenuAppBar sectionTitle="Demo Project">
|
|
<Tabs value={this.props.match.url} onChange={this.handleTabChange} variant="fullWidth">
|
|
<Tab value={`/${PROJECT_PATH}/fanctl/control`} label="Control" />
|
|
<Tab value={`/${PROJECT_PATH}/fanctl/settings`} label="Settings" />
|
|
</Tabs>
|
|
<Switch>
|
|
<AuthenticatedRoute exact path={`/${PROJECT_PATH}/fanctl/control`} component={FanCtlControl} />
|
|
<AuthenticatedRoute exact path={`/${PROJECT_PATH}/fanctl/settings`} component={FanCtlSettings} />
|
|
<Redirect to={`/${PROJECT_PATH}/fanctl/control`} />
|
|
</Switch>
|
|
</MenuAppBar>
|
|
)
|
|
}
|
|
|
|
}
|
|
|
|
export default FanCtlProject;
|