mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-04-19 19:01:19 +00:00
Add extra logs to debug and add condition to check paud lessons.length
This commit is contained in:
parent
229cd2ecb3
commit
3ddcf47a72
@ -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 <div>Error: {documentsError.message}</div>
|
||||
|
@ -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 <div>Error: {videosError}</div>;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user