EventList.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <div>
  3. <v-list>
  4. <v-list-item
  5. class="event-item"
  6. v-for="event in events"
  7. :key="event.id"
  8. :subtitle="formatDate(event.date)"
  9. :title="event.name"
  10. >
  11. <template v-slot:prepend>
  12. <v-avatar color="grey-lighten-1">
  13. <v-img :src="event.image" alt="Image de l'événement" />
  14. </v-avatar>
  15. </template>
  16. <template v-slot:append>
  17. <v-avatar color="primary" @click="$emit('edit', event.id)">
  18. <v-icon>fas fa-pencil</v-icon>
  19. </v-avatar>
  20. <v-avatar color="error" @click="$emit('delete', event.id)">
  21. <v-icon>fas fa-trash</v-icon>
  22. </v-avatar>
  23. </template>
  24. </v-list-item>
  25. </v-list>
  26. <div class="d-flex justify-space-between px-4 py-2">
  27. <v-btn variant="outlined" @click="$emit('load-prev')">Précédents</v-btn>
  28. <v-btn variant="outlined" @click="$emit('load-next')">Suivants</v-btn>
  29. </div>
  30. </div>
  31. </template>
  32. <script lang="ts" setup>
  33. import { defineProps, defineEmits } from 'vue'
  34. interface Event {
  35. id: number
  36. name: string
  37. date: string
  38. location: string
  39. image: string
  40. }
  41. const props = defineProps<{ events: Event[] }>()
  42. const emits = defineEmits(['edit', 'delete', 'load-next', 'load-prev'])
  43. function formatDate(dateStr: string): string {
  44. const date = new Date(dateStr)
  45. return date.toLocaleDateString('fr-FR', {
  46. weekday: 'long',
  47. year: 'numeric',
  48. month: 'long',
  49. day: 'numeric',
  50. })
  51. }
  52. </script>
  53. <style scoped>
  54. .event-item {
  55. margin-top: 20px;
  56. }
  57. </style>