diff --git a/api/queries.ts b/api/queries.ts index 776ed2c..dd05bc8 100644 --- a/api/queries.ts +++ b/api/queries.ts @@ -7,7 +7,7 @@ import { ChannelsModel } from '@/models/channels.model'; import { HomeModel } from '@/models/home.model'; import { LiveDescriptionModel } from '@/models/liveDescription.model'; import { MarqueeModel } from '@/models/marquee.model'; -import { NewsModel } from '@/models/news.model'; +import { NewsModel, NewsType } from '@/models/news.model'; import { NewsItemModel } from '@/models/newsItem.model'; import { PageItemModel } from '@/models/pageItem.model'; import { PlansModel } from '@/models/plans.model'; @@ -37,11 +37,17 @@ export class Queries { } public static async getlastNews(): Promise { - return await fetch(`https://turkmentv.gov.tm/v2/api/slider?type=small3`, { + return await fetch(`${baseUrl.NEWS_SRC}${routes.news}?locale=tm&count=5`, { next: { revalidate: 3600 }, }).then((res) => res.json().then((res) => res as NewsModel)); } + public static async getHomeBanner3(): Promise { + return await fetch(`https://turkmentv.gov.tm/v2/api/slider?type=small3`, { + next: { revalidate: 3600 }, + }).then((res) => res.json().then((res) => res as NewsType)); + } + public static async getNewsItem(id: string): Promise { return await fetch(`${baseUrl.NEWS_SRC}${routes.newsItem(id)}?locale=tm`, { next: { revalidate: 3600 }, diff --git a/components/home/SmallSwiperNews.tsx b/components/home/SmallSwiperNews.tsx index f5db95d..e131cc4 100644 --- a/components/home/SmallSwiperNews.tsx +++ b/components/home/SmallSwiperNews.tsx @@ -13,7 +13,7 @@ import LinkBlock from './LinkBlock'; const SmallSwiperNews = () => { const { data, isFetching, error } = useQuery({ queryKey: ['small_slider_news'], - queryFn: () => Queries.getlastNews(), + queryFn: () => Queries.getHomeBanner3(), }); if (isFetching) return ; diff --git a/models/news.model.ts b/models/news.model.ts index 304e03f..7e5802b 100644 --- a/models/news.model.ts +++ b/models/news.model.ts @@ -1,82 +1,82 @@ -// export interface NewsModel { -// data: Datum[]; -// links: Links; -// meta: Meta; -// } - -// export interface Datum { -// id: number; -// title: string; -// slug: string; -// excerpt: string; -// published_at: string; -// type: Type; -// awtor: Awtor; -// featured_images: FeaturedImage[]; -// video: string; -// categories: Category[]; -// } - -// export enum Awtor { -// Hhm = "HHM", -// Миц = "МИЦ", -// Ннм = "ННМ", -// } - -// export interface Category { -// id: number; -// name: string; -// powerseo_title: Powerseo | null; -// powerseo_description: Powerseo | null; -// powerseo_keywords: Powerseo | null; -// } - -// export enum Powerseo { -// Novosti = "Novosti", -// VTurkmenistane = "V Turkmenistane", -// } - -// export interface FeaturedImage { -// id: number; -// disk_name: string; -// file_name: string; -// path: string; -// extension: Extension; -// } - -// export enum Extension { -// JPEG = "jpeg", -// Jpg = "jpg", -// PNG = "png", -// } - -// export enum Type { -// Photo = "photo", -// Video = "video", -// } - -// export interface Links { -// first: string; -// last: string; -// prev: null; -// next: string; -// } - -// export interface Meta { -// current_page: number; -// from: number; -// last_page: number; -// path: string; -// per_page: number; -// to: number; -// total: number; -// } - export interface NewsModel { data: Datum[]; + links: Links; + meta: Meta; } export interface Datum { + id: number; + title: string; + slug: string; + excerpt: string; + published_at: string; + type: Type; + awtor: Awtor; + featured_images: FeaturedImage[]; + video: string; + categories: Category[]; +} + +export enum Awtor { + Hhm = 'HHM', + Миц = 'МИЦ', + Ннм = 'ННМ', +} + +export interface Category { + id: number; + name: string; + powerseo_title: Powerseo | null; + powerseo_description: Powerseo | null; + powerseo_keywords: Powerseo | null; +} + +export enum Powerseo { + Novosti = 'Novosti', + VTurkmenistane = 'V Turkmenistane', +} + +export interface FeaturedImage { + id: number; + disk_name: string; + file_name: string; + path: string; + extension: Extension; +} + +export enum Extension { + JPEG = 'jpeg', + Jpg = 'jpg', + PNG = 'png', +} + +export enum Type { + Photo = 'photo', + Video = 'video', +} + +export interface Links { + first: string; + last: string; + prev: null; + next: string; +} + +export interface Meta { + current_page: number; + from: number; + last_page: number; + path: string; + per_page: number; + to: number; + total: number; +} + +export interface NewsType { + data: Datu[]; +} + +export interface Datu { id: number; title: string; url: null | string;