feat: changed the whole api from projectid to slug

This commit is contained in:
Akhil Mohan
2024-03-22 14:18:12 +05:30
parent 70fe80414d
commit e3e62430ba
28 changed files with 357 additions and 165 deletions
@@ -5,26 +5,26 @@ import { apiRequest } from "@app/config/request";
import { TDynamicSecretLease, TListDynamicSecretLeaseDTO } from "./types";
export const dynamicSecretLeaseKeys = {
list: ({ projectId, environment, path, slug }: TListDynamicSecretLeaseDTO) =>
[{ projectId, environment, path, slug }, "dynamic-secret-leases"] as const
list: ({ projectSlug, environment, path, slug }: TListDynamicSecretLeaseDTO) =>
[{ projectSlug, environment, path, slug }, "dynamic-secret-leases"] as const
};
export const useGetDynamicSecretLeases = ({
projectId,
projectSlug,
environment,
path,
slug,
enabled = true
}: TListDynamicSecretLeaseDTO) => {
return useQuery({
queryKey: dynamicSecretLeaseKeys.list({ path, environment, projectId, slug }),
enabled: Boolean(projectId && environment && path && slug && enabled),
queryKey: dynamicSecretLeaseKeys.list({ path, environment, projectSlug, slug }),
enabled: Boolean(projectSlug && environment && path && slug && enabled),
queryFn: async () => {
const { data } = await apiRequest.get<{ leases: TDynamicSecretLease[] }>(
`/api/v1/dynamic-secrets/leases/${slug}`,
`/api/v1/dynamic-secrets/${slug}/leases`,
{
params: {
projectId,
projectSlug,
environment,
path
}