2021-05-12 02:10:36 +00:00
|
|
|
import React, { useContext } from "react"
|
|
|
|
import { faStar, faTrash, faUser } from "@fortawesome/free-solid-svg-icons"
|
2021-05-18 00:04:06 +00:00
|
|
|
import ContextLanguage from "../../contexts/ContextLanguage"
|
2021-05-18 15:51:36 +00:00
|
|
|
import SummaryBase from "../base/summary/SummaryBase"
|
|
|
|
import SummaryLeft from "../base/summary/SummaryLeft"
|
|
|
|
import SummaryLabels from "../base/summary/SummaryLabels"
|
|
|
|
import SummaryButton from "../base/summary/SummaryButton"
|
|
|
|
import SummaryRight from "../base/summary/SummaryRight"
|
2021-05-12 02:10:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
export default function SummaryUser({ user, destroyUser, running, ...props }) {
|
2021-05-18 00:48:34 +00:00
|
|
|
const { strings } = useContext(ContextLanguage)
|
2021-05-12 02:10:36 +00:00
|
|
|
|
|
|
|
return (
|
2021-05-18 17:15:53 +00:00
|
|
|
<SummaryBase {...props}>
|
2021-05-18 15:51:36 +00:00
|
|
|
<SummaryLeft
|
|
|
|
icon={user.isAdmin ? faStar : faUser}
|
|
|
|
title={user.username}
|
|
|
|
subtitle={user.email}
|
|
|
|
/>
|
|
|
|
<SummaryLabels
|
|
|
|
upperLabel={strings.type}
|
|
|
|
upperValue={user.isAdmin ? strings.admin : strings.user}
|
|
|
|
/>
|
2021-05-20 10:16:01 +00:00
|
|
|
<SummaryButton
|
|
|
|
color={"Red"}
|
|
|
|
icon={faTrash}
|
|
|
|
onClick={async event => {
|
|
|
|
event.stopPropagation()
|
|
|
|
// TODO: Errors are not caught here. Where should they be displayed?
|
|
|
|
await destroyUser(user["email"])
|
|
|
|
}}
|
|
|
|
disabled={running}
|
|
|
|
>
|
|
|
|
{strings.delete}
|
|
|
|
</SummaryButton>
|
2021-05-18 15:51:36 +00:00
|
|
|
<SummaryRight/>
|
|
|
|
</SummaryBase>
|
2021-05-12 02:10:36 +00:00
|
|
|
)
|
|
|
|
}
|