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:
parent
77f05b287c
commit
b1b5177d4e
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user