forked from sonos/api-web-sample-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
favoriteComponent.jsx
44 lines (39 loc) · 1.22 KB
/
favoriteComponent.jsx
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
import React from "react";
import { Component } from "react";
import HelperControls from "../ControlAPIs/playerControls";
import {Container} from "reactstrap";
/**
* Class component for a single Sonos favorite
* Displays button and loads favorite on click
*/
class FavoriteComponent extends Component {
/**
* @param props.state {JSON} Favorite information, including name and ID
* @param props.groupId {string} Used to target current group when calling Sonos API
*/
constructor(props) {
super(props);
// Used for Sonos API calls
this.ControlOptions = new HelperControls();
}
/**
* onClick handler that calls Sonos API to load favorite to currently displayed group
*/
playFavoriteHandler = () => {
const data = { favoriteId: this.props.state.id }
this.ControlOptions.helperControls("favorites", this.props.groupId, data);
}
render() {
// Returns button that displays favorite name and when clicked, loads favorite to current group
return (
<div>
<Container>
<a onClick={this.playFavoriteHandler}>
<p className="playback_item">{this.props.state.name}</p>
</a>
</Container>
</div>
);
}
}
export default FavoriteComponent;