Skip to content

Commit cfe9d7d

Browse files
committed
Fix types
1 parent 75f19b5 commit cfe9d7d

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

site/src/api/api.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,12 +394,14 @@ interface GetAuditLogsOptions {
394394
offset: number
395395
}
396396

397-
export const getAuditLogs = async (options: GetAuditLogsOptions): Promise<TypesGen.AuditLog[]> => {
397+
export const getAuditLogs = async (
398+
options: GetAuditLogsOptions,
399+
): Promise<TypesGen.AuditLogResponse> => {
398400
const response = await axios.get(`/api/v2/audit?limit=${options.limit}&offset=${options.offset}`)
399401
return response.data
400402
}
401403

402-
export const getAuditLogsCount = async (): Promise<number> => {
404+
export const getAuditLogsCount = async (): Promise<TypesGen.AuditLogCountResponse> => {
403405
const response = await axios.get(`/api/v2/audit/count`)
404406
return response.data
405407
}

site/src/xServices/audit/auditXService.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
import { getAuditLogs, getAuditLogsCount } from "api/api"
22
import { getErrorMessage } from "api/errors"
3+
import { AuditLog } from "api/typesGenerated"
34
import { displayError } from "components/GlobalSnackbar/utils"
45
import { assign, createMachine } from "xstate"
56

6-
type AuditLogs = Awaited<ReturnType<typeof getAuditLogs>>
7-
87
export const auditMachine = createMachine(
98
{
109
id: "auditMachine",
1110
schema: {
12-
context: {} as { auditLogs?: AuditLogs; count?: number; page: number; limit: number },
11+
context: {} as { auditLogs?: AuditLog[]; count?: number; page: number; limit: number },
1312
services: {} as {
1413
loadAuditLogs: {
15-
data: AuditLogs
14+
data: AuditLog[]
1615
}
1716
loadAuditLogsCount: {
1817
data: number
@@ -111,8 +110,8 @@ export const auditMachine = createMachine(
111110
// The page in the API starts at 0
112111
offset: (page - 1) * limit,
113112
limit,
114-
}),
115-
loadAuditLogsCount: () => getAuditLogsCount(),
113+
}).then((data) => data.audit_logs),
114+
loadAuditLogsCount: () => getAuditLogsCount().then((data) => data.count),
116115
},
117116
},
118117
)

0 commit comments

Comments
 (0)