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