Skip to content

Commit

Permalink
Created a common proptype Playlist
Browse files Browse the repository at this point in the history
  • Loading branch information
DalerAsrorov committed Oct 11, 2017
1 parent 4912b3d commit 3575469
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/List/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import MaterialList, {
ListSubheader
} from 'material-ui/List';
import { PlaylistPlay } from 'material-ui-icons';
import { PLAYLIST_PROPTYPE } from '../../utils/constants';

const styles = theme => ({
root: {
Expand Down Expand Up @@ -45,7 +46,7 @@ const List = props => {
};

List.propTypes = {
items: PropTypes.array.isRequired,
items: PropTypes.arrayOf(PLAYLIST_PROPTYPE).isRequired,
subheader: PropTypes.string,
classes: PropTypes.object
};
Expand Down
2 changes: 2 additions & 0 deletions src/components/MyPlaylists/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class MyPlaylists extends PureComponent {
const { myPlaylists: { playlists } } = this.props;
const ListOfMyPlaylists = <List items={playlists} />;

console.log('playlists', playlists);

return <div id="myPlaylists">{ListOfMyPlaylists}</div>;
}
}
Expand Down
18 changes: 18 additions & 0 deletions src/utils/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import PropTypes from 'prop-types';

export const PLAYLIST_PROPTYPE = PropTypes.shape({
id: PropTypes.string.isRequired,
href: PropTypes.string.isRequired,
images: PropTypes.array.isRequired,
name: PropTypes.string.isRequired,
tracks: PropTypes.object.isRequired,
type: PropTypes.string.isRequired,
owner: PropTypes.shape({
id: PropTypes.string.isRequired,
type: PropTypes.string.isRequired
}).isRequired,
external_urls: PropTypes.shape({
spotify: PropTypes.string
}).isRequired,
public: PropTypes.bool
});

0 comments on commit 3575469

Please sign in to comment.