Add support for Group tags
This commit is contained in:
20
app/soapbox/hooks/api/groups/useGroupTags.ts
Normal file
20
app/soapbox/hooks/api/groups/useGroupTags.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { Entities } from 'soapbox/entity-store/entities';
|
||||
import { useEntities } from 'soapbox/entity-store/hooks';
|
||||
import { groupTagSchema } from 'soapbox/schemas';
|
||||
|
||||
import type { GroupTag } from 'soapbox/schemas';
|
||||
|
||||
function useGroupTags(groupId: string) {
|
||||
const { entities, ...result } = useEntities<GroupTag>(
|
||||
[Entities.GROUP_TAGS, groupId],
|
||||
'/api/mock/groups/tags', // `api/v1/groups/${groupId}/tags`
|
||||
{ schema: groupTagSchema },
|
||||
);
|
||||
|
||||
return {
|
||||
...result,
|
||||
tags: entities,
|
||||
};
|
||||
}
|
||||
|
||||
export { useGroupTags };
|
||||
17
app/soapbox/hooks/api/groups/useUpdateGroupTag.ts
Normal file
17
app/soapbox/hooks/api/groups/useUpdateGroupTag.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { Entities } from 'soapbox/entity-store/entities';
|
||||
import { useEntityActions } from 'soapbox/entity-store/hooks';
|
||||
import { groupTagSchema } from 'soapbox/schemas';
|
||||
|
||||
import type { GroupTag } from 'soapbox/schemas';
|
||||
|
||||
function useUpdateGroupTag(groupId: string, tagId: string) {
|
||||
const { updateEntity } = useEntityActions<GroupTag>(
|
||||
[Entities.GROUP_TAGS, groupId, tagId],
|
||||
{ patch: `/api/mock/truth/groups/${groupId}/tags/${tagId}` },
|
||||
{ schema: groupTagSchema },
|
||||
);
|
||||
|
||||
return updateEntity;
|
||||
}
|
||||
|
||||
export { useUpdateGroupTag };
|
||||
Reference in New Issue
Block a user