pleroma/app/soapbox/hooks/api/useGroupMembers.ts

18 lines
538 B
TypeScript
Raw Normal View History

2023-03-13 06:47:23 -07:00
import { Entities } from 'soapbox/entity-store/entities';
import { useEntities } from 'soapbox/entity-store/hooks';
2023-03-13 12:08:02 -07:00
import { GroupMember, groupMemberSchema } from 'soapbox/schemas';
2023-03-13 06:47:23 -07:00
function useGroupMembers(groupId: string, role: string) {
const { entities, ...result } = useEntities<GroupMember>(
2023-03-13 12:08:02 -07:00
[Entities.GROUP_MEMBERSHIPS, groupId, role],
2023-03-14 09:55:42 -07:00
`/api/v1/groups/${groupId}/memberships?role=${role}`,
{ schema: groupMemberSchema },
2023-03-13 06:47:23 -07:00
);
return {
...result,
groupMembers: entities,
};
}
export { useGroupMembers };