feat: switched audit log stream from project level to org level

This commit is contained in:
Akhil Mohan
2024-05-03 00:23:59 +05:30
parent fa18ca41ac
commit 68a1aa6f46
18 changed files with 92 additions and 147 deletions
@@ -21,8 +21,8 @@ export const useCreateAuditLogStream = () => {
);
return data;
},
onSuccess: (_, { projectSlug }) => {
queryClient.invalidateQueries(auditLogStreamKeys.list(projectSlug));
onSuccess: (_, { orgId }) => {
queryClient.invalidateQueries(auditLogStreamKeys.list(orgId));
}
});
};
@@ -38,8 +38,8 @@ export const useUpdateAuditLogStream = () => {
);
return data;
},
onSuccess: (_, { projectSlug }) => {
queryClient.invalidateQueries(auditLogStreamKeys.list(projectSlug));
onSuccess: (_, { orgId }) => {
queryClient.invalidateQueries(auditLogStreamKeys.list(orgId));
}
});
};
@@ -54,8 +54,8 @@ export const useDeleteAuditLogStream = () => {
);
return data;
},
onSuccess: (_, { projectSlug }) => {
queryClient.invalidateQueries(auditLogStreamKeys.list(projectSlug));
onSuccess: (_, { orgId }) => {
queryClient.invalidateQueries(auditLogStreamKeys.list(orgId));
}
});
};
@@ -5,28 +5,23 @@ import { apiRequest } from "@app/config/request";
import { TAuditLogStream } from "./types";
export const auditLogStreamKeys = {
list: (projectSlug: string) => ["audit-log-stream", { projectSlug }],
list: (orgId: string) => ["audit-log-stream", { orgId }],
getById: (id: string) => ["audit-log-stream-details", { id }]
};
const fetchAuditLogStreams = async (projectSlug: string) => {
const fetchAuditLogStreams = async () => {
const { data } = await apiRequest.get<{ auditLogStreams: TAuditLogStream[] }>(
"/api/v1/audit-log-streams",
{
params: {
projectSlug
}
}
"/api/v1/audit-log-streams"
);
return data.auditLogStreams;
};
export const useGetAuditLogStreams = (projectSlug: string) =>
export const useGetAuditLogStreams = (orgId: string) =>
useQuery({
queryKey: auditLogStreamKeys.list(projectSlug),
queryFn: () => fetchAuditLogStreams(projectSlug),
enabled: Boolean(projectSlug)
queryKey: auditLogStreamKeys.list(orgId),
queryFn: () => fetchAuditLogStreams(),
enabled: Boolean(orgId)
});
const fetchAuditLogStreamDetails = async (id: string) => {
@@ -5,19 +5,19 @@ export type TAuditLogStream = {
};
export type TCreateAuditLogStreamDTO = {
projectSlug: string;
url: string;
token?: string;
orgId: string;
};
export type TUpdateAuditLogStreamDTO = {
id: string;
projectSlug: string;
url?: string;
token?: string;
orgId: string;
};
export type TDeleteAuditLogStreamDTO = {
id: string;
projectSlug: string;
orgId: string;
};