62 lines
1.4 KiB
JavaScript
Raw Normal View History

2020-12-24 03:21:18 +03:30
import React, {useState} from "react";
import {
BrowserRouter as Router,
Switch,
Route,
Link
} from "react-router-dom";
2020-12-24 15:02:03 +03:30
import Button from '@material-ui/core/Button';
import TemporaryDrawer from "./components/TemporaryDrawer";
import NavBar from "./components/NavBar";
2020-12-24 16:23:42 +03:30
import ExtensionCard from "./components/ExtensionCard";
2020-12-24 15:02:03 +03:30
2020-12-24 03:21:18 +03:30
export default function App() {
return (
<Router>
2020-12-24 15:02:03 +03:30
{/*<TemporaryDrawer/>*/}
<NavBar/>
2020-12-24 03:21:18 +03:30
2020-12-24 15:02:03 +03:30
<Switch>
<Route path="/extensions">
<Extensions/>
</Route>
<Route path="/users">
<Users/>
</Route>
<Route path="/">
<Home/>
</Route>
</Switch>
2020-12-24 03:21:18 +03:30
</Router>
);
}
function Extensions() {
let mapped;
let [extensions, setExtensions] = useState([])
if (extensions.length === 0) {
mapped = <h3>wait</h3>;
fetch("http://127.0.0.1:4567/api/v1/extensions")
.then(response => response.json())
.then(data => setExtensions(data));
} else {
2020-12-24 16:23:42 +03:30
mapped = extensions.map(it => <ExtensionCard {...it} />);
2020-12-24 03:21:18 +03:30
}
return <h2>{mapped}</h2>;
}
function Home() {
2020-12-24 15:02:03 +03:30
return (
<Button variant="contained" color="primary">
Hello World
</Button>
)
}
2020-12-24 03:21:18 +03:30
function Users() {
return <h2>Users</h2>;
}