pleroma/app/soapbox/hooks/api/groups/useCancelMembershipRequest.ts
2023-04-03 15:19:10 -05:00

21 lines
631 B
TypeScript

import { Entities } from 'soapbox/entity-store/entities';
import { useEntityActions } from 'soapbox/entity-store/hooks';
import { useOwnAccount } from 'soapbox/hooks';
import type { Group, GroupRelationship } from 'soapbox/schemas';
function useCancelMembershipRequest(group: Group) {
const me = useOwnAccount();
const { createEntity, isSubmitting } = useEntityActions<GroupRelationship>(
[Entities.GROUP_RELATIONSHIPS, group.id],
{ post: `/api/v1/groups/${group.id}/membership_requests/${me?.id}/reject` },
);
return {
mutate: createEntity,
isSubmitting,
};
}
export { useCancelMembershipRequest };