import { useState, useEffect } from "react"; import { useQuery } from "@tanstack/react-query"; import { Card } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; import { PlayCircle, Clock, Tag, Network } from "lucide-react"; interface VideoAd { adType: string; adUrl?: string; adTitle?: string; adDuration?: number; position?: number; vastTag?: string; adNetwork?: string; priority: number; } interface VideoAdsProps { videoId: string; } export default function VideoAds({ videoId }: VideoAdsProps) { const { data, isLoading, error } = useQuery({ queryKey: [`/api/videos/${videoId}/ads`], }); if (isLoading) { return (
); } if (error) { return (

Failed to load ad metadata

); } const { ads = [], totalAds = 0 } = data || {}; if (totalAds === 0) { return (

No ad spots configured for this video

); } return (

Video Ads ({totalAds} spots)

{ads.map((ad: VideoAd, index: number) => (
{ad.adType.toUpperCase()} {ad.adTitle || `${ad.adType} Advertisement`}
{ad.adDuration && (
{ad.adDuration}s duration
)} {ad.position !== undefined && ad.adType === 'midroll' && (
At {Math.floor(ad.position / 60)}:{(ad.position % 60).toString().padStart(2, '0')}
)} {ad.adNetwork && (
{ad.adNetwork}
)}
Priority {ad.priority}
{ad.vastTag && (
VAST: {ad.vastTag.substring(0, 80)}...
)}
))}
); }