mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-04-22 16:51:34 +00:00
Fix carousel filtering condition for documents and videos
This commit is contained in:
parent
543ad6ed38
commit
33da6d34f1
@ -54,15 +54,19 @@ export default function DocumentsCarousel() {
|
||||
useEffect(() => {
|
||||
const fetch = async () => {
|
||||
try {
|
||||
if (documents && documents.length > 0 && paidLessons.length > 0) {
|
||||
if (documents && documents.length > 0 && paidLessons) {
|
||||
const processedDocuments = documents.map(document => parseEvent(document));
|
||||
// Sort documents by created_at in descending order (most recent first)
|
||||
const sortedDocuments = processedDocuments.sort((a, b) => b.created_at - a.created_at);
|
||||
|
||||
// filter out documents that are in the paid lessons array
|
||||
const filteredDocuments = sortedDocuments.filter(document => !paidLessons.includes(document?.d));
|
||||
if (paidLessons && paidLessons.length > 0) {
|
||||
// filter out documents that are in the paid lessons array
|
||||
const filteredDocuments = sortedDocuments.filter(document => !paidLessons.includes(document?.d));
|
||||
|
||||
setProcessedDocuments(filteredDocuments);
|
||||
setProcessedDocuments(filteredDocuments);
|
||||
} else {
|
||||
setProcessedDocuments(sortedDocuments);
|
||||
}
|
||||
} else {
|
||||
console.log('No documents fetched or empty array returned');
|
||||
}
|
||||
|
@ -34,6 +34,10 @@ export default function VideosCarousel() {
|
||||
const windowWidth = useWindowWidth();
|
||||
const isMobileView = windowWidth <= 450;
|
||||
|
||||
useEffect(() => {
|
||||
console.log('videos', videos);
|
||||
}, [videos]);
|
||||
|
||||
useEffect(() => {
|
||||
axios.get('/api/lessons').then(res => {
|
||||
if (res.data) {
|
||||
@ -53,15 +57,19 @@ export default function VideosCarousel() {
|
||||
useEffect(() => {
|
||||
const fetch = async () => {
|
||||
try {
|
||||
if (videos && videos.length > 0 && paidLessons.length > 0) {
|
||||
if (videos && videos.length > 0 && paidLessons) {
|
||||
const processedVideos = videos.map(video => parseEvent(video));
|
||||
|
||||
const sortedVideos = processedVideos.sort((a, b) => b.created_at - a.created_at);
|
||||
|
||||
// filter out videos that are in the paid lessons array
|
||||
const filteredVideos = sortedVideos.filter(video => !paidLessons.includes(video?.d));
|
||||
if (paidLessons && paidLessons.length > 0) {
|
||||
// filter out videos that are in the paid lessons array
|
||||
const filteredVideos = sortedVideos.filter(video => !paidLessons.includes(video?.d));
|
||||
|
||||
setProcessedVideos(filteredVideos);
|
||||
setProcessedVideos(filteredVideos);
|
||||
} else {
|
||||
setProcessedVideos(sortedVideos);
|
||||
}
|
||||
} else {
|
||||
console.log('No videos fetched or empty array returned');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user