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/LoggedInUser.js

26 lines
775 B
JavaScript
Raw Normal View History

import React, { useContext } from "react"
import Style from "./LoggedInUser.module.css"
import classNames from "classnames"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import { faUser } from "@fortawesome/free-solid-svg-icons"
import ContextLogin from "../contexts/ContextLogin"
export default function LoggedInUser({ children, className, ...props }) {
const {state} = useContext(ContextLogin);
if(!state) {
return (
<i className={classNames(Style.LoggedInUser, className)} {...props}>
Not logged in
</i>
)
}
return (
<b className={classNames(Style.LoggedInUser, className)} {...props}>
<FontAwesomeIcon icon={faUser}/> {state.username}
</b>
)
}