feat: ajout de la fonctionnalité de recherche et d'ajout de mangas, avec mise à jour du store pour gérer les états de recherche et d'ajout, ainsi que création d'une nouvelle page AddManga pour l'interface utilisateur

This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2025-03-30 18:06:46 +02:00
parent 77f05b287c
commit b1b5177d4e
5 changed files with 316 additions and 89 deletions

View File

@@ -26,7 +26,16 @@ export const useMangaStore = defineStore('manga', {
// --- Selected Manga State ---
// Gardé pour savoir quel manga est sélectionné dans l'UI,
// mais les données détaillées ne sont plus stockées ici.
currentMangaId: null
currentMangaId: null,
// --- Search State ---
searchResults: [],
loadingSearch: false,
searchError: null,
// --- Add Manga State ---
addingManga: false,
addMangaError: null
}),
getters: {
@@ -75,8 +84,44 @@ export const useMangaStore = defineStore('manga', {
clearCurrentMangaFocus() {
this.currentMangaId = null;
}
},
// Plus d'actions fetchMangaDetails / fetchMangaChapters ici
// --- Search Actions ---
async searchMangaDex(query) {
if (this.loadingSearch) return;
this.loadingSearch = true;
this.searchError = null;
this.searchResults = [];
try {
const data = await mangaRepository.searchMangaDex(query);
this.searchResults = data.items || [];
} catch (error) {
this.searchError = error.message;
throw error;
} finally {
this.loadingSearch = false;
}
},
// --- Add Manga Actions ---
async createFromMangaDex(externalId) {
if (this.addingManga) return;
this.addingManga = true;
this.addMangaError = null;
try {
await mangaRepository.createFromMangaDex(externalId);
// Rafraîchir la collection après l'ajout
await this.loadCollection();
} catch (error) {
this.addMangaError = error.message;
throw error;
} finally {
this.addingManga = false;
}
}
}
});