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