|
3 | 3 | import { endpoint } from "@/api" |
4 | 4 | import { api } from "@/api/api-client" |
5 | 5 |
|
6 | | -import type { Country, Operator, OperatorsSearchResponse } from "@/types/api" |
| 6 | +import type { |
| 7 | + Country, |
| 8 | + Operator, |
| 9 | + OperatorPerformanceChart, |
| 10 | + OperatorsSearchResponse, |
| 11 | +} from "@/types/api" |
7 | 12 | import { type ChainName } from "@/config/chains" |
| 13 | +import { |
| 14 | + operatorPerformanceChartParamsSerializer, |
| 15 | + type OperatorPerformanceChartParams, |
| 16 | +} from "@/lib/search-parsers/operator-performance-chart-parsers" |
8 | 17 | import { |
9 | 18 | operatorSearchParamsSerializer, |
10 | 19 | type OperatorsSearchSchema, |
@@ -171,3 +180,30 @@ export const getOperatorPerformanceV2 = async (params: { |
171 | 180 | } |
172 | 181 | )() |
173 | 182 | } |
| 183 | + |
| 184 | +export const getOperatorPerformanceChart = async ( |
| 185 | + params: { |
| 186 | + network: ChainName |
| 187 | + operatorId: number |
| 188 | + } & Partial<OperatorPerformanceChartParams> |
| 189 | +) => |
| 190 | + await unstable_cache( |
| 191 | + async () => { |
| 192 | + const searchParams = operatorPerformanceChartParamsSerializer({ |
| 193 | + points: params.points, |
| 194 | + type: params.type, |
| 195 | + }) |
| 196 | + |
| 197 | + const url = endpoint( |
| 198 | + params.network, |
| 199 | + `duties/operator/${params.operatorId}/performance-chart`, |
| 200 | + searchParams ? `?${searchParams}` : "" |
| 201 | + ) |
| 202 | + return await api.get<OperatorPerformanceChart>(url) |
| 203 | + }, |
| 204 | + [JSON.stringify(params)], |
| 205 | + { |
| 206 | + revalidate: 30, |
| 207 | + tags: ["operator-performance-chart"], |
| 208 | + } |
| 209 | + )() |
0 commit comments