all posts

This commit is contained in:
VividTruthKeeper 2023-02-23 09:30:32 +05:00
parent bd85604a2c
commit 3c452f9ad1
3 changed files with 45 additions and 2 deletions

View File

@ -17,12 +17,12 @@ import Main from "./pages/Main";
import NewsArticle from "./pages/NewsArticle";
import Category from "./pages/Category";
import SearchResult from "./pages/SearchResult";
import AllPosts from "./pages/AllPosts";
// Components
import Header from "./components/header/Header";
import Footer from "./components/footer/Footer";
import { Api } from "./api/Api";
// import { useEffect } from "react";
const App = () => {
const location = useLocation();
@ -42,6 +42,7 @@ const App = () => {
<Route path="/category/:category" element={<Category />} />
<Route path="/news/:id" element={<NewsArticle />} />
<Route path="/search/:word" element={<SearchResult />} />
<Route path="/all/:category" element={<AllPosts />} />
</Routes>
</AnimatePresence>
<Footer />

View File

@ -74,7 +74,7 @@ const NewsScroll = ({ title, category }: Props) => {
{title === true ? (
<SectionTitle
title="Лента новостей"
linkData={{ link: "/", title: "Посмотреть все" }}
linkData={{ link: "/all/", title: "Посмотреть все" }}
/>
) : null}
<div className="news-scroll-inner">

42
src/pages/AllPosts.tsx Normal file
View File

@ -0,0 +1,42 @@
// Modules
import { useState, useEffect } from "react";
import { useParams } from "react-router-dom";
// Api
import { Api } from "../api/Api";
import { url } from "../url";
// Components
import CustomNewsScroll from "../components/global/CustomNewsScroll";
import { IurlParamAdder } from "../types/api.types";
const AllPosts = () => {
const { category } = useParams();
const api = new Api(url + category);
const language = api.language;
const [params, setParams] = useState<IurlParamAdder[]>([
{
name: "count",
value: 10,
},
]);
const [lastLanguage, setLastLanguage] = useState<typeof language>(language);
useEffect(() => {
if (language !== lastLanguage) {
// api.get()
}
}, [language, lastLanguage]);
return (
<main className="all">
<div className="container">
<div className="all-inner"></div>
</div>
</main>
);
};
export default AllPosts;