network-resurrector-frontend/src/components/layout/Main.js

57 lines
1.3 KiB
JavaScript
Raw Normal View History

2020-12-19 04:22:38 +02:00
import React from "react";
import ApplicationStepper from "./stepper/ApplicationStepper";
import Switcher from "./Switcher";
import { makeStyles } from "@material-ui/core/styles";
2020-12-24 05:32:35 +02:00
import { useAuthorizationToken } from "../../hooks";
import LoginContainer from "../../features/login/components/LoginContainer";
2020-12-19 04:22:38 +02:00
const useStyles = makeStyles(() => ({
app: {
textAlign: "center",
backgroundColor: "#282c34",
minHeight: "100vh",
display: "flex",
flexDirection: "column"
},
content: {
minHeight: "80vh",
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
fontSize: "calc(10px + 2vmin)",
color: "white"
2020-12-24 05:32:35 +02:00
},
appLoginOnly: {
textAlign: "center",
backgroundColor: "#282c34",
minHeight: "100vh",
display: "flex",
flexDirection: "column",
justifyContent: "center"
2020-12-19 04:22:38 +02:00
}
}));
const Main = () => {
const classes = useStyles();
2020-12-24 05:32:35 +02:00
const { tokenIsValid } = useAuthorizationToken();
const _tokenIsValid = tokenIsValid();
2020-12-19 04:22:38 +02:00
return (
2020-12-24 05:32:35 +02:00
<div className={_tokenIsValid ? classes.app : classes.appLoginOnly}>
{_tokenIsValid ? (
<>
<ApplicationStepper />
<div className={classes.content}>
<Switcher />
</div>
</>
) : (
<LoginContainer />
)}
2020-12-19 04:22:38 +02:00
</div>
);
};
export default Main;