2021-10-07 00:36:49 +00:00
|
|
|
import {faEnvelope, faGlobe} from "@fortawesome/free-solid-svg-icons"
|
|
|
|
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
|
|
|
|
import * as React from "react"
|
|
|
|
import {ManagedResource} from "../../hooks/useManagedViewSet"
|
|
|
|
import {SophonResearchGroup} from "../../types/SophonTypes"
|
|
|
|
import {Link} from "../elements/Link"
|
|
|
|
import {ResourcePanel} from "../elements/ResourcePanel"
|
2021-10-11 17:13:32 +00:00
|
|
|
import {GroupDeleteButton} from "./GroupDeleteButton"
|
2021-10-10 15:02:48 +00:00
|
|
|
import {GroupJoinButton} from "./GroupJoinButton"
|
|
|
|
import {GroupLeaveButton} from "./GroupLeaveButton"
|
2021-10-07 00:36:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
export interface GroupResourcePanelProps {
|
|
|
|
resource: ManagedResource<SophonResearchGroup>,
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function GroupResourcePanel({resource}: GroupResourcePanelProps): JSX.Element {
|
|
|
|
const icon = resource.value.access === "OPEN" ? faGlobe : faEnvelope
|
2021-10-11 16:53:28 +00:00
|
|
|
|
2021-10-12 00:26:27 +00:00
|
|
|
const trueMembers = [...new Set([resource.value.owner, ...resource.value.members])]
|
2021-10-07 00:36:49 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<ResourcePanel>
|
|
|
|
<ResourcePanel.Icon>
|
|
|
|
<FontAwesomeIcon icon={icon}/>
|
|
|
|
</ResourcePanel.Icon>
|
|
|
|
<ResourcePanel.Name>
|
|
|
|
<Link href={`g/${resource.value.slug}/`}>
|
|
|
|
{resource.value.name}
|
|
|
|
</Link>
|
|
|
|
</ResourcePanel.Name>
|
|
|
|
<ResourcePanel.Text>
|
2021-10-11 16:53:28 +00:00
|
|
|
{trueMembers.length} member{trueMembers.length !== 1 ? "s" : ""}
|
2021-10-07 00:36:49 +00:00
|
|
|
</ResourcePanel.Text>
|
|
|
|
<ResourcePanel.Buttons>
|
2021-10-10 15:02:48 +00:00
|
|
|
<GroupLeaveButton resource={resource}/>
|
|
|
|
<GroupJoinButton resource={resource}/>
|
2021-10-11 17:13:32 +00:00
|
|
|
<GroupDeleteButton resource={resource}/>
|
2021-10-07 00:36:49 +00:00
|
|
|
</ResourcePanel.Buttons>
|
|
|
|
</ResourcePanel>
|
|
|
|
)
|
|
|
|
}
|