import React, { PropTypes } from 'react';
import { Link, hashHistory } from 'react-router';
import Icon from './Icon';
export default class Notifications extends React.Component{
constructor(props){
super(props)
}
importSpotifyAuthorization(notification_key, user, authorization){
this.props.spotifyActions.importAuthorization(user, authorization);
this.props.uiActions.removeNotification(notification_key, true);
this.props.uiActions.createNotification({content: 'Spotify authorization imported'});
}
renderNotifications(){
if (!this.props.notifications || this.props.notifications.length <= 0) return null
var notifications = []
for (var key in this.props.notifications){
if (this.props.notifications.hasOwnProperty(key)){
notifications.push(this.props.notifications[key])
}
}
return (
{
notifications.map(notification => {
switch (notification.type){
case 'shortcut':
return (
{notification.user.display_name ? notification.user.display_name : notification.user.id} has shared their Spotify authorization with you. Do you want to import this?
Authorization shared
this.importSpotifyAuthorization(notification.key, notification.user, notification.authorization)}>Import
{notification.title}
: null}
{notification.content ? :null}
{notification.description ? : null }