mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 16:52:38 +00:00
feat: completed frontend
This commit is contained in:
@@ -54,6 +54,7 @@ export type TDynamicSecretProvider =
|
||||
revocationStatement: string;
|
||||
renewStatement?: string;
|
||||
ca?: string | undefined;
|
||||
gatewayId?: string;
|
||||
};
|
||||
}
|
||||
| {
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
export { useDeleteGateway } from "./mutation";
|
||||
export { useDeleteGatewayById, useUpdateGatewayById } from "./mutation";
|
||||
export { gatewaysQueryKeys } from "./queries";
|
||||
|
||||
@@ -3,15 +3,28 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { apiRequest } from "@app/config/request";
|
||||
|
||||
import { gatewaysQueryKeys } from "./queries";
|
||||
import { TUpdateGatewayDTO } from "./types";
|
||||
|
||||
export const useDeleteGateway = () => {
|
||||
export const useDeleteGatewayById = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (id: string) => {
|
||||
return apiRequest.delete(`/api/v1/gateways/${id}`);
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(gatewaysQueryKeys.list());
|
||||
queryClient.invalidateQueries(gatewaysQueryKeys.list({}));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdateGatewayById = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: ({ id, name }: TUpdateGatewayDTO) => {
|
||||
return apiRequest.patch(`/api/v1/gateways/${id}`, { name });
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(gatewaysQueryKeys.list({}));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -2,16 +2,22 @@ import { queryOptions } from "@tanstack/react-query";
|
||||
|
||||
import { apiRequest } from "@app/config/request";
|
||||
|
||||
import { TGateway } from "./types";
|
||||
import { TGateway, TListGatewayDTO } from "./types";
|
||||
|
||||
export const gatewaysQueryKeys = {
|
||||
allKey: () => ["gateways"],
|
||||
listKey: () => [...gatewaysQueryKeys.allKey(), "list"],
|
||||
list: () =>
|
||||
listKey: ({ projectId }: TListGatewayDTO) => [
|
||||
...gatewaysQueryKeys.allKey(),
|
||||
"list",
|
||||
{ projectId }
|
||||
],
|
||||
list: ({ projectId }: TListGatewayDTO = {}) =>
|
||||
queryOptions({
|
||||
queryKey: gatewaysQueryKeys.listKey(),
|
||||
queryKey: gatewaysQueryKeys.listKey({ projectId }),
|
||||
queryFn: async () => {
|
||||
const { data } = await apiRequest.get<{ gateways: TGateway[] }>("/api/v1/gateways");
|
||||
const { data } = await apiRequest.get<{ gateways: TGateway[] }>("/api/v1/gateways", {
|
||||
params: { projectId }
|
||||
});
|
||||
return data.gateways;
|
||||
}
|
||||
})
|
||||
|
||||
@@ -12,6 +12,15 @@ export type TGateway = {
|
||||
};
|
||||
};
|
||||
|
||||
export type TUpdateGatewayDTO = {
|
||||
id: string;
|
||||
name?: string;
|
||||
};
|
||||
|
||||
export type TDeleteGatewayDTO = {
|
||||
id: string;
|
||||
};
|
||||
|
||||
export type TListGatewayDTO = {
|
||||
projectId?: string;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user