Move Group mutations to entities
This commit is contained in:
20
app/soapbox/hooks/api/groups/useJoinGroup.ts
Normal file
20
app/soapbox/hooks/api/groups/useJoinGroup.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Entities } from 'soapbox/entity-store/entities';
|
||||
import { useEntityActions } from 'soapbox/entity-store/hooks';
|
||||
import { groupRelationshipSchema } from 'soapbox/schemas';
|
||||
|
||||
import type { Group, GroupRelationship } from 'soapbox/schemas';
|
||||
|
||||
function useJoinGroup(group: Group) {
|
||||
const { createEntity, isLoading } = useEntityActions<GroupRelationship>(
|
||||
[Entities.GROUP_RELATIONSHIPS, group.id],
|
||||
{ post: `/api/v1/groups/${group.id}/join` },
|
||||
{ schema: groupRelationshipSchema },
|
||||
);
|
||||
|
||||
return {
|
||||
mutate: createEntity,
|
||||
isLoading,
|
||||
};
|
||||
}
|
||||
|
||||
export { useJoinGroup };
|
||||
Reference in New Issue
Block a user