Skip to main content

useDeletePeople


Overview

useDeletePeople is a hook used to delete an existing member of a project.

Usage

const Component = () => {
const projectId = '662e760532df26ab0c1bf720'
const people = {
_id: '662e760532df26ab0c1bf72a',
role: ROLE.Admin
}

const { disableDelete, handleDeletePeople } = useDeletePeople()

return (
<Button
disableDelete={people.role}
onClick={() => handleDeletePeople({
projectId: projectId,
peopleId: people._id
})}
>
Delete People
</Button>
)
}

Parameters

No parameters are needed.

Returns

  • disableDelete: A function to determine if the user ( you ) has the role to delete other members in the project. This function takes the role of the user that will be deleted as a parameter.

  • handleDeletePeople: A function that will open up a delete confirmation modal. If the user confirms, proceed to execute a delete mutation function. This function takes projectId and peopleId as parameters.