diff --git a/components/form/content/spit-convert-form.tsx b/components/form/content/spit-convert-form.tsx index 76452cbf..05ecb648 100644 --- a/components/form/content/spit-convert-form.tsx +++ b/components/form/content/spit-convert-form.tsx @@ -47,6 +47,7 @@ import { // Swiper import { Swiper, SwiperSlide } from "swiper/react"; +import { Swiper as SwiperType } from "swiper"; import "swiper/css"; import "swiper/css/free-mode"; import "swiper/css/navigation"; @@ -206,7 +207,7 @@ export default function FormConvertSPIT() { // <-- changed: detailThumb is now FileType[] (objects from API) --> const [detailThumb, setDetailThumb] = useState([]); - const [thumbsSwiper, setThumbsSwiper] = useState(null); + const [thumbsSwiper, setThumbsSwiper] = useState(null); const [files, setFiles] = useState([]); const [filePlacements, setFilePlacements] = useState([]); const [articleIds, setArticleIds] = useState([]); @@ -229,6 +230,13 @@ export default function FormConvertSPIT() { checkUserPermissions(); }, [userLevelId, roleId]); + // Handle Swiper re-initialization when detailThumb changes + useEffect(() => { + if (thumbsSwiper && detailThumb.length > 0) { + thumbsSwiper.update(); + } + }, [detailThumb, thumbsSwiper]); + const initializeComponent = async () => { try { setIsLoading(true); @@ -952,68 +960,114 @@ export default function FormConvertSPIT() { -
+
{detailThumb.map((item) => ( - + {item.contentType === "VIDEO" ? ( -
-
-
- {/* main video player */} -
-
+
+
) : ( - {`Media +
+ {`Media { + console.error('Image load error:', e); + e.currentTarget.style.display = 'none'; + }} + /> +
)} ))} {detailThumb.map((item) => ( - + {item.contentType === "VIDEO" ? ( -
+
{/* use preload metadata so browser doesn't download full video */}
) : ( - {`Thumbnail +
+ {`Thumbnail { + console.error('Thumbnail image load error:', e); + e.currentTarget.style.display = 'none'; + }} + /> +
)} ))}