kgroad-frontend2/src/App/news/page.tsx
2024-02-09 19:42:22 +06:00

37 lines
952 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Typography from "@/shared/ui/components/Typography/Typography";
import "./News.scss";
import { apiInstance } from "@/shared/config/apiConfig";
import { INewsList } from "@/shared/types/news-type";
import NewsCard from "@/entities/NewsCard/NewsCard";
const News = async () => {
const getNews = async () => {
const response = await apiInstance.get<INewsList>("/news/");
return response.data;
};
const data = await getNews();
return (
<div className="news page-padding">
<Typography element="h2">Новости</Typography>
<ul className="news__list">
{data.results.map((news) => (
<li key={news.id}>
<NewsCard
id={news.id}
title={news.title}
description={news.description}
image={news.image}
date={news.created_at}
/>
</li>
))}
</ul>
</div>
);
};
export default News;