Files
ncd-fe/packages/pl-fe/src/api/hooks/groups/useGroupRelationship.ts
marcin mikołajczak 2f7e149f75 pl-api: Mostly finish migration to valibot
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-10-16 01:08:56 +02:00

28 lines
722 B
TypeScript

import * as v from 'valibot';
import { Entities } from 'pl-fe/entity-store/entities';
import { useEntity } from 'pl-fe/entity-store/hooks';
import { useClient } from 'pl-fe/hooks';
import type { GroupRelationship } from 'pl-api';
const useGroupRelationship = (groupId: string | undefined) => {
const client = useClient();
const { entity: groupRelationship, ...result } = useEntity<GroupRelationship>(
[Entities.GROUP_RELATIONSHIPS, groupId!],
() => client.experimental.groups.getGroupRelationships([groupId!]),
{
enabled: !!groupId,
schema: v.pipe(v.any(), v.transform(arr => arr[0])),
},
);
return {
groupRelationship,
...result,
};
};
export { useGroupRelationship };