Commit ee01d354 by OuiAtichat

add Navbarcomponent

parent f467c56e
import React from 'react'; import React, { Component } from 'react';
import app from '../firebase'; import app from '../firebase';
import { Row, Col, Container } from 'react-bootstrap'; import { Row, Col, Container } from 'react-bootstrap';
import DataTable from '../components/DataTable'; import DataTable from '../components/DataTable';
import NavBar from '../components/NavBar';
// mock component // mock component
const Map = () => <Col>Map</Col>; const Map = () => <Col>Map</Col>;
...@@ -10,30 +11,44 @@ const RevenueChart = () => <Col>Revenue chart</Col>; ...@@ -10,30 +11,44 @@ const RevenueChart = () => <Col>Revenue chart</Col>;
const PeopleChart = () => <Col>People chart</Col>; const PeopleChart = () => <Col>People chart</Col>;
const RemoteChart = () => <Col>Remote chart</Col>; const RemoteChart = () => <Col>Remote chart</Col>;
const Home = () => { class Home extends Component {
const signOut = async () => { state = {
await app.auth().signOut(); currentUser: null,
}; };
return ( componentDidMount() {
<Container> this.getCurrentUser();
<h1>Home</h1> }
<button onClick={signOut}>signOut</button>
<Row> getCurrentUser = async () => {
<Map /> const { displayName, email } = await app.auth().currentUser;
</Row> this.setState({ currentUser: displayName || email });
<Row> };
<CurrentChart />
<RevenueChart /> render() {
</Row> const { currentUser } = this.state;
<Row>
<PeopleChart /> return (
<RemoteChart /> <>
</Row> <NavBar user={currentUser} />
<Row> <Container>
<DataTable /> <Row>
</Row> <Map />
</Container> </Row>
); <Row>
}; <CurrentChart />
<RevenueChart />
</Row>
<Row>
<PeopleChart />
<RemoteChart />
</Row>
<Row>
<DataTable />
</Row>
</Container>
</>
);
}
}
export default Home; export default Home;
import React from 'react'; import React from 'react';
import { Card, Form, Button, Container, Row } from 'react-bootstrap'; import { Card, Form, Button, Container } from 'react-bootstrap';
const LogInView = ({ onSubmit }) => { const LogInView = ({ onSubmit }) => {
return ( return (
<Container style={{ alignItems: 'center', paddingTop: '2em', maxWidth: '400px' }}> <Container style={{ alignItems: 'center', paddingTop: '2em', maxWidth: '400px' }}>
......
import React from 'react';
import { Navbar, Button } from 'react-bootstrap';
import app from '../firebase';
const NavbarComponent = ({ user }) => {
const signOut = async () => {
await app.auth().signOut();
};
return (
<Navbar style={{ backgroundColor: '#49b9ff' }}>
<Navbar.Brand style={{ color: '#fff' }}>ToiletCoin Dashboard</Navbar.Brand>
<Navbar.Toggle />
<Navbar.Collapse className="justify-content-end">
<Navbar.Text style={{ color: '#fff' }}>user: {user} </Navbar.Text>
<Button variant="link" onClick={signOut} style={{ color: '#fff' }}>
Log Out
</Button>
</Navbar.Collapse>
</Navbar>
);
};
export default NavbarComponent;
...@@ -6,4 +6,4 @@ import './styles.scss'; ...@@ -6,4 +6,4 @@ import './styles.scss';
ReactDOM.render(<App />, document.getElementById('root')); ReactDOM.render(<App />, document.getElementById('root'));
serviceWorker.unregister(); serviceWorker.register();
// Override default variables before the import // Override default variables before the import
// $body-bg: #000; // $body-bg: #000;
.body {
background: linear-gradient(45deg, #f7f7f7, #e3e3e3);
}
// Import Bootstrap and its default variables // Import Bootstrap and its default variables
@import '~bootstrap/scss/bootstrap.scss'; @import '~bootstrap/scss/bootstrap.scss';
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment