/* * Copyright (c) 2016 Gabriel Augendre * Free software under MIT License. See LICENSE file. */ 'use strict'; var React = require('react'); var ReactBootstrap = require('react-bootstrap'); var $ = require('jquery'); var DuplicatesBox = require('./duplicates-box'); var PlaylistBox = require('./playlist-box'); var DuplicateFinderBox = React.createClass({ getInitialState: function () { return { currentId: null, currentUId: null, dups: null, dupsLoading: false, clicked: false, title: null }; }, componentWillReceiveProps: function () { this.setState({ clicked: false }); }, handlePlaylistClick: function (id, uid, title) { this.setState({ currentId: id, currentUId: uid, dupsLoading: true, clicked: true, title: title }); var self = this; $.ajax({ url: "/pl/" + uid + "/" + id, data: { 'access_token': self.props.auth.access_token }, success: function (data) { var dups = data.data; self.setState({ dups: dups, dupsLoading: false }); }, error: function (xhr, response, err) { console.error(response, err); } }); }, render: function () { var duplicates; var Col = ReactBootstrap.Col, Row = ReactBootstrap.Row; if (this.state.clicked) { duplicates =

Loading...

; if (!this.state.dupsLoading) { duplicates = ; } duplicates = (

Duplicates in {this.state.title}

{duplicates} ) } var playlistBox =

Loading...

; var dupsCount = this.state.dups && this.state.dups.length; if (!this.props.playlistsLoading) { playlistBox = ; } return (

Playlists

{playlistBox} {duplicates}
); } }); module.exports = DuplicateFinderBox;