mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
setup artist discography page
This commit is contained in:
committed by
Mungai Njoroge
parent
fd863d188c
commit
35a8446f8b
@@ -0,0 +1,63 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { discographyAlbumTypes } from "@/composables/enums";
|
||||
import { Album } from "@/interfaces";
|
||||
import { getArtistAlbums } from "@/composables/fetch/artists";
|
||||
|
||||
export default defineStore("artistDiscography", {
|
||||
state: () => ({
|
||||
artist: <string>"",
|
||||
page: discographyAlbumTypes.all,
|
||||
|
||||
toShow: <Album[]>[],
|
||||
|
||||
albums: <Album[]>[],
|
||||
eps: <Album[]>[],
|
||||
singles: <Album[]>[],
|
||||
appearances: <Album[]>[],
|
||||
}),
|
||||
actions: {
|
||||
setAlbums(page: discographyAlbumTypes) {
|
||||
switch (page) {
|
||||
case discographyAlbumTypes.albums:
|
||||
this.toShow = this.albums;
|
||||
break;
|
||||
case discographyAlbumTypes.eps:
|
||||
this.toShow = this.eps;
|
||||
break;
|
||||
case discographyAlbumTypes.singles:
|
||||
this.toShow = this.singles;
|
||||
break;
|
||||
case discographyAlbumTypes.appearances:
|
||||
this.toShow = this.appearances;
|
||||
break;
|
||||
default:
|
||||
this.toShow = this.albums.concat(
|
||||
this.eps,
|
||||
this.singles,
|
||||
this.appearances
|
||||
);
|
||||
}
|
||||
},
|
||||
setPage(page: discographyAlbumTypes) {
|
||||
this.page = page;
|
||||
},
|
||||
fetchAlbums(artisthash: string) {
|
||||
getArtistAlbums(artisthash, true)
|
||||
.then((data) => {
|
||||
this.albums = data.albums;
|
||||
this.eps = data.eps;
|
||||
this.singles = data.singles;
|
||||
this.appearances = data.appearances;
|
||||
})
|
||||
.then(() => this.setAlbums(this.page));
|
||||
},
|
||||
resetAlbums() {
|
||||
this.albums = [];
|
||||
this.eps = [];
|
||||
this.singles = [];
|
||||
this.appearances = [];
|
||||
|
||||
this.toShow = [];
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user