Bruno Predot

Ajout section supplémentaire si aucun commentaire existant dans le store.

1 <script setup lang="ts"> 1 <script setup lang="ts">
2 //#region --Import--. 2 //#region --Import--.
3 import type { MovieCommentInterface } from "~/interfaces/movieComment"; 3 import type { MovieCommentInterface } from "~/interfaces/movieComment";
  4 +import { MessageSquareIcon } from "lucide-vue-next";
4 //#endregion 5 //#endregion
5 6
6 //#region --Props--. 7 //#region --Props--.
@@ -15,6 +16,7 @@ defineProps({ @@ -15,6 +16,7 @@ defineProps({
15 </script> 16 </script>
16 17
17 <template> 18 <template>
  19 + <section>
18 <!-- Liste des commentaires --> 20 <!-- Liste des commentaires -->
19 <section v-if="comments.length > 0" class="mt-10"> 21 <section v-if="comments.length > 0" class="mt-10">
20 <h2>Commentaires publiés</h2> 22 <h2>Commentaires publiés</h2>
@@ -24,17 +26,23 @@ defineProps({ @@ -24,17 +26,23 @@ defineProps({
24 class="bg-gray-800 rounded-lg p-6 mb-4" 26 class="bg-gray-800 rounded-lg p-6 mb-4"
25 > 27 >
26 <div class="flex justify-between items-start mb-2"> 28 <div class="flex justify-between items-start mb-2">
27 - <div> 29 + <section>
28 <h4 class="font-bold text-lg">Par {{ comment.username }}</h4> 30 <h4 class="font-bold text-lg">Par {{ comment.username }}</h4>
29 <p class="text-sm text-gray-400">Le {{ useDateFormat(comment.createdAt, "DD-MM-YYYY") }}</p> 31 <p class="text-sm text-gray-400">Le {{ useDateFormat(comment.createdAt, "DD-MM-YYYY") }}</p>
30 - </div> 32 + </section>
31 - <div class="bg-primary text-white rounded-full w-10 h-10 flex items-center justify-center font-bold"> 33 + <section class="bg-primary text-white rounded-full w-10 h-10 flex items-center justify-center font-bold">
32 {{ comment.rating }} 34 {{ comment.rating }}
33 - </div> 35 + </section>
34 </div> 36 </div>
35 <p class="text-gray-300">{{ comment.message }}</p> 37 <p class="text-gray-300">{{ comment.message }}</p>
36 </div> 38 </div>
37 </section> 39 </section>
  40 + <!-- Si aucun commentaire -->
  41 + <section v-else class="text-center py-8 bg-gray-800 rounded-lg mt-10">
  42 + <MessageSquareIcon :size="48" class="mx-auto mb-3 text-gray-600" />
  43 + <p class="text-gray-400">Aucun commentaire pour le moment. Soyez le premier à donner votre avis !</p>
  44 + </section>
  45 + </section>
38 </template> 46 </template>
39 47
40 <style scoped> 48 <style scoped>