2023-03-20 10:27:22 -07:00
|
|
|
import { Entities } from 'soapbox/entity-store/entities';
|
2023-04-04 03:39:49 -07:00
|
|
|
import { useCreateEntity } from 'soapbox/entity-store/hooks';
|
|
|
|
import { useApi, useOwnAccount } from 'soapbox/hooks';
|
2023-03-20 10:27:22 -07:00
|
|
|
|
2023-04-04 03:39:49 -07:00
|
|
|
import type { Group } from 'soapbox/schemas';
|
2023-03-20 10:27:22 -07:00
|
|
|
|
|
|
|
function useCancelMembershipRequest(group: Group) {
|
2023-04-04 03:39:49 -07:00
|
|
|
const api = useApi();
|
2023-06-25 10:35:09 -07:00
|
|
|
const { account: me } = useOwnAccount();
|
2023-03-20 10:27:22 -07:00
|
|
|
|
2023-04-04 10:29:51 -07:00
|
|
|
const { createEntity, isSubmitting } = useCreateEntity(
|
2023-04-04 03:39:49 -07:00
|
|
|
[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,
|
2023-04-03 13:19:10 -07:00
|
|
|
isSubmitting,
|
2023-03-20 10:27:22 -07:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export { useCancelMembershipRequest };
|