fix: use type aliases and named response type for consistency
This commit is contained in:
@@ -1,21 +1,27 @@
|
|||||||
import { apiClient } from '@/shared/api/client'
|
import { apiClient } from '@/shared/api/client'
|
||||||
|
|
||||||
export interface ChecklistResultDto {
|
export type ChecklistResultDto = {
|
||||||
passed: boolean
|
passed: boolean
|
||||||
checkedAt: string
|
checkedAt: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TestChecklistResponse {
|
export type TestChecklistResponse = {
|
||||||
results: Record<string, ChecklistResultDto>
|
results: Record<string, ChecklistResultDto>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type UpdateChecklistItemResponse = {
|
||||||
|
itemKey: string
|
||||||
|
passed: boolean
|
||||||
|
checkedAt: string
|
||||||
|
}
|
||||||
|
|
||||||
export async function fetchTestChecklistResults(): Promise<TestChecklistResponse> {
|
export async function fetchTestChecklistResults(): Promise<TestChecklistResponse> {
|
||||||
const { data } = await apiClient.get<TestChecklistResponse>('admin/test-checklist')
|
const { data } = await apiClient.get<TestChecklistResponse>('admin/test-checklist')
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateTestChecklistItem(itemKey: string, passed: boolean): Promise<{ itemKey: string; passed: boolean; checkedAt: string }> {
|
export async function updateTestChecklistItem(itemKey: string, passed: boolean): Promise<UpdateChecklistItemResponse> {
|
||||||
const { data } = await apiClient.patch<{ result: { itemKey: string; passed: boolean; checkedAt: string } }>('admin/test-checklist', { itemKey, passed })
|
const { data } = await apiClient.patch<{ result: UpdateChecklistItemResponse }>('admin/test-checklist', { itemKey, passed })
|
||||||
return data.result
|
return data.result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user