71 lines
1.6 KiB
JavaScript
71 lines
1.6 KiB
JavaScript
import React from "react"
|
|
import PropTypes from "prop-types"
|
|
|
|
import Dropdown from "react-bootstrap/Dropdown"
|
|
|
|
import RefreshIndicator from "./refresh"
|
|
|
|
export const WishlistButton = (props) => {
|
|
const handleClick = (e) => {
|
|
e.preventDefault();
|
|
if (props.wishlisted) {
|
|
props.deleteFromWishlist(props.resourceId);
|
|
} else {
|
|
props.addToWishlist(props.resourceId);
|
|
}
|
|
}
|
|
|
|
if (props.wishlisted) {
|
|
return (
|
|
<Dropdown.Item onClick={handleClick}>
|
|
<span>
|
|
<i className="fa fa-bookmark"></i> Delete from wishlist
|
|
</span>
|
|
</Dropdown.Item>
|
|
);
|
|
} else {
|
|
return (
|
|
<Dropdown.Item onClick={handleClick}>
|
|
<span>
|
|
<i className="fa fa-bookmark-o"></i> Add to wishlist
|
|
</span>
|
|
</Dropdown.Item>
|
|
);
|
|
}
|
|
}
|
|
|
|
export const DeleteButton = (props) => {
|
|
const handleClick = () => {
|
|
props.deleteFunc(props.resourceId, props.lastFetchUrl);
|
|
}
|
|
return (
|
|
<Dropdown.Item onClick={handleClick}>
|
|
<span>
|
|
<i className="fa fa-trash"></i> Delete
|
|
</span>
|
|
</Dropdown.Item>
|
|
);
|
|
}
|
|
DeleteButton.propTypes = {
|
|
resourceId: PropTypes.string.isRequired,
|
|
lastFetchUrl: PropTypes.string,
|
|
deleteFunc: PropTypes.func.isRequired,
|
|
};
|
|
|
|
export const RefreshButton = (props) => {
|
|
const handleClick = () => {
|
|
if (props.fetching) { return; }
|
|
props.getDetails(props.resourceId);
|
|
}
|
|
return (
|
|
<Dropdown.Item onClick={handleClick}>
|
|
<RefreshIndicator refresh={props.fetching} />
|
|
</Dropdown.Item>
|
|
);
|
|
}
|
|
RefreshButton.propTypes = {
|
|
fetching: PropTypes.bool.isRequired,
|
|
resourceId: PropTypes.string.isRequired,
|
|
getDetails: PropTypes.func.isRequired,
|
|
};
|