Skip to content

Commit

Permalink
Fix type errors on song overview
Browse files Browse the repository at this point in the history
  • Loading branch information
sbont committed Jan 27, 2024
1 parent a74b655 commit 7219ede
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
1 change: 1 addition & 0 deletions frontend/src/components/Song.vue
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ const remove = () =>
const edit = () => {
draftValues.value = song.value as DraftSong;
draftValues.value.songbook ??= {}
draftSongCategories.value = Object.assign({}, songCategories.value);
editing.value = true;
}
Expand Down
20 changes: 7 additions & 13 deletions frontend/src/stores/categoryStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,18 @@ export type CategoriesState = {
export const useCategories = defineStore('categories', {
state: () => ({
categories: {},
categoriesBySongId: new Map(),
categoriesBySongId: new CacheListMap<number, Category>(),
loading: false
} as CategoriesState),
getters: {},
actions: {
async fetchAll() {
this.loading = true;
api.getAllCategories()
.then(response => {
this.categories = {
season: response.data.filter(category => category.type === "SEASON"),
liturgical: response.data.filter(category => category.type === "LITURGICAL_MOMENT")
}
})
.catch((error) => {
console.log(error);
this.error = "Failed to load categories";
});
const response = await api.getAllCategories()
this.categories = {
season: response.data.filter(category => category.type === "SEASON"),
liturgical: response.data.filter(category => category.type === "LITURGICAL_MOMENT")
}
this.loading = false;
},

Expand All @@ -52,7 +46,7 @@ export const useCategories = defineStore('categories', {
let newCategories = categories.filter(draftCategory => !previousCategories.some(previousCategory => draftCategory.id === previousCategory.id));
let deletedCategories = previousCategories.filter(previousCategory => !categories.some(draftCategory => previousCategory.id === draftCategory.id));
const promises = [];
if(newCategories.length) {
if (newCategories.length) {
const posted = api.postSongCategories(songId, newCategories.map(songCategory => songCategory._links.self.href));
promises.push(posted);
}
Expand Down

0 comments on commit 7219ede

Please sign in to comment.