From 5fa261591c7ced4793d2a5c58e6a88a49415c352 Mon Sep 17 00:00:00 2001 From: xianyi Date: Tue, 13 Jan 2026 17:12:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=9B=BD=E5=AE=B6=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- constants/api.ts | 1 + lib/api.ts | 16 ++++++++++++++++ types/api.ts | 10 ++++++++++ 3 files changed, 27 insertions(+) diff --git a/constants/api.ts b/constants/api.ts index 8c502a5..39a5198 100644 --- a/constants/api.ts +++ b/constants/api.ts @@ -5,6 +5,7 @@ export const API_CONFIG = { export const API_ENDPOINTS = { SPORTS: "/v1/api/sports", + COUNTRIES: "/v1/api/countries", MATCHES_TODAY: "/v1/api/matches/today", MATCH_DETAIL: (id: string) => `/v1/api/matches/${id}`, }; diff --git a/lib/api.ts b/lib/api.ts index 1de6ea5..903c9be 100644 --- a/lib/api.ts +++ b/lib/api.ts @@ -2,6 +2,7 @@ import { API_CONFIG, API_ENDPOINTS } from "@/constants/api"; import { ApiListResponse, ApiResponse, + Country, Match, MatchDetailData, Sport, @@ -32,6 +33,21 @@ export const fetchSports = async (): Promise => { } }; +export const fetchCountries = async (): Promise => { + try { + const response = await apiClient.get>>( + API_ENDPOINTS.COUNTRIES + ); + if (response.data.code === 0) { + return response.data.data.list; + } + throw new Error(response.data.message); + } catch (error) { + console.error("Fetch countries error:", error); + throw error; + } +}; + export const fetchTodayMatches = async (sportId: number): Promise => { try { const response = await apiClient.get>>( diff --git a/types/api.ts b/types/api.ts index 7e40e64..742619e 100644 --- a/types/api.ts +++ b/types/api.ts @@ -30,6 +30,16 @@ export interface ApiListResponse { total: number; } +export interface Country { + id: number; + code: string; + name: string; + flagIcon: string; + createdAt: string; + updatedAt: string; + isActive: boolean; +} + export interface GoalEvent { time: string; home_scorer?: string;