81 lines
1.8 KiB
JavaScript
81 lines
1.8 KiB
JavaScript
import React from "react"
|
|
|
|
import { MenuItem } from "react-bootstrap"
|
|
|
|
import RefreshIndicator from "./refresh"
|
|
|
|
export class WishlistButton extends React.PureComponent {
|
|
constructor(props) {
|
|
super(props);
|
|
this.handleClick = this.handleClick.bind(this);
|
|
}
|
|
handleClick(e) {
|
|
e.preventDefault();
|
|
if (this.props.wishlisted) {
|
|
this.props.deleteFromWishlist(this.props.resourceId);
|
|
} else {
|
|
this.props.addToWishlist(this.props.resourceId);
|
|
}
|
|
}
|
|
render() {
|
|
if (this.props.wishlisted) {
|
|
return (
|
|
<MenuItem onClick={this.handleClick}>
|
|
<span>
|
|
<i className="fa fa-bookmark"></i> Delete from wishlist
|
|
</span>
|
|
</MenuItem>
|
|
);
|
|
} else {
|
|
return (
|
|
<MenuItem onClick={this.handleClick}>
|
|
<span>
|
|
<i className="fa fa-bookmark-o"></i> Add to wishlist
|
|
</span>
|
|
</MenuItem>
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
export class DeleteButton extends React.PureComponent {
|
|
constructor(props) {
|
|
super(props);
|
|
this.handleClick = this.handleClick.bind(this);
|
|
}
|
|
handleClick(e) {
|
|
e.preventDefault();
|
|
this.props.deleteFunc(this.props.resourceId, this.props.lastFetchUrl);
|
|
}
|
|
render() {
|
|
return (
|
|
<MenuItem onClick={this.handleClick}>
|
|
<span>
|
|
<i className="fa fa-trash"></i> Delete
|
|
</span>
|
|
</MenuItem>
|
|
);
|
|
}
|
|
}
|
|
|
|
export class RefreshButton extends React.PureComponent {
|
|
constructor(props) {
|
|
super(props);
|
|
this.handleClick = this.handleClick.bind(this);
|
|
}
|
|
handleClick(e) {
|
|
e.preventDefault();
|
|
if (this.props.fetching) {
|
|
return
|
|
}
|
|
this.props.getDetails(this.props.resourceId);
|
|
}
|
|
render() {
|
|
return (
|
|
<MenuItem onClick={this.handleClick}>
|
|
<RefreshIndicator refresh={this.props.fetching} />
|
|
</MenuItem>
|
|
);
|
|
}
|
|
}
|