pl-fe: remove group normalizer

Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
nicole mikołajczyk
2025-10-27 11:51:30 +01:00
parent f50ac8d73e
commit 1fef71db0b
29 changed files with 34 additions and 64 deletions

View File

@ -1,17 +1,15 @@
import { Entities } from 'pl-fe/entity-store/entities';
import { useCreateEntity } from 'pl-fe/entity-store/hooks/use-create-entity';
import { useClient } from 'pl-fe/hooks/use-client';
import { normalizeGroup, type Group } from 'pl-fe/normalizers/group';
import type { Group as BaseGroup, CreateGroupParams } from 'pl-api';
import type { Group, CreateGroupParams } from 'pl-api';
const useCreateGroup = () => {
const client = useClient();
const { createEntity, ...rest } = useCreateEntity<BaseGroup, Group, CreateGroupParams>(
const { createEntity, ...rest } = useCreateEntity<Group, Group, CreateGroupParams>(
[Entities.GROUPS, 'search', ''],
(params: CreateGroupParams) => client.experimental.groups.createGroup(params),
{ transform: normalizeGroup },
);
return {

View File

@ -4,21 +4,19 @@ import { useHistory } from 'react-router-dom';
import { Entities } from 'pl-fe/entity-store/entities';
import { useEntity } from 'pl-fe/entity-store/hooks/use-entity';
import { useClient } from 'pl-fe/hooks/use-client';
import { normalizeGroup, type Group } from 'pl-fe/normalizers/group';
import { useGroupRelationship } from './use-group-relationship';
import type { Group as BaseGroup } from 'pl-api';
import type { Group } from 'pl-api';
const useGroup = (groupId: string, refetch = true) => {
const client = useClient();
const history = useHistory();
const { entity: group, isUnauthorized, ...result } = useEntity<BaseGroup, Group>(
const { entity: group, isUnauthorized, ...result } = useEntity<Group, Group>(
[Entities.GROUPS, groupId],
() => client.experimental.groups.getGroup(groupId),
{
transform: normalizeGroup,
refetch,
enabled: !!groupId,
},

View File

@ -2,20 +2,19 @@ import { Entities } from 'pl-fe/entity-store/entities';
import { useEntities } from 'pl-fe/entity-store/hooks/use-entities';
import { useClient } from 'pl-fe/hooks/use-client';
import { useFeatures } from 'pl-fe/hooks/use-features';
import { normalizeGroup, type Group } from 'pl-fe/normalizers/group';
import { useGroupRelationships } from './use-group-relationships';
import type { Group as BaseGroup } from 'pl-api';
import type { Group } from 'pl-api';
const useGroups = () => {
const client = useClient();
const features = useFeatures();
const { entities, ...result } = useEntities<BaseGroup, Group>(
const { entities, ...result } = useEntities<Group, Group>(
[Entities.GROUPS, 'search', ''],
() => client.experimental.groups.getGroups(),
{ enabled: features.groups, transform: normalizeGroup },
{ enabled: features.groups },
);
const { relationships } = useGroupRelationships(
['search', ''],

View File

@ -1,7 +1,6 @@
import { Entities } from 'pl-fe/entity-store/entities';
import { useCreateEntity } from 'pl-fe/entity-store/hooks/use-create-entity';
import { useClient } from 'pl-fe/hooks/use-client';
import { normalizeGroup } from 'pl-fe/normalizers/group';
interface UpdateGroupParams {
display_name?: string;
@ -18,7 +17,6 @@ const useUpdateGroup = (groupId: string) => {
const { createEntity, ...rest } = useCreateEntity(
[Entities.GROUPS],
(params: UpdateGroupParams) => client.experimental.groups.updateGroup(groupId, params),
{ transform: normalizeGroup },
);
return {