List.client.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <div v-if="pending">
  3. <v-row class="justify-center progress">
  4. <v-progress-circular indeterminate color="grey" />
  5. </v-row>
  6. </div>
  7. <div v-else-if="!newsCollection || !newsCollection!.items">
  8. <v-row class="justify-center"> Aucun résultat trouvé </v-row>
  9. </div>
  10. <div v-else>
  11. <v-row
  12. v-for="(newsItem, index) in newsCollection!.items"
  13. :key="index"
  14. class="news d-flex align-center mr-10"
  15. >
  16. <v-card class="alt-theme">
  17. <v-card-item>
  18. <v-container fluid>
  19. <v-row align="center">
  20. <v-col cols="12" lg="3">
  21. <v-img
  22. v-if="newsItem.attachment"
  23. :src="getImageUrl(newsItem.attachment)"
  24. alt="poster"
  25. cover
  26. />
  27. </v-col>
  28. <v-col cols="12" lg="9">
  29. <div class="details">
  30. <NuxtLink
  31. :to="`/actualites/${newsItem.id}`"
  32. class="text-decoration-none"
  33. >
  34. <v-card-title>
  35. {{ newsItem.title }}
  36. <v-icon
  37. v-if="newsItem.featured"
  38. size="16"
  39. icon="star fas fa-star"
  40. />
  41. </v-card-title>
  42. </NuxtLink>
  43. <v-card-text>
  44. <div class="flex-container">
  45. <div class="text-container">
  46. <table>
  47. <tr>
  48. <td>
  49. {{ newsItem.leadText }}
  50. </td>
  51. </tr>
  52. </table>
  53. </div>
  54. <div class="button-container">
  55. <v-card-actions class="justify-end">
  56. <v-btn
  57. :to="`/actualites/${newsItem.id}`"
  58. class="inv-theme btn mr-2 mb-1"
  59. >
  60. En savoir plus
  61. </v-btn>
  62. </v-card-actions>
  63. </div>
  64. </div>
  65. </v-card-text>
  66. </div>
  67. </v-col>
  68. </v-row>
  69. </v-container>
  70. </v-card-item>
  71. </v-card>
  72. </v-row>
  73. <v-row v-if="newsCollection!.items">
  74. <v-col cols="12">
  75. <LayoutPagination
  76. v-if="newsCollection && newsCollection.pagination"
  77. :model-value="page"
  78. :pagination="newsCollection.pagination"
  79. class="mt-4"
  80. @update:model-value="onPageUpdated"
  81. />
  82. </v-col>
  83. </v-row>
  84. </div>
  85. </template>
  86. <script setup lang="ts">
  87. import type { ComputedRef, Ref } from 'vue'
  88. import { useEntityFetch } from '~/composables/data/useEntityFetch'
  89. import News from '~/models/Maestro/News'
  90. const config = useRuntimeConfig()
  91. const { fetchCollection } = useEntityFetch()
  92. const getImageUrl = (attachment: string) =>
  93. `${config.public.apiBaseUrl}/uploads/news/${attachment}`
  94. const page: Ref<number> = ref(1)
  95. const query: ComputedRef<Record<string, string | number>> = computed(() => {
  96. return {
  97. page: page.value,
  98. type: 'BUSINESS',
  99. 'startPublication[before]': 'now',
  100. 'endPublication[after]': 'now',
  101. }
  102. })
  103. const {
  104. data: newsCollection,
  105. pending,
  106. refresh,
  107. } = fetchCollection(News, null, query)
  108. const onPageUpdated = async (newVal: number): Promise<void> => {
  109. page.value = newVal
  110. pending.value = true
  111. await refresh()
  112. setTimeout(
  113. async () => await navigateTo({ path: '', hash: '#news-anchor' }),
  114. 200
  115. )
  116. }
  117. </script>
  118. <style scoped lang="scss">
  119. .v-container {
  120. padding: 0 !important;
  121. }
  122. h1 {
  123. color: #d1cdc7; /* TODO: pqoi cette couleur ici? */
  124. margin-left: 3rem;
  125. margin-top: 2rem;
  126. font-size: 4rem;
  127. font-weight: 600;
  128. line-height: 42px;
  129. @media (max-width: 600px) {
  130. font-size: 2.5rem;
  131. }
  132. }
  133. .news {
  134. .v-card {
  135. border-radius: 14px;
  136. min-width: 100%;
  137. margin-bottom: 1rem;
  138. margin-left: 2rem;
  139. margin-right: 2rem;
  140. padding-top: 0.2rem;
  141. padding-bottom: 0.2rem;
  142. height: 60%;
  143. .v-card-text {
  144. letter-spacing: 0 !important;
  145. padding: 0 !important;
  146. }
  147. .v-card-item {
  148. padding: 0 !important;
  149. }
  150. }
  151. .v-img {
  152. width: 100%;
  153. max-height: 160px;
  154. margin: 12px;
  155. border-radius: 14px;
  156. @media (max-width: 1240px) {
  157. width: 97%;
  158. margin: 1.5%;
  159. }
  160. }
  161. .details {
  162. border: 1px solid var(--neutral-color) !important;
  163. padding: 9px;
  164. border-radius: 24px;
  165. width: 99%;
  166. @media (max-width: 1240px) {
  167. width: 94%;
  168. margin: -18px 3% 12px;
  169. }
  170. .v-card-title {
  171. color: var(--neutral-color);
  172. font-size: 36px;
  173. font-weight: 600;
  174. line-height: 39px;
  175. @media (max-width: 1240px) {
  176. font-size: 24px;
  177. }
  178. }
  179. .star {
  180. color: yellow !important;
  181. }
  182. .v-card-text {
  183. td {
  184. color: var(--neutral-color);
  185. font-size: 22px;
  186. font-weight: 500;
  187. line-height: 26px;
  188. margin-left: 1rem;
  189. }
  190. }
  191. .v-btn {
  192. background: var(--secondary-color);
  193. color: var(--on-secondary-color);
  194. display: flex;
  195. left: 0;
  196. padding: 25px 28px;
  197. align-items: center;
  198. gap: 9px;
  199. font-size: 0.9rem;
  200. border-radius: 5px;
  201. font-weight: 700;
  202. line-height: 15px;
  203. letter-spacing: 1.3px;
  204. text-transform: uppercase;
  205. margin-bottom: -1rem;
  206. }
  207. }
  208. }
  209. </style>