canina/frontend/application/lib/services/videoService.ts
parsa aghaei 187aa7c962
Some checks are pending
Deploy Canina / deploy (push) Waiting to run
feat: add excel export to reports and video view counter increment [TASK-26.20]
2026-08-05 14:42:38 +03:30

44 lines
1015 B
TypeScript

import api from './api';
export interface Video {
id: string;
title: string;
doctor: string;
duration: string;
thumbnail: string;
videoUrl: string;
description: string;
viewsCount?: number;
isFeatured?: boolean;
}
export const videoService = {
getVideos: async (params?: { featured?: boolean; limit?: number; search?: string }) => {
try {
const res = await api.get('/videos', { params });
return res.data.data || res.data || [];
} catch (error) {
console.error('Failed to fetch videos from API:', error);
return [];
}
},
getVideoById: async (id: string) => {
try {
const res = await api.get(`/videos/${id}`);
return res.data;
} catch (error) {
console.error('Failed to fetch video details:', error);
return null;
}
},
incrementViews: async (id: string) => {
try {
await api.patch(`/videos/${id}/view`);
} catch (error) {
console.warn('Failed to increment video views:', error);
}
}
};