feat: completed query hooks for identities

This commit is contained in:
=
2025-11-13 12:52:38 +05:30
parent d980029832
commit 1fe635678e
8 changed files with 331 additions and 0 deletions
@@ -0,0 +1,44 @@
import { queryOptions } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import {
TGetProjectIdentityByIdDTO,
TListProjectIdentitiesDTO,
TProjectIdentity
} from "./types";
export const projectIdentityQuery = {
allKey: () => ["project-identities"] as const,
getByIdKey: (params: TGetProjectIdentityByIdDTO) =>
[...projectIdentityQuery.allKey(), "by-id", params] as const,
listKey: (params: TListProjectIdentitiesDTO) =>
[...projectIdentityQuery.allKey(), "list", params] as const,
getById: (params: TGetProjectIdentityByIdDTO) =>
queryOptions({
queryKey: projectIdentityQuery.getByIdKey(params),
queryFn: async () => {
const { data } = await apiRequest.get<{ identity: TProjectIdentity }>(
`/api/v1/projects/${params.projectId}/identities/${params.identityId}`
);
return data.identity;
}
}),
list: (params: TListProjectIdentitiesDTO) =>
queryOptions({
queryKey: projectIdentityQuery.listKey(params),
queryFn: async () => {
const { data } = await apiRequest.get<{
identities: TProjectIdentity[];
totalCount: number;
}>(`/api/v1/projects/${params.projectId}/identities`, {
params: {
offset: params.offset,
limit: params.limit,
search: params.search
}
});
return data;
}
})
};