Details.client.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <LayoutContainer>
  3. <div class="news-section">
  4. <v-row class="mb-6 center-90">
  5. <v-col class="d-flex align-items-center">
  6. <v-btn
  7. to="/actualites"
  8. prepend-icon="fas fa-arrow-left"
  9. variant="outlined"
  10. class="back-button"
  11. >
  12. Retour aux actualités
  13. </v-btn>
  14. </v-col>
  15. </v-row>
  16. <div>
  17. <div v-if="pending">
  18. <v-row class="justify-center progress">
  19. <v-progress-circular indeterminate color="grey" />
  20. </v-row>
  21. </div>
  22. <div v-else-if="newsItem !== null" class="news">
  23. <CommonMeta
  24. :title="() => newsItem.title"
  25. :description="() => newsItem.leadText"
  26. :image="() => newsItem.image"
  27. />
  28. <v-row class="center-90 mb-12">
  29. <v-col cols="12" md="6">
  30. <v-img :src="getImageUrl(newsItem.attachment)" cover />
  31. </v-col>
  32. <v-col cols="12" md="6" class="d-flex flex-column justify-center">
  33. <h3>
  34. {{ newsItem.title }}
  35. </h3>
  36. <strong>
  37. {{ newsItem.leadText }}
  38. </strong>
  39. <p>
  40. {{ formattedPublicationDate }}
  41. </p>
  42. </v-col>
  43. </v-row>
  44. <v-row class="center-90">
  45. <p class="description" v-html="newsItem.bodyText" />
  46. </v-row>
  47. <v-row class="d-flex justify-center align-center">
  48. <v-btn
  49. v-if="newsItem.linkButton"
  50. :href="newsItem.linkButton"
  51. target="_blank"
  52. class="btn-plus mb-12"
  53. :text="true"
  54. >
  55. En savoir plus
  56. </v-btn>
  57. </v-row>
  58. <v-row class="d-flex justify-space-between center-90">
  59. <div>
  60. <p v-if="newsItem.tags.length > 0">MOTS CLÉS</p>
  61. </div>
  62. <div v-if="mdAndUp">
  63. <p>PARTAGER</p>
  64. </div>
  65. </v-row>
  66. <v-row class="d-flex justify-space-between mb-8 center-90">
  67. <p class="key-word mt-3">
  68. <span v-for="tag in newsItem.tags" :key="tag.id" class="mr-2">
  69. {{ tag.name }}
  70. </span>
  71. </p>
  72. <CommonShare v-if="mdAndUp" />
  73. </v-row>
  74. <div v-if="smAndDown" class="center-90">
  75. <p>PARTAGER</p>
  76. <CommonShare />
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. </LayoutContainer>
  82. </template>
  83. <script setup lang="ts">
  84. import { useDisplay } from 'vuetify'
  85. import { parseISO, format } from 'date-fns'
  86. import { fr } from 'date-fns/locale'
  87. import type { ComputedRef } from 'vue'
  88. import { useEntityFetch } from '~/composables/data/useEntityFetch'
  89. import News from '~/models/Maestro/News'
  90. const { mdAndUp, smAndDown } = useDisplay()
  91. const route = useRoute()
  92. const { fetch } = useEntityFetch()
  93. const config = useRuntimeConfig()
  94. const newsId: number = parseInt(route.params.id as string)
  95. if (!newsId || isNaN(newsId)) {
  96. throw new Error('Missing or invalid id')
  97. }
  98. const { data: newsItem, pending } = fetch(News, newsId)
  99. const getImageUrl = (attachment: string): string | null => {
  100. if (!attachment) {
  101. return null
  102. }
  103. return `${config.public.apiBaseUrl}/uploads/news/${attachment}`
  104. }
  105. const formattedPublicationDate: ComputedRef<string> = computed(() => {
  106. if (pending.value || !newsItem.value) {
  107. return ''
  108. }
  109. const date = parseISO(newsItem.value.startPublication)
  110. let formattedPublicationDate = format(date, "'Le' dd MMMM yyyy", {
  111. locale: fr,
  112. })
  113. formattedPublicationDate = formattedPublicationDate.replace(
  114. 'Le 01 ',
  115. 'Le 1er '
  116. )
  117. return formattedPublicationDate
  118. })
  119. </script>
  120. <style scoped>
  121. .news {
  122. .v-img {
  123. max-height: 600px;
  124. margin-left: auto;
  125. margin-right: auto;
  126. }
  127. h3 {
  128. text-decoration: none;
  129. text-transform: uppercase;
  130. font-size: 36px;
  131. font-weight: 600;
  132. color: var(--primary-color);
  133. }
  134. strong {
  135. font-size: 21px;
  136. margin-top: 16px;
  137. }
  138. .description {
  139. color: var(--primary-color);
  140. max-width: 80%;
  141. font-size: 21px;
  142. font-weight: 500;
  143. line-height: 34px;
  144. margin-left: auto;
  145. margin-right: auto;
  146. margin-bottom: 3rem;
  147. }
  148. .btn-plus {
  149. background: var(--secondary-color);
  150. color: var(--on-secondary-color);
  151. display: flex;
  152. left: 0;
  153. padding: 25px 28px;
  154. align-items: center;
  155. gap: 9px;
  156. font-size: 0.9rem;
  157. border-radius: 5px;
  158. font-weight: 700;
  159. line-height: 15px;
  160. letter-spacing: 1.3px;
  161. text-transform: uppercase;
  162. margin-bottom: -1rem;
  163. }
  164. }
  165. .back-button {
  166. text-decoration: none;
  167. color: var(--on-neutral-color);
  168. font-size: 0.9rem;
  169. font-weight: 700;
  170. line-height: 15px;
  171. letter-spacing: 1.8px;
  172. text-transform: uppercase;
  173. }
  174. .key-word {
  175. color: var(--on-neutral-color);
  176. font-size: 20px;
  177. font-weight: 500;
  178. line-height: 24px;
  179. }
  180. </style>