useGroupMembershipRequests: use useDismissEntity hooks
This commit is contained in:
parent
61fb434a54
commit
b47cdb368f
1 changed files with 9 additions and 6 deletions
|
@ -1,21 +1,24 @@
|
|||
import { Entities } from 'soapbox/entity-store/entities';
|
||||
import { useEntities } from 'soapbox/entity-store/hooks';
|
||||
import { useDismissEntity, useEntities } from 'soapbox/entity-store/hooks';
|
||||
import { useApi } from 'soapbox/hooks/useApi';
|
||||
import { accountSchema } from 'soapbox/schemas';
|
||||
|
||||
import type { ExpandedEntitiesPath } from 'soapbox/entity-store/hooks/types';
|
||||
|
||||
function useGroupMembershipRequests(groupId: string) {
|
||||
const api = useApi();
|
||||
const path: ExpandedEntitiesPath = [Entities.ACCOUNTS, 'membership_requests', groupId];
|
||||
|
||||
function authorize(accountId: string) {
|
||||
const authorize = useDismissEntity(path, (accountId) => {
|
||||
return api.post(`/api/v1/groups/${groupId}/membership_requests/${accountId}/authorize`);
|
||||
}
|
||||
});
|
||||
|
||||
function reject(accountId: string) {
|
||||
const reject = useDismissEntity(path, (accountId) => {
|
||||
return api.post(`/api/v1/groups/${groupId}/membership_requests/${accountId}/reject`);
|
||||
}
|
||||
});
|
||||
|
||||
const { entities, ...rest } = useEntities(
|
||||
[Entities.ACCOUNTS, 'membership_requests', groupId],
|
||||
path,
|
||||
`/api/v1/groups/${groupId}/membership_requests`,
|
||||
{ schema: accountSchema },
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue