bigbuffet-rw/app/soapbox/api/hooks/groups/useCancelMembershipRequest.ts

23 lines
632 B
TypeScript
Raw Normal View History

2023-03-20 10:27:22 -07:00
import { Entities } from 'soapbox/entity-store/entities';
import { useCreateEntity } from 'soapbox/entity-store/hooks';
import { useApi, useOwnAccount } from 'soapbox/hooks';
2023-03-20 10:27:22 -07:00
import type { Group } from 'soapbox/schemas';
2023-03-20 10:27:22 -07:00
function useCancelMembershipRequest(group: Group) {
const api = useApi();
2023-06-25 10:35:09 -07:00
const { account: me } = useOwnAccount();
2023-03-20 10:27:22 -07:00
const { createEntity, isSubmitting } = useCreateEntity(
[Entities.GROUP_RELATIONSHIPS],
() => api.post(`/api/v1/groups/${group.id}/membership_requests/${me?.id}/reject`),
2023-03-20 10:27:22 -07:00
);
return {
mutate: createEntity,
isSubmitting,
2023-03-20 10:27:22 -07:00
};
}
export { useCancelMembershipRequest };