Commit a7c21989 by asranov0003

refactor: news

parent a513873f
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
padding-top: 60px; padding-top: 60px;
} }
.news__title {
margin-bottom: 1rem;
}
.news__list { .news__list {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
......
...@@ -7,12 +7,14 @@ import { ...@@ -7,12 +7,14 @@ import {
type RootState, type RootState,
} from "../../stores/store"; } from "../../stores/store";
import { fetchAllNews } from "../../stores/slices/newsSlice"; import { fetchAllNews } from "../../stores/slices/newsSlice";
import { useTranslation } from "react-i18next";
const News: React.FC = () => { const News: React.FC = () => {
const { news, isNewsLoading } = useAppSelector( const { news, isNewsLoading } = useAppSelector(
(state: RootState) => state.news (state: RootState) => state.news
); );
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const { t } = useTranslation();
useEffect(() => { useEffect(() => {
dispatch(fetchAllNews()); dispatch(fetchAllNews());
...@@ -20,12 +22,18 @@ const News: React.FC = () => { ...@@ -20,12 +22,18 @@ const News: React.FC = () => {
return ( return (
<div className="news wrapper"> <div className="news wrapper">
<h3 className="news__title">{t("navs.news")}</h3>
{isNewsLoading && news.length === 0 && ( {isNewsLoading && news.length === 0 && (
<div className="cloading__center"> <div className="cloading__center">
<CLoading /> <CLoading />
</div> </div>
)} )}
{!isNewsLoading && news.length === 0 && (
<p className="news__empty">{t("common.noData")}</p>
)}
<div className="news__list"> <div className="news__list">
{news.map((item) => { {news.map((item) => {
return ( return (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment