1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-26 23:14:19 +00:00
pds-2021-g2-nest/code/frontend/src/components/interactive/LoggedInUser.js
Stefano Pigozzi 809d86758c
🧹 Reformat code
2021-05-11 16:37:15 +02:00

30 lines
736 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"
/**
* 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}>
Not logged in
</i>
)
}
return (
<b {...props}>
<FontAwesomeIcon icon={faUser}/> {user.username}
</b>
)
}