Correctif typage + ajout section supplémentaire si le film n'est pas retrouvé.
Showing
1 changed file
with
28 additions
and
7 deletions
1 | <script lang="ts" setup> | 1 | <script lang="ts" setup> |
2 | //#region --import--. | 2 | //#region --import--. |
3 | -import { ArrowLeftIcon } from "lucide-vue-next"; | 3 | +import { AlertTriangleIcon, ArrowLeftIcon } from "lucide-vue-next"; |
4 | import { useTMDB } from "~/composables/tMDB"; | 4 | import { useTMDB } from "~/composables/tMDB"; |
5 | import { computed, onMounted, ref } from "vue"; | 5 | import { computed, onMounted, ref } from "vue"; |
6 | import { Movie } from "~/models/movie"; | 6 | import { Movie } from "~/models/movie"; |
@@ -12,6 +12,7 @@ import { MovieComment } from "~/models/movieComment"; | @@ -12,6 +12,7 @@ import { MovieComment } from "~/models/movieComment"; | ||
12 | // Infos sur le composable date de Vuetify : https://vuetifyjs.com/en/features/dates/ | 12 | // Infos sur le composable date de Vuetify : https://vuetifyjs.com/en/features/dates/ |
13 | // Et l'api date : https://vuetifyjs.com/en/api/use-date/#exposed | 13 | // Et l'api date : https://vuetifyjs.com/en/api/use-date/#exposed |
14 | import { useDate } from "vuetify"; | 14 | import { useDate } from "vuetify"; |
15 | +import { WhereSecondaryClosure } from "pinia-orm"; | ||
15 | //#endregion | 16 | //#endregion |
16 | 17 | ||
17 | //#region --Declaration--. | 18 | //#region --Declaration--. |
@@ -47,8 +48,11 @@ const movieId = computed(() => { | @@ -47,8 +48,11 @@ const movieId = computed(() => { | ||
47 | 48 | ||
48 | const movie = computed(() => { | 49 | const movie = computed(() => { |
49 | if (unref(movieId)) { | 50 | if (unref(movieId)) { |
50 | - // Todo : revoir ici. | 51 | + return useRepo(Movie) |
51 | - return useRepo(Movie).query().where("id", movieId.value).withAll().first() as unknown as MovieInterface; | 52 | + .query() |
53 | + .where("id", movieId.value as WhereSecondaryClosure<never> | null | undefined) | ||
54 | + .withAll() | ||
55 | + .first() as unknown as MovieInterface; | ||
52 | } else { | 56 | } else { |
53 | return null; | 57 | return null; |
54 | } | 58 | } |
@@ -69,10 +73,14 @@ const director = computed(() => { | @@ -69,10 +73,14 @@ const director = computed(() => { | ||
69 | * Retourne les commentaires liés au film, du plus récent au plus ancien. | 73 | * Retourne les commentaires liés au film, du plus récent au plus ancien. |
70 | */ | 74 | */ |
71 | const comments = computed(() => { | 75 | const comments = computed(() => { |
72 | - return useRepo(MovieComment).query().where(comment => { | 76 | + return useRepo(MovieComment) |
77 | + .query() | ||
78 | + .where((comment) => { | ||
73 | const searched = comment as unknown as MovieCommentInterface; | 79 | const searched = comment as unknown as MovieCommentInterface; |
74 | - return searched.movie_id === unref(movieId) | 80 | + return searched.movie_id === unref(movieId); |
75 | - }).orderBy('createdAt', 'desc').get(); | 81 | + }) |
82 | + .orderBy("createdAt", "desc") | ||
83 | + .get(); | ||
76 | }); | 84 | }); |
77 | //#endregion | 85 | //#endregion |
78 | 86 | ||
@@ -123,7 +131,7 @@ async function fetchCredits(id: number | string) { | @@ -123,7 +131,7 @@ async function fetchCredits(id: number | string) { | ||
123 | function handleSubmitEvent(event: MovieCommentInterface) { | 131 | function handleSubmitEvent(event: MovieCommentInterface) { |
124 | isSubmitting.value = true; | 132 | isSubmitting.value = true; |
125 | event.movie_id = unref(movieId); | 133 | event.movie_id = unref(movieId); |
126 | - event.createdAt = `${new Date(Date.now())}` | 134 | + event.createdAt = `${new Date(Date.now())}`; |
127 | useRepo(MovieComment).save(event); | 135 | useRepo(MovieComment).save(event); |
128 | isSubmitting.value = false; | 136 | isSubmitting.value = false; |
129 | } | 137 | } |
@@ -212,6 +220,19 @@ onMounted(() => { | @@ -212,6 +220,19 @@ onMounted(() => { | ||
212 | </div> | 220 | </div> |
213 | </div> | 221 | </div> |
214 | </div> | 222 | </div> |
223 | + | ||
224 | + <!-- Erreur --> | ||
225 | + <section v-else class="container mx-auto px-4 py-16 text-center"> | ||
226 | + <AlertTriangleIcon :size="64" class="mx-auto mb-4 text-red-500" /> | ||
227 | + <h2 class="text-2xl font-bold mb-2">Film non trouvé</h2> | ||
228 | + <p class="text-gray-400 mb-6">Nous n'avons pas pu trouver le film que vous cherchez.</p> | ||
229 | + <button | ||
230 | + class="px-6 py-2 bg-primary text-white font-bold rounded-md hover:bg-primary-dark transition-colors" | ||
231 | + @click="navigateTo('/')" | ||
232 | + > | ||
233 | + Retour à l'accueil | ||
234 | + </button> | ||
235 | + </section> | ||
215 | </section> | 236 | </section> |
216 | </template> | 237 | </template> |
217 | 238 |
-
Please register or login to post a comment