mirror of
https://github.com/Steffo99/sophon.git
synced 2024-12-23 07:14:21 +00:00
33 lines
1 KiB
TypeScript
33 lines
1 KiB
TypeScript
import {faTrash} from "@fortawesome/free-solid-svg-icons"
|
|
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
|
|
import * as React from "react"
|
|
import {useAuthorizationContext} from "../../contexts/authorization"
|
|
import {ManagedResource} from "../../hooks/useManagedViewSet"
|
|
import {SophonResearchGroup} from "../../types/SophonTypes"
|
|
import {SafetyButton} from "../elements/SafetyButton"
|
|
|
|
|
|
export interface GroupDeleteButtonProps {
|
|
resource: ManagedResource<SophonResearchGroup>,
|
|
}
|
|
|
|
|
|
export function GroupDeleteButton({resource}: GroupDeleteButtonProps): JSX.Element | null {
|
|
const authorization = useAuthorizationContext()
|
|
|
|
if(!authorization) {
|
|
return null
|
|
}
|
|
if(!authorization.state.user) {
|
|
return null
|
|
}
|
|
if(resource.value.owner !== authorization.state.user.id) {
|
|
return null
|
|
}
|
|
|
|
return (
|
|
<SafetyButton timeout={3} onClick={() => resource.destroy()}>
|
|
<FontAwesomeIcon icon={faTrash} pulse={resource.busy}/> Delete
|
|
</SafetyButton>
|
|
)
|
|
}
|