mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-05 15:29:50 +00:00
Take into account case when there are no active news
This commit is contained in:
parent
53d18c7748
commit
6787612071
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div>
|
||||
<div v-if="newsItems.length > 0">
|
||||
<h1>{{ $t('widget.news.title') }}</h1>
|
||||
<ul class="scrollable">
|
||||
<NewsItem v-for="item in newsItems" :item="item" :key="item.id" />
|
||||
@ -9,7 +9,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { makeFetch } from '../../../lib/api/apiMethods';
|
||||
import { fetchResults } from '../../../lib/api/apiMethods';
|
||||
import Modal from '../../_components/Modal.vue';
|
||||
import { NewsItemType } from '../../../types';
|
||||
import NewsItem from './NewsItem.vue';
|
||||
@ -17,10 +17,12 @@ import NewsItem from './NewsItem.vue';
|
||||
const newsItems = ref<NewsItemType[]>([])
|
||||
|
||||
onMounted(() => {
|
||||
makeFetch('GET', '/api/1.0/main/news.json')
|
||||
.then((response: { results: NewsItemType[] }) => {
|
||||
fetchResults<NewsItemType>('/api/1.0/main/news/current.json')
|
||||
.then((news): Promise<void> => {
|
||||
// console.log('news articles', response.results)
|
||||
newsItems.value = response.results
|
||||
newsItems.value = news;
|
||||
|
||||
return Promise.resolve();
|
||||
})
|
||||
.catch((error: string) => {
|
||||
console.error('Error fetching news items', error);
|
||||
|
@ -40,9 +40,9 @@
|
||||
</div>
|
||||
|
||||
<div class="mbloc col col-lg-12 col-lg-4" v-if="this.dashboardItems">
|
||||
<div v-for="dashboardItem in this.dashboardItems">
|
||||
<template v-for="dashboardItem in this.dashboardItems">
|
||||
<News v-if="dashboardItem.type === 'news'"/>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user