-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCards.js
50 lines (37 loc) · 1.25 KB
/
Cards.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import React, { useState } from "react";
import Card from "./Card"
function Cards(props) {
let courses = props.courses;
let category = props.category;
const [likedCourses, setLikedCourses] = useState([]);
console.log("Printing dta");
console.log(courses);
//returns ypu a list of all cources recevied from the api response
function getCourses() {
if (category === "All") {
let allCourses = [];
Object.values(courses).forEach(courseCategory => {
courseCategory.forEach(courseData => {
allCourses.push(courseData);
})
})
return allCourses;
}
else{
// MAin sirf specific category ka array pass karuga...
return courses[category];
}
}
return (
<div className="flex flex-wrap justify-center gap-4 mb-4">
{
getCourses().map((course) => {
return (
<Card key={course.id} course={course} likedCourses={likedCourses} setLikedCourses={setLikedCourses} />
)
})
}
</div>
);
}
export default Cards;