diff --git a/assets/vue/app/domain/manga/application/queries/searchMangas.js b/assets/vue/app/domain/manga/application/queries/searchMangas.js index a772aa9..4989381 100644 --- a/assets/vue/app/domain/manga/application/queries/searchMangas.js +++ b/assets/vue/app/domain/manga/application/queries/searchMangas.js @@ -15,4 +15,4 @@ export class SearchMangas { throw error; } } -} \ No newline at end of file +} diff --git a/assets/vue/app/domain/manga/application/store/mangaStore.js b/assets/vue/app/domain/manga/application/store/mangaStore.js index 30c190c..7400485 100644 --- a/assets/vue/app/domain/manga/application/store/mangaStore.js +++ b/assets/vue/app/domain/manga/application/store/mangaStore.js @@ -1,5 +1,5 @@ -import { defineStore } from 'pinia'; -import { ApiMangaRepository } from '../../infrastructure/api/apiMangaRepository'; +import {defineStore} from 'pinia'; +import {ApiMangaRepository} from '../../infrastructure/api/apiMangaRepository'; const mangaRepository = new ApiMangaRepository(); @@ -19,32 +19,26 @@ export const useMangaStore = defineStore('manga', { // Actions pour la collection async loadCollection() { if (this.loading) return; - - console.log('Starting loadCollection...'); + this.loading = true; this.error = null; - + try { - console.log('Fetching collection from repository...'); this.collection = await mangaRepository.getCollection(); - console.log('Collection loaded:', this.collection); } catch (err) { this.error = err.message; - console.error('Failed to load collection:', err); } finally { this.loading = false; - console.log('loadCollection finished. Loading:', this.loading); } }, async refreshCollectionInBackground() { if (this.isBackgroundLoading) return; - + this.isBackgroundLoading = true; - + try { - const updatedCollection = await mangaRepository.getCollection(); - this.collection = updatedCollection; + this.collection = await mangaRepository.getCollection(); } catch (err) { console.error('Failed to refresh collection:', err); } finally { @@ -70,12 +64,10 @@ export const useMangaStore = defineStore('manga', { this.error = null; try { const response = await mangaRepository.getChapters(mangaId); - console.log('API Response:', response); // Pour déboguer - this.chapters = Array.isArray(response) ? response : + this.chapters = Array.isArray(response) ? response : (response.items ? response.items : []); } catch (error) { this.error = error.message; - console.error('Failed to fetch chapters:', error); } finally { this.loading = false; } @@ -86,4 +78,4 @@ export const useMangaStore = defineStore('manga', { this.chapters = []; } } -}); \ No newline at end of file +}); diff --git a/assets/vue/app/domain/manga/domain/entities/manga.js b/assets/vue/app/domain/manga/domain/entities/manga.js index 5c42700..cba5686 100644 --- a/assets/vue/app/domain/manga/domain/entities/manga.js +++ b/assets/vue/app/domain/manga/domain/entities/manga.js @@ -6,6 +6,7 @@ export class Manga { description = null, authors = [], imageUrl = null, + thumbnailUrl = null, publicationYear = null, status = null, rating = null, @@ -18,6 +19,7 @@ export class Manga { this.description = description; this.authors = authors; this.imageUrl = imageUrl; + this.thumbnailUrl = thumbnailUrl; this.publicationYear = publicationYear; this.status = status; this.rating = rating; diff --git a/assets/vue/app/domain/manga/infrastructure/api/apiMangaRepository.js b/assets/vue/app/domain/manga/infrastructure/api/apiMangaRepository.js index f75af8d..35b75b2 100644 --- a/assets/vue/app/domain/manga/infrastructure/api/apiMangaRepository.js +++ b/assets/vue/app/domain/manga/infrastructure/api/apiMangaRepository.js @@ -24,7 +24,7 @@ export class ApiMangaRepository { async getMangaById(id) { try { - const response = await fetch(`/api/mangas/${id}`); + const response = await fetch(`/api/mangas/by-id/${id}`); if (!response.ok) { throw new Error('Failed to fetch manga details'); } @@ -64,7 +64,7 @@ export class ApiMangaRepository { async getMangaBySlug(slug) { try { - const response = await fetch(`/api/mangas/${slug}`); + const response = await fetch(`/api/mangas/by-slug/${slug}`); if (!response.ok) { throw new Error('Failed to fetch manga details'); } @@ -87,4 +87,4 @@ export class ApiMangaRepository { throw error; } } -} \ No newline at end of file +} diff --git a/assets/vue/app/domain/manga/presentation/pages/HomePage.vue b/assets/vue/app/domain/manga/presentation/pages/HomePage.vue index 331d9bd..03204d9 100644 --- a/assets/vue/app/domain/manga/presentation/pages/HomePage.vue +++ b/assets/vue/app/domain/manga/presentation/pages/HomePage.vue @@ -17,7 +17,7 @@ import { storeToRefs } from 'pinia'; import { useMangaStore } from '../../application/store/mangaStore'; import MangaGrid from '../components/MangaGrid.vue'; import Toolbar from '../../../../shared/components/ui/Toolbar.vue'; -import { +import { ArrowPathIcon, MagnifyingGlassIcon, Cog6ToothIcon, @@ -29,35 +29,22 @@ import { const router = useRouter(); const mangaStore = useMangaStore(); -const { - collection, - loading, - error, - isBackgroundLoading +const { + collection, + loading, + error, + isBackgroundLoading } = storeToRefs(mangaStore); onMounted(() => { - console.log('HomePage mounted'); - console.log('Store state before loadCollection:', { - collection: collection.value, - loading: loading.value, - error: error.value - }); - mangaStore.loadCollection(); - - console.log('loadCollection called'); }); -const handleAddMangaClick = (query = '') => { - router.push(`/add${query ? `?q=${encodeURIComponent(query)}` : ''}`); -}; - const toolbarConfig = { leftSection: [ - { - icon: ArrowPathIcon, - label: 'Refresh', + { + icon: ArrowPathIcon, + label: 'Refresh', onClick: () => mangaStore.refreshCollectionInBackground(), active: isBackgroundLoading }, @@ -70,4 +57,4 @@ const toolbarConfig = { { icon: FunnelIcon, onClick: () => {} } ] }; - \ No newline at end of file + diff --git a/assets/vue/app/domain/manga/presentation/pages/MangaDetails.vue b/assets/vue/app/domain/manga/presentation/pages/MangaDetails.vue index 302ef15..530552a 100644 --- a/assets/vue/app/domain/manga/presentation/pages/MangaDetails.vue +++ b/assets/vue/app/domain/manga/presentation/pages/MangaDetails.vue @@ -159,7 +159,7 @@