diff --git a/backend/server.js b/backend/server.js index 46821243adfa421d41411a8bcabccf3e668186d4..4151af6a7f29548b249060d85bf245e56c86982a 100644 --- a/backend/server.js +++ b/backend/server.js @@ -113,6 +113,7 @@ app.post('/joinparty/:partyid', (req, res) => { var config ={ headers: {Authorization: 'Bearer ' + req.body.token} }; + console.log(request.body.token). let genres = []; let genres_temp = []; let trackNum=0; @@ -249,10 +250,13 @@ app.post('/saveplaylist/:id', (req,res) => { axios.post(`https://api.spotify.com/v1/playlists/${playlistId}/tracks?${track_ids}`,{},config).then(result =>{ console.log(result.data) db.run('DELETE FROM party WHERE id=?',[req.params.id], () => { + console.log("one") db.run('DELETE FROM songs WHERE party_id=?', [req.params.id], () => { + console.log("two") db.run('DELETE FROM party_members WHERE party_id =?', [req.params.id], () => { + console.log("three") } ) }) diff --git a/frontend/src/actions/playlistActions.js b/frontend/src/actions/playlistActions.js index d75a2f7e5ad3189a2876e53280b9bf3307b145d7..ac0d3be0a39bf4c595f76874db5e683bcd2f5817 100644 --- a/frontend/src/actions/playlistActions.js +++ b/frontend/src/actions/playlistActions.js @@ -79,21 +79,6 @@ export const getPartyDetails = (partyId) => dispatch => { ); } -export const joinParty = (pData) => dispatch => { - - console.log(pData) - axios.post(`https://thespotifierapp.herokuapp.com/joinparty/${pData.party_id}`,pData) - .then(res =>{ - console.log(res.data) - } - ) - .catch(err=> - dispatch({ - type: GET_ERRORS, - payload: err - }) - ); -} //ADD PLAYLIST diff --git a/frontend/src/components/dashboard/SpotifyPlaylist.js b/frontend/src/components/dashboard/SpotifyPlaylist.js index 4268d682da73aa863d9a2ce06264b5d49339384e..84e8e2a9194e867bc4a26bc26c8a933c7b7250ef 100644 --- a/frontend/src/components/dashboard/SpotifyPlaylist.js +++ b/frontend/src/components/dashboard/SpotifyPlaylist.js @@ -42,7 +42,7 @@ class AllProject extends Component { let playlistContent; - if (this.props.playlists.loading===false && playlists!==null){ + if (this.props.playlists.loading===false && playlists!==null && playlists.spotifyPlaylists!==null){ playlistContent=( playlists.spotifyPlaylists.items.map(playlist => ( <tr key={playlist.name}> diff --git a/frontend/src/components/join/Join.js b/frontend/src/components/join/Join.js index 6ecbde07a0380a8ba8653a0c9cbfb9c356f4e993..488a27d612f97a64ddedd17ea9fb281d19c88f92 100644 --- a/frontend/src/components/join/Join.js +++ b/frontend/src/components/join/Join.js @@ -1,8 +1,8 @@ import React, { Component, Fragment } from 'react' import {Link, withRouter} from 'react-router-dom'; -import {joinParty} from '../../actions/playlistActions' import connect from "react-redux/es/connect/connect"; import {getCurrentProfile} from "../../actions/profileActions"; +import axios from "axios"; class Join extends Component { @@ -15,14 +15,18 @@ class Join extends Component { this.onSubmit = this.onSubmit.bind(this); this.state={ profile : null, - token: null + token: null, + joined: false } } - onSubmit = param => (e) => { + onSubmit = param => async (e) => { - this.props.joinParty(param, this.props.history); + + const response = await axios.post(`https://thespotifierapp.herokuapp.com/joinparty/${param.party_id}`,param) + console.log(response) + this.setState({joined:true}) } @@ -50,7 +54,7 @@ class Join extends Component { - return <div className="add-project"> + return (!this.state.joined) ? (<div className="add-project"> <div className="containter"> <div className="row"> <div className="col-lg-12"> @@ -91,8 +95,9 @@ class Join extends Component { </div> </div> </div> - </div> - } + </div>) : <div className="col-lg-12"> You joined to this event! </div> + + } } @@ -101,4 +106,4 @@ const mapStateToProps = state => ({ auth: state.auth }) -export default connect(mapStateToProps,{getCurrentProfile,joinParty})(withRouter(Join)); \ No newline at end of file +export default connect(mapStateToProps,{getCurrentProfile})(withRouter(Join)); \ No newline at end of file