1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-23 05:24:18 +00:00
pds-2021-g2-nest/nest_frontend/components/interactive/LoggedInUser.js
2021-05-18 00:22:11 +02:00

31 lines
795 B
JavaScript

import React, { useContext } from "react"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import { faUser } from "@fortawesome/free-solid-svg-icons"
import ContextUser from "../../contexts/ContextUser"
import Localization from "../../Localization"
/**
* An element displaying inline the currently logged in user.
*
* @param props - Additional props to pass to the element.
* @returns {JSX.Element}
* @constructor
*/
export default function LoggedInUser({ ...props }) {
const { user } = useContext(ContextUser)
if(!user) {
return (
<i {...props}>
{Localization.notLoggedIn}
</i>
)
}
return (
<b {...props}>
<FontAwesomeIcon icon={faUser}/> {user.username}
</b>
)
}