feat: AI commentary skeleton loading - separate async endpoint
Deploy Iddaai Frontend / build-and-deploy (push) Successful in 2m20s

This commit is contained in:
2026-05-17 16:46:53 +03:00
parent e744a62fc2
commit 71a6ed320c
8 changed files with 228 additions and 40 deletions
+9
View File
@@ -65,6 +65,14 @@ const checkHealth = () => {
});
};
const getCommentary = (matchId: string) => {
return apiRequest<ApiResponse<{ commentary: string | null }>>({
url: `/predictions/${matchId}/commentary`,
client: "core",
method: "get",
});
};
const generateSmartCoupon = (body: SmartCouponRequestDto) => {
return apiRequest<ApiResponse<SmartCouponResponseDto>>({
url: "/predictions/smart-coupon",
@@ -82,4 +90,5 @@ export const predictionsService = {
getHistory,
checkHealth,
generateSmartCoupon,
getCommentary,
};
+12
View File
@@ -7,6 +7,8 @@ export const PredictionsQueryKeys = {
all: ["predictions"] as const,
detail: (matchId: string) =>
[...PredictionsQueryKeys.all, "detail", matchId] as const,
commentary: (matchId: string) =>
[...PredictionsQueryKeys.all, "commentary", matchId] as const,
upcoming: () => [...PredictionsQueryKeys.all, "upcoming"] as const,
valueBets: () => [...PredictionsQueryKeys.all, "valueBets"] as const,
history: () => [...PredictionsQueryKeys.all, "history"] as const,
@@ -21,6 +23,16 @@ export const usePrediction = (matchId: string) => {
});
};
export const useAiCommentary = (matchId: string, enabled: boolean) => {
return useQuery({
queryKey: PredictionsQueryKeys.commentary(matchId),
queryFn: () => predictionsService.getCommentary(matchId),
enabled,
staleTime: 10 * 60 * 1000, // 10 dakika cache
retry: 1,
});
};
export const useGeneratePrediction = () => {
return useMutation({
mutationFn: (body: { matchId: string; sport?: SportType }) =>