1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-30 00:14:19 +00:00
pds-2021-g2-nest/nest_frontend/components/interactive/BoxLoggedIn.js

43 lines
1.4 KiB
JavaScript
Raw Normal View History

import React, { useContext } from "react"
2021-04-29 14:58:31 +00:00
import BoxFull from "../base/BoxFull"
import LoggedInUser from "./LoggedInUser"
2021-04-29 14:58:31 +00:00
import Button from "../base/Button"
import { faSignOutAlt } from "@fortawesome/free-solid-svg-icons"
2021-04-29 14:58:31 +00:00
import ContextUser from "../../contexts/ContextUser"
import { useHistory } from "react-router"
import Style from "./BoxLoggedIn.module.css"
2021-04-26 16:36:41 +00:00
import CurrentServer from "./CurrentServer"
import useStrings from "../../hooks/useStrings"
2021-04-26 16:36:41 +00:00
/**
* A {@link BoxFull} displaying the user's current login status, and allowing them to logout.
*
2021-05-23 03:03:41 +00:00
* @param props - Additional props to pass to the box.
2021-04-26 16:36:41 +00:00
* @returns {JSX.Element}
* @constructor
*/
export default function BoxLoggedIn({ ...props }) {
2021-05-11 14:37:15 +00:00
const { logout } = useContext(ContextUser)
const history = useHistory()
const strings = useStrings()
return (
2021-05-18 00:04:06 +00:00
<BoxFull header={strings.loggedInTitle} {...props}>
<div className={Style.BoxLoggedInContents}>
<div>
2021-05-18 00:04:06 +00:00
{strings.loggedInOn} <CurrentServer/> {strings.loggedInAs} <LoggedInUser/>.
</div>
<div>
2021-05-11 14:37:15 +00:00
<Button
color={"Red"} onClick={() => {
logout()
history.push("/login")
2021-05-11 14:37:15 +00:00
}} icon={faSignOutAlt}
2021-05-18 00:04:06 +00:00
>{strings.logout}</Button>
</div>
</div>
</BoxFull>
)
}