Migrate to external library for interacting with API

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak
2024-08-06 19:52:36 +02:00
parent 3b87810f85
commit 32c68a9221
89 changed files with 364 additions and 710 deletions

View File

@ -1,8 +1,8 @@
import { serialize } from 'object-to-formdata';
import { useClient } from 'soapbox/hooks';
import { Entities } from 'soapbox/entity-store/entities';
import { useCreateEntity } from 'soapbox/entity-store/hooks';
import { useClient } from 'soapbox/hooks';
import { groupSchema } from 'soapbox/schemas';
interface CreateGroupParams {
@ -18,12 +18,11 @@ interface CreateGroupParams {
const useCreateGroup = () => {
const client = useClient();
const { createEntity, ...rest } = useCreateEntity([Entities.GROUPS, 'search', ''], (params: CreateGroupParams) =>
client.request('/api/v1/groups', {
method: 'POST',
contentType: '',
body: params,
}), { schema: groupSchema });
const { createEntity, ...rest } = useCreateEntity(
[Entities.GROUPS, 'search', ''],
(params: CreateGroupParams) => client.experimental.groups.createGroup(params),
{ schema: groupSchema },
);
return {
createGroup: createEntity,