mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-16 01:05:40 +00:00
Added pki collection table, pki alert modal
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
export {
|
||||
useCreatePkiCollection,
|
||||
useDeletePkiCollection,
|
||||
useUpdatePkiCollection} from "./mutations";
|
||||
export { useGetPkiCollectionById } from "./queries";
|
||||
@@ -0,0 +1,64 @@
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
import { apiRequest } from "@app/config/request";
|
||||
|
||||
import { workspaceKeys } from "../workspace/queries";
|
||||
// import { alertKeys } from "./queries";
|
||||
// import { TAlert, TCreateAlertDTO, TDeleteAlertDTO, TUpdateAlertDTO } from "./types";
|
||||
import { pkiCollectionKeys } from "./queries";
|
||||
import {
|
||||
TCreatePkiCollectionDTO,
|
||||
TDeletePkiCollectionDTO,
|
||||
TPkiCollection,
|
||||
TUpdatePkiCollectionTO} from "./types";
|
||||
|
||||
export const useCreatePkiCollection = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TPkiCollection, {}, TCreatePkiCollectionDTO>({
|
||||
mutationFn: async (body) => {
|
||||
const { data: pkiCollection } = await apiRequest.post<TPkiCollection>(
|
||||
"/api/v1/pki/collections",
|
||||
body
|
||||
);
|
||||
return pkiCollection;
|
||||
},
|
||||
onSuccess: (_, { projectId }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspacePkiCollections(projectId));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdatePkiCollection = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TPkiCollection, {}, TUpdatePkiCollectionTO>({
|
||||
mutationFn: async ({ collectionId, ...body }) => {
|
||||
const { data: pkiCollection } = await apiRequest.patch<TPkiCollection>(
|
||||
`/api/v1/pki/collections/${collectionId}`,
|
||||
body
|
||||
);
|
||||
return pkiCollection;
|
||||
},
|
||||
onSuccess: (_, { projectId, collectionId }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspacePkiCollections(projectId));
|
||||
queryClient.invalidateQueries(pkiCollectionKeys.getPkiCollectionById(collectionId));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useDeletePkiCollection = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TPkiCollection, {}, TDeletePkiCollectionDTO>({
|
||||
mutationFn: async ({ collectionId }) => {
|
||||
const { data: pkiCollection } = await apiRequest.delete<TPkiCollection>(
|
||||
`/api/v1/pki/collections/${collectionId}`
|
||||
);
|
||||
return pkiCollection;
|
||||
},
|
||||
onSuccess: (_, { projectId, collectionId }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspacePkiCollections(projectId));
|
||||
queryClient.invalidateQueries(pkiCollectionKeys.getPkiCollectionById(collectionId));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// TODO: add PKI Collection Item
|
||||
@@ -0,0 +1,22 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { apiRequest } from "@app/config/request";
|
||||
|
||||
import { TPkiCollection } from "./types";
|
||||
|
||||
export const pkiCollectionKeys = {
|
||||
getPkiCollectionById: (collectionId: string) => [{ collectionId }, "pki-collection"]
|
||||
};
|
||||
|
||||
export const useGetPkiCollectionById = (collectionId: string) => {
|
||||
return useQuery({
|
||||
queryKey: pkiCollectionKeys.getPkiCollectionById(collectionId),
|
||||
queryFn: async () => {
|
||||
const { data: pkiCollection } = await apiRequest.get<TPkiCollection>(
|
||||
`/api/v1/pki/collections/${collectionId}`
|
||||
);
|
||||
return pkiCollection;
|
||||
},
|
||||
enabled: Boolean(collectionId)
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
export type TPkiCollection = {
|
||||
id: string;
|
||||
name: string;
|
||||
projectId: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
};
|
||||
|
||||
export type TCreatePkiCollectionDTO = {
|
||||
projectId: string;
|
||||
name: string;
|
||||
};
|
||||
|
||||
export type TUpdatePkiCollectionTO = {
|
||||
collectionId: string;
|
||||
projectId: string;
|
||||
name?: string;
|
||||
};
|
||||
|
||||
export type TDeletePkiCollectionDTO = {
|
||||
collectionId: string;
|
||||
projectId: string;
|
||||
};
|
||||
Reference in New Issue
Block a user