refactor: squash commits

This commit is contained in:
dec0dOS 2021-03-21 22:25:13 +03:00
parent 63ebcb5915
commit 1e6e237aa3
107 changed files with 20077 additions and 0 deletions

View file

@ -0,0 +1,16 @@
import { useLocalStorage } from "react-use";
import HomeLoggedIn from "components/HomeLoggedIn";
import HomeLoggedOut from "components/HomeLoggedOut";
function Home() {
const [loggedIn] = useLocalStorage("loggedIn", false);
if (loggedIn) {
return <HomeLoggedIn />;
} else {
return <HomeLoggedOut />;
}
}
export default Home;

View file

@ -0,0 +1 @@
export { default } from "./Home";

View file

@ -0,0 +1,83 @@
import { useState, useEffect } from "react";
import { Link as RouterLink, useParams, useHistory } from "react-router-dom";
import { useLocalStorage } from "react-use";
import { Link, Grid, Typography } from "@material-ui/core";
import ArrowBackIcon from "@material-ui/icons/ArrowBack";
import useStyles from "./Network.styles";
import NetworkHeader from "components/NetworkHeader";
import NetworkSettings from "components/NetworkSettings";
import NetworkMembers from "components/NetworkMembers";
import NetworkRules from "components/NetworkRules";
import NetworkManagment from "components/NetworkManagment";
import API from "utils/API";
function Network() {
const { nwid } = useParams();
const [loggedIn] = useLocalStorage("loggedIn", false);
const [network, setNetwork] = useState({});
const classes = useStyles();
const history = useHistory();
useEffect(() => {
async function fetchData() {
try {
const network = await API.get("network/" + nwid);
setNetwork(network.data);
console.log("Current network:", network.data);
} catch (err) {
if (err.response.status === 404) {
history.push("/404");
}
console.error(err);
}
}
fetchData();
}, [nwid, history]);
if (loggedIn) {
return (
<>
<Link color="inherit" component={RouterLink} to="/" underline="none">
<ArrowBackIcon className={classes.backIcon}></ArrowBackIcon>
Networks
</Link>
<div className={classes.container}>
{network["config"] && (
<>
<NetworkHeader network={network} />
<NetworkSettings network={network} setNetwork={setNetwork} />
</>
)}
<NetworkMembers />
{network["config"] && <NetworkRules network={network} />}
<NetworkManagment />
</div>
</>
);
} else {
return (
<Grid
container
spacing={0}
direction="column"
alignItems="center"
justify="center"
style={{
minHeight: "50vh",
}}
>
<Grid item xs={10}>
<Typography variant="h5">
You are not authorized. Please Log In
</Typography>
</Grid>
</Grid>
);
}
}
export default Network;

View file

@ -0,0 +1,12 @@
import { makeStyles } from "@material-ui/core/styles";
const useStyles = makeStyles((theme) => ({
backIcon: {
fontSize: 12,
},
container: {
margin: "1%",
},
}));
export default useStyles;

View file

@ -0,0 +1 @@
export { default } from "./Network";

View file

@ -0,0 +1,28 @@
import { Grid, Typography } from "@material-ui/core";
function NotFound() {
return (
<Grid
container
spacing={0}
direction="column"
alignItems="center"
justify="center"
style={{
minHeight: "50vh",
}}
>
<Grid item xs={10}>
<Typography variant="h1">
<span>404</span>
</Typography>
<Typography variant="h4">
<span>Not found</span>
</Typography>
</Grid>
</Grid>
);
}
export default NotFound;

View file

@ -0,0 +1 @@
export { default } from "./NotFound";