Showing
1 changed file
with
11 additions
and
3 deletions
@@ -4,7 +4,7 @@ import SearchBar from "~/components/SearchBar.vue"; | @@ -4,7 +4,7 @@ import SearchBar from "~/components/SearchBar.vue"; | ||
4 | import { onBeforeUnmount, ref } from "vue"; | 4 | import { onBeforeUnmount, ref } from "vue"; |
5 | import { useTMDB } from "~/composables/tMDB"; | 5 | import { useTMDB } from "~/composables/tMDB"; |
6 | import { Movie } from "~/models/movie"; | 6 | import { Movie } from "~/models/movie"; |
7 | -import { FilmIcon } from "lucide-vue-next"; | 7 | +import { FilmIcon, SearchXIcon } from "lucide-vue-next"; |
8 | import type { MovieInterface } from "~/interfaces/movie"; | 8 | import type { MovieInterface } from "~/interfaces/movie"; |
9 | import { useDateFormat } from "@vueuse/core"; | 9 | import { useDateFormat } from "@vueuse/core"; |
10 | //#endregion | 10 | //#endregion |
@@ -119,6 +119,7 @@ function handleSearchEvent(event: string) { | @@ -119,6 +119,7 @@ function handleSearchEvent(event: string) { | ||
119 | 119 | ||
120 | function handleClearSearchEvent() { | 120 | function handleClearSearchEvent() { |
121 | searchQuery.value = ''; | 121 | searchQuery.value = ''; |
122 | + currentPage.value = 1; | ||
122 | // Fetch popular movies after clear. | 123 | // Fetch popular movies after clear. |
123 | fetchMovies(1); | 124 | fetchMovies(1); |
124 | } | 125 | } |
@@ -127,7 +128,7 @@ function handleClearSearchEvent() { | @@ -127,7 +128,7 @@ function handleClearSearchEvent() { | ||
127 | 128 | ||
128 | //#region --Global event--. | 129 | //#region --Global event--. |
129 | onMounted(() => { | 130 | onMounted(() => { |
130 | - // Chargement des premiers films. | 131 | + // First loading. |
131 | fetchMovies(1); | 132 | fetchMovies(1); |
132 | // Création et stockage dans la ref de l'instance IntersectionObserver. | 133 | // Création et stockage dans la ref de l'instance IntersectionObserver. |
133 | observer.value = createIntersectionObserver(); | 134 | observer.value = createIntersectionObserver(); |
@@ -142,7 +143,7 @@ onMounted(() => { | @@ -142,7 +143,7 @@ onMounted(() => { | ||
142 | }); | 143 | }); |
143 | 144 | ||
144 | onBeforeUnmount(() => { | 145 | onBeforeUnmount(() => { |
145 | - // Disconnect the observer when the component is unmounted | 146 | + // Disconnect the observer when the component is unmounted. |
146 | if (observer.value) { | 147 | if (observer.value) { |
147 | observer.value.disconnect(); | 148 | observer.value.disconnect(); |
148 | } | 149 | } |
@@ -192,6 +193,13 @@ onBeforeUnmount(() => { | @@ -192,6 +193,13 @@ onBeforeUnmount(() => { | ||
192 | </div> | 193 | </div> |
193 | </div> | 194 | </div> |
194 | 195 | ||
196 | + <!-- Message si aucun film trouvé --> | ||
197 | + <section v-else-if="searchQuery && !movies.length" class="text-center py-12"> | ||
198 | + <SearchXIcon :size="64" class="mx-auto mb-4 text-gray-600" /> | ||
199 | + <h3 class="text-xl font-bold mb-2">Aucun film trouvé</h3> | ||
200 | + <p class="text-gray-400">Essayez avec un autre terme de recherche</p> | ||
201 | + </section> | ||
202 | + | ||
195 | <!-- Élément observé pour le défilement infini --> | 203 | <!-- Élément observé pour le défilement infini --> |
196 | <div ref="loadMoreTrigger" class="h-10 mt-4" /> | 204 | <div ref="loadMoreTrigger" class="h-10 mt-4" /> |
197 | </section> | 205 | </section> |
-
Please register or login to post a comment