feat: ajout de la fonctionnalité d'édition des mangas, incluant la création d'un modal d'édition, la mise à jour de l'API pour gérer les modifications, et l'intégration de la logique de gestion des erreurs. Tests ajoutés pour valider le bon fonctionnement de l'édition.
This commit is contained in:
parent
896c57ac34
commit
9255509042
@@ -37,6 +37,16 @@
|
||||
@close="closePreferredSourcesModal"
|
||||
@save="savePreferredSources"
|
||||
/>
|
||||
|
||||
<!-- Modale d'édition du manga -->
|
||||
<MangaEditModal
|
||||
:is-open="isEditModalOpen"
|
||||
:manga="currentManga"
|
||||
:is-saving="isEditLoading"
|
||||
:error="editError"
|
||||
@close="closeEditModal"
|
||||
@save="saveMangaEdit"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div v-else-if="isLoadingDetails" class="flex justify-center items-center h-64">
|
||||
@@ -64,10 +74,12 @@ import { computed, onUnmounted, ref, watch } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
import { useMangaDetails } from '../composables/useMangaDetails';
|
||||
import { useMangaEdit } from '../composables/useMangaEdit';
|
||||
import { useMangaPreferredSources } from '../composables/useMangaPreferredSources';
|
||||
import { useMangaVolumes } from '../composables/useMangaVolumes';
|
||||
|
||||
import MangaHeader from '../components/MangaHeader.vue';
|
||||
import MangaEditModal from '../components/MangaEditModal.vue';
|
||||
import MangaHeader from '../components/MangaHeader.vue';
|
||||
import MangaPreferredSourcesModal from '../components/MangaPreferredSourcesModal.vue';
|
||||
import MangaVolumeList from '../components/MangaVolumeList.vue';
|
||||
import MercureListener from '../components/MercureListener.vue';
|
||||
@@ -105,6 +117,16 @@ import { useMangaStore } from '../../application/store/mangaStore';
|
||||
savePreferredSources: saveSourcesOrder
|
||||
} = useMangaPreferredSources(mangaId);
|
||||
|
||||
// Composable pour l'édition des mangas
|
||||
const {
|
||||
isEditModalOpen,
|
||||
openEditModal,
|
||||
closeEditModal,
|
||||
editManga,
|
||||
isLoading: isEditLoading,
|
||||
error: editError
|
||||
} = useMangaEdit();
|
||||
|
||||
// Charger les chapitres dans le store quand le manga est chargé
|
||||
watch(
|
||||
mangaId,
|
||||
@@ -133,6 +155,15 @@ import { useMangaStore } from '../../application/store/mangaStore';
|
||||
}
|
||||
};
|
||||
|
||||
// Fonction pour sauvegarder l'édition du manga
|
||||
const saveMangaEdit = async (updateData) => {
|
||||
try {
|
||||
await editManga(mangaId.value, updateData);
|
||||
} catch (error) {
|
||||
console.error('Erreur lors de l\'édition du manga:', error);
|
||||
}
|
||||
};
|
||||
|
||||
const toolbarConfig = computed(() => ({
|
||||
leftSection: [
|
||||
{
|
||||
@@ -171,7 +202,7 @@ import { useMangaStore } from '../../application/store/mangaStore';
|
||||
icon: WrenchIcon,
|
||||
label: 'Edit',
|
||||
type: 'button',
|
||||
onClick: () => console.log('Edit')
|
||||
onClick: openEditModal
|
||||
},
|
||||
{
|
||||
icon: TrashIcon,
|
||||
|
||||
Reference in New Issue
Block a user