mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-05-19 08:22:02 +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(() => {
|
useEffect(() => {
|
||||||
const fetch = async () => {
|
const fetch = async () => {
|
||||||
try {
|
try {
|
||||||
if (documents && documents.length > 0) {
|
if (documents && documents.length > 0 && paidLessons.length > 0) {
|
||||||
const processedDocuments = documents.map(document => parseEvent(document));
|
const processedDocuments = documents.map(document => parseEvent(document));
|
||||||
|
console.log('processedDocuments', processedDocuments);
|
||||||
// Sort documents by created_at in descending order (most recent first)
|
// Sort documents by created_at in descending order (most recent first)
|
||||||
const sortedDocuments = processedDocuments.sort((a, b) => b.created_at - a.created_at);
|
const sortedDocuments = processedDocuments.sort((a, b) => b.created_at - a.created_at);
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ export default function DocumentsCarousel() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetch();
|
fetch();
|
||||||
}, [documents]);
|
}, [documents, paidLessons]);
|
||||||
|
|
||||||
if (documentsError) {
|
if (documentsError) {
|
||||||
return <div>Error: {documentsError.message}</div>
|
return <div>Error: {documentsError.message}</div>
|
||||||
|
@ -50,10 +50,12 @@ export default function VideosCarousel() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetch = async () => {
|
const fetch = async () => {
|
||||||
try {
|
try {
|
||||||
if (videos && videos.length > 0) {
|
if (videos && videos.length > 0 && paidLessons.length > 0) {
|
||||||
const processedVideos = videos.map(video => parseEvent(video));
|
const processedVideos = videos.map(video => parseEvent(video));
|
||||||
|
console.log('processedVideos', processedVideos);
|
||||||
|
|
||||||
const sortedVideos = processedVideos.sort((a, b) => b.created_at - a.created_at);
|
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
|
// filter out videos that are in the paid lessons array
|
||||||
const filteredVideos = sortedVideos.filter(video => !paidLessons.includes(video?.d));
|
const filteredVideos = sortedVideos.filter(video => !paidLessons.includes(video?.d));
|
||||||
@ -67,7 +69,7 @@ export default function VideosCarousel() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetch();
|
fetch();
|
||||||
}, [videos]);
|
}, [videos, paidLessons]);
|
||||||
|
|
||||||
if (videosError) return <div>Error: {videosError}</div>;
|
if (videosError) return <div>Error: {videosError}</div>;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user