fix(admin): enhance media manager with all file types and progress, fix videos sync and home display
Deploy Canina / deploy (push) Successful in 1m49s
Deploy Canina / deploy (push) Successful in 1m49s
This commit is contained in:
1 parent
2d83a00169
commit
bea0488efb
6 files changed
+571
-356
No files matched your search
@@ -81,18 +81,20 @@ export default function VetGallery({ testimonials = [] }: { testimonials?: Testi
|
||||
}, []);
|
||||
|
||||
const activeTestimonials = testimonials.filter(t => t.isActive !== false);
|
||||
const displayItems: DisplayVideoItem[] = activeTestimonials.length > 0
|
||||
? activeTestimonials.map((t, idx) => ({
|
||||
id: t.id || `t-${idx}`,
|
||||
title: (t.authorName || t.vetName || '') + (t.roleTitle ? ` — ${t.roleTitle}` : (t.clinicName ? ` — ${t.clinicName}` : '')),
|
||||
doctor: (t.authorName || t.vetName || '') + (t.roleTitle ? ` (${t.roleTitle})` : ''),
|
||||
duration: "۰۲:۰۰",
|
||||
thumbnail: t.avatarUrl || t.imageUrl || "https://images.unsplash.com/photo-1576091160550-217359f42f8c?auto=format&fit=crop&q=80&w=400",
|
||||
videoUrl: "https://www.w3schools.com/html/mov_bbb.mp4",
|
||||
description: t.content || t.quote || '',
|
||||
quote: t.content || t.quote || ''
|
||||
}))
|
||||
: (apiVideos.length > 0 ? apiVideos : FALLBACK_VIDEOS);
|
||||
const displayItems: DisplayVideoItem[] = apiVideos.length > 0
|
||||
? apiVideos
|
||||
: (activeTestimonials.length > 0
|
||||
? activeTestimonials.map((t, idx) => ({
|
||||
id: t.id || `t-${idx}`,
|
||||
title: (t.authorName || t.vetName || '') + (t.roleTitle ? ` — ${t.roleTitle}` : (t.clinicName ? ` — ${t.clinicName}` : '')),
|
||||
doctor: (t.authorName || t.vetName || '') + (t.roleTitle ? ` (${t.roleTitle})` : ''),
|
||||
duration: "۰۲:۰۰",
|
||||
thumbnail: t.avatarUrl || t.imageUrl || "https://images.unsplash.com/photo-1576091160550-217359f42f8c?auto=format&fit=crop&q=80&w=400",
|
||||
videoUrl: "https://www.w3schools.com/html/mov_bbb.mp4",
|
||||
description: t.content || t.quote || '',
|
||||
quote: t.content || t.quote || ''
|
||||
}))
|
||||
: FALLBACK_VIDEOS);
|
||||
|
||||
return (
|
||||
<section className="py-24 bg-white font-vazir" dir="rtl">
|
||||
|
||||
@@ -58,15 +58,23 @@ const FALLBACK_VIDEOS: Video[] = [
|
||||
|
||||
export default function VideosPage() {
|
||||
const router = useRouter();
|
||||
const [videos, setVideos] = useState<Video[]>(FALLBACK_VIDEOS);
|
||||
const [videos, setVideos] = useState<Video[]>([]);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [selectedVideo, setSelectedVideo] = useState<Video | null>(null);
|
||||
const [search, setSearch] = useState("");
|
||||
|
||||
React.useEffect(() => {
|
||||
setIsLoading(true);
|
||||
videoService.getVideos({ limit: 100 }).then((data) => {
|
||||
if (data && data.length > 0) {
|
||||
setVideos(data);
|
||||
} else {
|
||||
setVideos(FALLBACK_VIDEOS);
|
||||
}
|
||||
}).catch(() => {
|
||||
setVideos(FALLBACK_VIDEOS);
|
||||
}).finally(() => {
|
||||
setIsLoading(false);
|
||||
});
|
||||
}, []);
|
||||
|
||||
@@ -144,11 +152,11 @@ export default function VideosPage() {
|
||||
<div className="flex items-center gap-4 text-xs font-bold text-white/40">
|
||||
<div className="flex items-center gap-1">
|
||||
<User className="w-3 h-3" />
|
||||
{video.doctor}
|
||||
{video.doctor || 'کادر علمی کنینا'}
|
||||
</div>
|
||||
<div className="flex items-center gap-1">
|
||||
<Clock className="w-3 h-3" />
|
||||
دسترسی دائمی
|
||||
<span>{video.duration || 'آموزش ویدئویی'}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -16,7 +16,12 @@ 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 || [];
|
||||
const raw = res.data;
|
||||
if (Array.isArray(raw?.videos)) return raw.videos;
|
||||
if (Array.isArray(raw?.data?.videos)) return raw.data.videos;
|
||||
if (Array.isArray(raw?.data)) return raw.data;
|
||||
if (Array.isArray(raw)) return raw;
|
||||
return [];
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch videos from API:', error);
|
||||
return [];
|
||||
|
||||
Reference in new issue
Block a user