A 3
A 3
A 3
import "./App.css"
state = {
show: false,
data: [],
rating: 1,
}
componentDidMount = () => {
// Write your code here
this.handleGetData();
}
render() {
return (
<div className="home">
<header>
<h2>ABC Learning</h2>
</header>
{
!this.state.show || !this.state.data ? "Fetching DATA" :
this.state.data.map(
(course, index) => (
<div className="cardContainer" key={index}>
<div className="card">
<ul>
<div className="header">
<li>{course.courseName}</li>
<li>{course.courseDept}</li>
<li>{course.description}</li>
{course.isApplied ?
(<li>
{
!course.isRated &&
(<li>Rate:
<select
className="rating"
name="rating"
onChange={(e) => { this.handleRating(e) }}>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<button className="rate"
onClick={() => {
this.handleAddRating(this.state.data[index]
["_id"]);
}}> Add</button>
</li>)
}
<button
className="drop"
onClick={() => {
this.handleDrop(this.state.data[index]["_id"]);
}}>Drop Course</button>
</li>) :
(<li>
<button
className="btn"
onClick={() => {
this.handleApply(this.state.data[index]["_id"]);
}}>Apply</button>
</li>)}
</div>
<div className="footer">
<li>{course.duration} hrs . {course.noOfRatings} Ratings .
{course.rating}/5</li>
</div>
</ul>
</div>
</div >
)
)
}
</div>
);
}
}