Merge branch 'main' of https://github.com/VividTruthKeeper/hhm-client
This commit is contained in:
commit
88426851b8
|
|
@ -1,6 +1,5 @@
|
||||||
// Modules
|
// Modules
|
||||||
import { Routes, Route, useLocation } from "react-router-dom";
|
import { Routes, Route, useLocation } from "react-router-dom";
|
||||||
import { AnimatePresence } from "framer-motion";
|
|
||||||
import ScrollToTop from "./hooks/ScrollToTop";
|
import ScrollToTop from "./hooks/ScrollToTop";
|
||||||
|
|
||||||
// Styles
|
// Styles
|
||||||
|
|
@ -18,6 +17,7 @@ import Category from "./pages/Category";
|
||||||
import SearchResult from "./pages/SearchResult";
|
import SearchResult from "./pages/SearchResult";
|
||||||
import AllPosts from "./pages/AllPosts";
|
import AllPosts from "./pages/AllPosts";
|
||||||
import NotFound404 from "./pages/NotFound404";
|
import NotFound404 from "./pages/NotFound404";
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
import Header from "./components/header/Header";
|
import Header from "./components/header/Header";
|
||||||
import Footer from "./components/footer/Footer";
|
import Footer from "./components/footer/Footer";
|
||||||
|
|
@ -47,7 +47,6 @@ const App = () => {
|
||||||
<ScrollToTop>
|
<ScrollToTop>
|
||||||
<div className="App">
|
<div className="App">
|
||||||
<Header />
|
<Header />
|
||||||
<AnimatePresence mode="wait" initial={false}>
|
|
||||||
<Routes location={location} key={location.pathname}>
|
<Routes location={location} key={location.pathname}>
|
||||||
<Route path="/" element={<Main />} />
|
<Route path="/" element={<Main />} />
|
||||||
<Route path="/category/:category" element={<Category />} />
|
<Route path="/category/:category" element={<Category />} />
|
||||||
|
|
@ -56,7 +55,6 @@ const App = () => {
|
||||||
<Route path="/all" element={<AllPosts />} />
|
<Route path="/all" element={<AllPosts />} />
|
||||||
<Route path="*" element={<NotFound404 />} />
|
<Route path="*" element={<NotFound404 />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</AnimatePresence>
|
|
||||||
<Footer />
|
<Footer />
|
||||||
</div>
|
</div>
|
||||||
</ScrollToTop>
|
</ScrollToTop>
|
||||||
|
|
|
||||||
|
|
@ -35,12 +35,10 @@ const ContentSlider = ({ data }: IProps) => {
|
||||||
return (
|
return (
|
||||||
<SwiperSlide key={uuidv4()}>
|
<SwiperSlide key={uuidv4()}>
|
||||||
<ContentItem
|
<ContentItem
|
||||||
id={dataEl.id}
|
id={dataEl?.id}
|
||||||
type="big"
|
type="big"
|
||||||
img={
|
img={dataEl?.featured_images[0]?.path}
|
||||||
dataEl.featured_images ? dataEl.featured_images[0].path : ""
|
title={dataEl?.title}
|
||||||
}
|
|
||||||
title={dataEl.title}
|
|
||||||
/>
|
/>
|
||||||
</SwiperSlide>
|
</SwiperSlide>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,9 @@
|
||||||
// Modules
|
// Modules
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
// import { LazyLoadComponent } from "react-lazy-load-image-component";
|
|
||||||
import { useSelector, useDispatch } from "react-redux";
|
import { useSelector, useDispatch } from "react-redux";
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
import ContentItem from "./ContentItem";
|
import ContentItem from "./ContentItem";
|
||||||
import SectionTitle from "../global/SectionTitle";
|
|
||||||
import ContentSlider from "./ContentSlider";
|
import ContentSlider from "./ContentSlider";
|
||||||
import Loader from "../global/Loader";
|
import Loader from "../global/Loader";
|
||||||
|
|
||||||
|
|
@ -17,6 +15,7 @@ import { url } from "../../url";
|
||||||
import { Api } from "../../api/Api";
|
import { Api } from "../../api/Api";
|
||||||
import { featuredParams } from "../../api/params";
|
import { featuredParams } from "../../api/params";
|
||||||
import { setFeatured } from "../../actions/setData";
|
import { setFeatured } from "../../actions/setData";
|
||||||
|
import { INewPostsData } from "../../types/posts.types";
|
||||||
|
|
||||||
const MainContent = () => {
|
const MainContent = () => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|
@ -27,17 +26,15 @@ const MainContent = () => {
|
||||||
const language = api.language;
|
const language = api.language;
|
||||||
const [lastLanguage, setLastLanguage] = useState<typeof language>(language);
|
const [lastLanguage, setLastLanguage] = useState<typeof language>(language);
|
||||||
|
|
||||||
const getData = () => {
|
|
||||||
api.get(data, (data) => dispatch(setFeatured(data)));
|
|
||||||
};
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!(data.status_code > 0 && language === lastLanguage)) {
|
if (!(data.status_code > 0 && language === lastLanguage)) {
|
||||||
getData();
|
api.get(data, (data: INewPostsData) => dispatch(setFeatured(data)));
|
||||||
setLastLanguage(language);
|
setLastLanguage(language);
|
||||||
}
|
}
|
||||||
}, [language, lastLanguage]);
|
}, [language, lastLanguage]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="main-content-wrapper">
|
||||||
{data.status_code > 0 ? (
|
{data.status_code > 0 ? (
|
||||||
data.data.data.length >= 5 ? (
|
data.data.data.length >= 5 ? (
|
||||||
<div className="main-content">
|
<div className="main-content">
|
||||||
|
|
@ -79,7 +76,7 @@ const MainContent = () => {
|
||||||
) : (
|
) : (
|
||||||
<Loader />
|
<Loader />
|
||||||
)}
|
)}
|
||||||
</>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,11 @@
|
||||||
// Modules
|
// Modules
|
||||||
import { motion } from "framer-motion";
|
|
||||||
import { useState, useEffect, useMemo } from "react";
|
import { useState, useEffect, useMemo } from "react";
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
import Aside from "../components/aside/Aside";
|
import Aside from "../components/aside/Aside";
|
||||||
import NewsScroll from "../components/global/NewsScroll";
|
|
||||||
import CustomNewsScroll from "../components/global/CustomNewsScroll";
|
import CustomNewsScroll from "../components/global/CustomNewsScroll";
|
||||||
import ContentItem from "../components/main/ContentItem";
|
import ContentItem from "../components/main/ContentItem";
|
||||||
import Pagination from "../components/global/Pagination";
|
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
import Loader from "../components/global/Loader";
|
import Loader from "../components/global/Loader";
|
||||||
|
|
@ -43,12 +40,7 @@ const Category = () => {
|
||||||
}, [params]);
|
}, [params]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<motion.main
|
<main className="category">
|
||||||
className="category"
|
|
||||||
initial={{ opacity: 0, scale: 0.8 }}
|
|
||||||
animate={{ opacity: 1, scale: 1, transition: { duration: 0.15 } }}
|
|
||||||
exit={{ opacity: 0, scale: 0.8, transition: { duration: 0.15 } }}
|
|
||||||
>
|
|
||||||
<div className="container">
|
<div className="container">
|
||||||
<div className="category-inner">
|
<div className="category-inner">
|
||||||
<div className="category-left">
|
<div className="category-left">
|
||||||
|
|
@ -76,7 +68,7 @@ const Category = () => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</motion.main>
|
</main>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,3 @@
|
||||||
// Modules
|
|
||||||
import { motion } from "framer-motion";
|
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
import Aside from "../components/aside/Aside";
|
import Aside from "../components/aside/Aside";
|
||||||
import NewsScroll from "../components/global/NewsScroll";
|
import NewsScroll from "../components/global/NewsScroll";
|
||||||
|
|
@ -9,12 +6,7 @@ import MainContent from "../components/main/MainContent";
|
||||||
|
|
||||||
const Main = () => {
|
const Main = () => {
|
||||||
return (
|
return (
|
||||||
<motion.main
|
<main className="main">
|
||||||
className="main"
|
|
||||||
initial={{ opacity: 0, scale: 0.8 }}
|
|
||||||
animate={{ opacity: 1, scale: 1, transition: { duration: 0.15 } }}
|
|
||||||
exit={{ opacity: 0, scale: 0.8, transition: { duration: 0.15 } }}
|
|
||||||
>
|
|
||||||
<h1 style={{ display: "none" }}>Туркменистан новостной портал</h1>
|
<h1 style={{ display: "none" }}>Туркменистан новостной портал</h1>
|
||||||
<div className="news-section">
|
<div className="news-section">
|
||||||
<div className="container">
|
<div className="container">
|
||||||
|
|
@ -28,7 +20,7 @@ const Main = () => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</motion.main>
|
</main>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,13 @@ import { Link, useParams } from "react-router-dom";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useSelector, useDispatch } from "react-redux";
|
import { useSelector, useDispatch } from "react-redux";
|
||||||
import { v4 as uuidv4 } from "uuid";
|
import { v4 as uuidv4 } from "uuid";
|
||||||
import { motion } from "framer-motion";
|
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
import Aside from "../components/aside/Aside";
|
import Aside from "../components/aside/Aside";
|
||||||
import NewsArticleSlider from "../components/news/NewsArticleSlider";
|
import NewsArticleSlider from "../components/news/NewsArticleSlider";
|
||||||
import Loader from "../components/global/Loader";
|
import Loader from "../components/global/Loader";
|
||||||
// import VideosItem from "../components/videos/VideosItem";
|
|
||||||
|
|
||||||
// Icons
|
// Icons
|
||||||
import { ReactComponent as Share } from "../assets/icons/share.svg";
|
|
||||||
import { ReactComponent as View } from "../assets/icons/eye.svg";
|
import { ReactComponent as View } from "../assets/icons/eye.svg";
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
|
|
@ -67,12 +64,7 @@ const NewsArticle = () => {
|
||||||
}, [data]);
|
}, [data]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<motion.div
|
<div className="news-article">
|
||||||
className="news-article"
|
|
||||||
initial={{ opacity: 0, scale: 0.8 }}
|
|
||||||
animate={{ opacity: 1, scale: 1, transition: { duration: 0.15 } }}
|
|
||||||
exit={{ opacity: 0, scale: 0.8, transition: { duration: 0.15 } }}
|
|
||||||
>
|
|
||||||
<div className="container">
|
<div className="container">
|
||||||
<div className="news-article-inner">
|
<div className="news-article-inner">
|
||||||
{data.data.id > -1 ? (
|
{data.data.id > -1 ? (
|
||||||
|
|
@ -103,18 +95,6 @@ const NewsArticle = () => {
|
||||||
<h2 className="news-article-title">{data.data.title}</h2>
|
<h2 className="news-article-title">{data.data.title}</h2>
|
||||||
</div>
|
</div>
|
||||||
<div className="news-article-slider-wrapper">
|
<div className="news-article-slider-wrapper">
|
||||||
{/* {data.data.video ? (
|
|
||||||
<VideosItem
|
|
||||||
url={data.data.video}
|
|
||||||
placeholder={
|
|
||||||
data.data.featured_images[0]
|
|
||||||
? data.data.featured_images[0].path
|
|
||||||
: ""
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<NewsArticleSlider images={data.data.featured_images} />
|
|
||||||
)} */}
|
|
||||||
<NewsArticleSlider
|
<NewsArticleSlider
|
||||||
images={data.data.featured_images}
|
images={data.data.featured_images}
|
||||||
video={data.data.video}
|
video={data.data.video}
|
||||||
|
|
@ -124,9 +104,6 @@ const NewsArticle = () => {
|
||||||
className="news-article-text"
|
className="news-article-text"
|
||||||
dangerouslySetInnerHTML={{ __html: data.data.content_html }}
|
dangerouslySetInnerHTML={{ __html: data.data.content_html }}
|
||||||
></p>
|
></p>
|
||||||
{/* <button className="share-btn">
|
|
||||||
<Share /> <span>Поделиться</span>
|
|
||||||
</button> */}
|
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<Loader />
|
<Loader />
|
||||||
|
|
@ -134,7 +111,7 @@ const NewsArticle = () => {
|
||||||
<Aside type="latest" />
|
<Aside type="latest" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</motion.div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue