feat: ajout de la fonctionnalité de suppression des chapitres avec mise à jour de l'API et des composants associés pour gérer la suppression des chapitres et des fichiers CBZ.

This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2025-06-29 23:04:57 +02:00
parent 37e1b202c2
commit 8692fa14c6
6 changed files with 563 additions and 552 deletions

View File

@@ -197,6 +197,18 @@ export const useMangaStore = defineStore('manga', {
console.error('Erreur lors de la recherche du chapitre:', error);
throw error;
}
},
// --- Delete Chapter Action ---
async deleteChapter(chapterId) {
try {
await mangaRepository.deleteChapter(chapterId);
// Mettre à jour l'état du chapitre pour refléter qu'il n'est plus disponible
this.updateChapterAvailability(chapterId, false);
} catch (error) {
console.error('Erreur lors de la suppression du chapitre:', error);
throw error;
}
}
}
});

View File

@@ -173,4 +173,19 @@ export class ApiMangaRepository {
throw error;
}
}
async deleteChapter(chapterId) {
try {
const response = await fetch(`/api/manga/chapters/${chapterId}/cbz`, {
method: 'DELETE'
});
if (!response.ok) {
throw new Error('Failed to delete chapter');
}
return true;
} catch (error) {
console.error('API Error:', error);
throw error;
}
}
}

View File

@@ -35,8 +35,8 @@
<script setup>
import { ArrowDownTrayIcon, MagnifyingGlassIcon, TrashIcon, XMarkIcon } from '@heroicons/vue/24/solid';
import { computed, ref, watch } from 'vue';
import { useMangaStore } from '../../application/store/mangaStore';
import { computed, ref, watch } from 'vue';
import { useMangaStore } from '../../application/store/mangaStore';
const props = defineProps({
chapter: {
@@ -87,8 +87,12 @@
};
const handleDelete = async () => {
// TODO: Implémenter la suppression du chapitre
console.log('Suppression du chapitre:', props.chapter.id);
try {
console.log(`MangaChapter: Suppression du chapitre ${props.chapter.number} (ID: ${props.chapter.id})`);
await store.deleteChapter(props.chapter.id);
} catch (error) {
console.error('Erreur lors de la suppression du chapitre:', error);
}
};
const handleDownload = async () => {