feat: AI commentary skeleton loading - separate async endpoint
Deploy Iddaai Frontend / build-and-deploy (push) Successful in 2m20s
Deploy Iddaai Frontend / build-and-deploy (push) Successful in 2m20s
This commit is contained in:
@@ -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,
|
||||
};
|
||||
|
||||
@@ -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 }) =>
|
||||
|
||||
Reference in New Issue
Block a user