diff --git a/src/components/content/carousels/DocumentsCarousel.js b/src/components/content/carousels/DocumentsCarousel.js index ea20b34..f6a6e75 100644 --- a/src/components/content/carousels/DocumentsCarousel.js +++ b/src/components/content/carousels/DocumentsCarousel.js @@ -51,9 +51,9 @@ export default function DocumentsCarousel() { useEffect(() => { const fetch = async () => { try { - if (documents && documents.length > 0) { + if (documents && documents.length > 0 && paidLessons.length > 0) { const processedDocuments = documents.map(document => parseEvent(document)); - + console.log('processedDocuments', processedDocuments); // Sort documents by created_at in descending order (most recent first) const sortedDocuments = processedDocuments.sort((a, b) => b.created_at - a.created_at); @@ -69,7 +69,7 @@ export default function DocumentsCarousel() { } }; fetch(); - }, [documents]); + }, [documents, paidLessons]); if (documentsError) { return
Error: {documentsError.message}
diff --git a/src/components/content/carousels/VideosCarousel.js b/src/components/content/carousels/VideosCarousel.js index 8b9b2ed..da8aa13 100644 --- a/src/components/content/carousels/VideosCarousel.js +++ b/src/components/content/carousels/VideosCarousel.js @@ -50,10 +50,12 @@ export default function VideosCarousel() { useEffect(() => { const fetch = async () => { try { - if (videos && videos.length > 0) { + if (videos && videos.length > 0 && paidLessons.length > 0) { const processedVideos = videos.map(video => parseEvent(video)); + console.log('processedVideos', processedVideos); const sortedVideos = processedVideos.sort((a, b) => b.created_at - a.created_at); + console.log('paidLessons', paidLessons); // filter out videos that are in the paid lessons array const filteredVideos = sortedVideos.filter(video => !paidLessons.includes(video?.d)); @@ -67,7 +69,7 @@ export default function VideosCarousel() { } }; fetch(); - }, [videos]); + }, [videos, paidLessons]); if (videosError) return
Error: {videosError}
;