feat(dashboard): Migrate to new hooks and API client (#6963)

This commit is contained in:
Kasper Fabricius Kristensen
2024-04-05 18:27:08 +02:00
committed by GitHub
parent 5ba74ec5fc
commit 8a5c6928f7
195 changed files with 3919 additions and 6028 deletions

View File

@@ -0,0 +1,40 @@
import { CreateApiKeyReq, UpdateApiKeyReq } from "../../types/api-payloads"
import {
ApiKeyDeleteRes,
ApiKeyListRes,
ApiKeyRes,
} from "../../types/api-responses"
import { deleteRequest, getRequest, postRequest } from "./common"
const retrieveApiKey = async (id: string, query?: Record<string, any>) => {
return getRequest<ApiKeyRes>(`/admin/api-keys/${id}`, query)
}
const listApiKeys = async (query?: Record<string, any>) => {
return getRequest<ApiKeyListRes>(`/admin/api-keys`, query)
}
const deleteApiKey = async (id: string) => {
return deleteRequest<ApiKeyDeleteRes>(`/admin/api-keys/${id}`)
}
const revokeApiKey = async (id: string) => {
return postRequest<ApiKeyRes>(`/admin/api-keys/${id}/revoke`)
}
const createApiKey = async (payload: CreateApiKeyReq) => {
return postRequest<ApiKeyRes>(`/admin/api-keys`, payload)
}
const updateApiKey = async (id: string, payload: UpdateApiKeyReq) => {
return postRequest<ApiKeyRes>(`/admin/api-keys/${id}`, payload)
}
export const apiKeys = {
retrieve: retrieveApiKey,
list: listApiKeys,
delete: deleteApiKey,
create: createApiKey,
update: updateApiKey,
revoke: revokeApiKey,
}