Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Feature: Top Sellers #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/vuex/actions/TopSellers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import axios from './axios';

function FetchTopArtists ({commit}) {
return new Promise((resolve, reject) => {
axios.get('/top/artists')
.then(resp => {
commit('SET_TOP_ARTISTS', resp.data);
resolve(resp.data);
})
.catch(err => {
reject(err);
});
});
}

function FetchTopSongs ({commit}) {
return new Promise((resolve, reject) => {
axios.get('/top/songs')
.then(resp => {
commit('SET_TOP_SONGS', resp.data);
resolve(resp.data);
})
.catch(err => {
reject(err);
});
});
}

function FetchTopAlbums ({commit}) {
return new Promise((resolve, reject) => {
axios.get('/top/albums')
.then(resp => {
commit('SET_TOP_ALBUMS', resp.data);
resolve(resp.data);
})
.catch(err => {
reject(err);
});
});
}

export default {
FetchTopArtists,
FetchTopSongs,
FetchTopAlbums
};
2 changes: 2 additions & 0 deletions src/vuex/actions/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Auth from './Auth';
import Featured from './Featured';
import TopSellers from './TopSellers';

export default {
...Auth,
...Featured,
...TopSellers,
};
17 changes: 17 additions & 0 deletions src/vuex/mutations/TopSellers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function SET_TOP_ARTISTS (state, artists) {
state.top.artists = artists;
}

function SET_TOP_SONGS (state, songs) {
state.top.songs = songs;
}

function SET_TOP_ALBUMS (state, albums) {
state.top.albums = albums;
}

export default {
SET_TOP_ARTISTS,
SET_TOP_SONGS,
SET_TOP_ALBUMS
};
4 changes: 3 additions & 1 deletion src/vuex/mutations/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Featured from './Featured';
import TopSellers from './TopSellers';

export default {
...Featured
...Featured,
...TopSellers
};
7 changes: 6 additions & 1 deletion src/vuex/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ export default new Vuex.Store({
artists: [],
albums: [],
songs: [],
}
},
top: {
artists: [],
albums: [],
songs: [],
},
},
getters: {
user (state) {
Expand Down