mirror of
https://github.com/lemeow125/Ivy-Frontend.git
synced 2025-04-12 13:01:28 +08:00
34 lines
1 KiB
TypeScript
34 lines
1 KiB
TypeScript
import { useSelector } from "react-redux";
|
|
import { Button } from "@mui/material";
|
|
import styles from "../../styles";
|
|
import { useNavigate } from "react-router-dom";
|
|
import { LoggedInUserState } from "../../Interfaces/Interfaces";
|
|
import { LoginState } from "../../Interfaces/Interfaces";
|
|
|
|
export default function Login() {
|
|
const logged_in = useSelector((state: LoginState) => state.logged_in.value);
|
|
const logged_in_user = useSelector(
|
|
(state: LoggedInUserState) => state.logged_in_user.value
|
|
);
|
|
const navigate = useNavigate();
|
|
if (logged_in) {
|
|
return (
|
|
<p style={{ ...styles.text_white, ...styles.text_M }}>
|
|
Logged in as {logged_in_user.username}
|
|
</p>
|
|
);
|
|
} else {
|
|
return (
|
|
<div>
|
|
<Button
|
|
onClick={() => navigate("/Login")}
|
|
value="Login"
|
|
variant="contained"
|
|
style={styles.login_button}
|
|
>
|
|
<p style={{ ...styles.text, ...styles.text_M }}>Login</p>
|
|
</Button>
|
|
</div>
|
|
);
|
|
}
|
|
}
|