-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy pathShow.js
31 lines (25 loc) · 900 Bytes
/
Show.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
import React from 'react';
import Episodes from "./Episodes";
import Loading from './Loading';
const Show = (props) => {
const { handleSelect, selectedSeason, show } = props;
if (!show)
return <Loading />
return(<div data-testid="show-container">
<h1>{show.name}</h1>
<p>{show.summary}</p>
<label htmlFor="seasons">Select A Season</label><br/>
<select onChange={handleSelect} name="seasons" id="seasons" data-testid="seasons">
<option value="none"></option>
{
show.seasons.map(season=>{
return(<option data-testid="season-option" key={season.id} value={season.id}>{season.name}</option>);
})
}
</select>
{
(selectedSeason !== "none") && <Episodes episodes={show.seasons[selectedSeason].episodes} />
}
</div>);
}
export default Show;