Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | import type { MetricSummary, TodoItem } from '../types'
import { get } from '../http'
import { mockApiDelay } from '../mock'
import { mockTodos } from '../mock/data'
// 后端 /c/dashboard/summary 返回体(com.yd.csf.service.vo.ReferrerDashboardVO)
interface DashboardSummaryDTO {
monthPaidCommission: number
taxYearPaidCommission: number
pipelineCommission: number
effectivePolicyCount: number
firstYearFyp: number
caseCount: number
followingCount: number
}
export async function fetchMetricSummary(): Promise<MetricSummary> {
const dto = await get<DashboardSummaryDTO>('/c/dashboard/summary')
// 后端契约 -> 前端展示模型
return {
thisMonthPaidHkd: dto.monthPaidCommission,
taxYearPaidHkd: dto.taxYearPaidCommission,
pipelineHkd: dto.pipelineCommission,
inforceCount: dto.effectivePolicyCount,
firstYearFypHkd: dto.firstYearFyp,
caseCount: dto.caseCount,
followingCount: dto.followingCount
}
}
/**
* 待办数据来源。
* 后端当前仅有留痕写入接口、无列表查询,故列表仍是前端内置示例数据。
* 界面据此显示「示例数据」标识,避免用户把它当成真实待办;
* 后续接入真接口时改为 'server' 即可,无需改模板。
*/
export const todoDataSource: 'mock' | 'server' = 'mock'
// 待办后端当前仅有留痕写入接口,无列表查询,暂保留 mock
export async function fetchTodos(): Promise<TodoItem[]> {
await mockApiDelay()
return mockTodos
}
|