diff --git a/src/router.js b/src/router.js index dc20aa3..22bf210 100644 --- a/src/router.js +++ b/src/router.js @@ -2,7 +2,14 @@ import React, { useEffect } from "react"; import { BrowserRouter, Routes, Route } from "react-router-dom"; import { Navigate } from "react-router-dom"; import { connect } from "react-redux"; -import { publicApi, menu, config, userProduct } from "./redux/actions"; +import { + publicApi, + menu, + config, + userProduct, + book, + blog, +} from "./redux/actions"; import Navbar from "./components/Navbar"; import BG from "./components/BG"; import BottomNavigation from "./components/BottomNavigation"; @@ -47,10 +54,15 @@ function Router({ device, getAvailableForSell, getUserProducts, + getBookList, + getBlogList, }) { useEffect(() => { getAvailableForSell(); getUserProducts(); + getBookList({ vod: true }); + getBlogList(); + window.scroll({ top: 0, behavior: "smooth" }); const width = window.innerWidth; if (width <= 640) { setDevice("mobile"); @@ -627,6 +639,8 @@ const mapDispatchToProps = { setDevice: config.setDevice, getAvailableForSell: config.getAvailableForSell, getUserProducts: userProduct.list, + getBookList: book.list, + getBlogList: blog.list, }; export default connect(mapStateToProps, mapDispatchToProps)(Router); diff --git a/src/views/Blog/index.js b/src/views/Blog/index.js index 6596025..11b1bc9 100644 --- a/src/views/Blog/index.js +++ b/src/views/Blog/index.js @@ -18,18 +18,15 @@ export const Blog = ({ blog, setHeaderOptions, headerOptions, - getList, blogs, }) => { let { id } = useParams(); useEffect(() => { - getList(); setHeaderOptions(headerOptions); }, []); useEffect(() => { - window.scroll({ top: 0, behavior: "smooth" }); getInfo({ id }); }, [id]); @@ -181,7 +178,6 @@ const mapStateToProps = (state) => ({ const mapDispatchToProps = { getInfo: blog.info, - getList: blog.list, setHeaderOptions: publicApi.setHeaderOptions, }; diff --git a/src/views/Blogs/index.js b/src/views/Blogs/index.js index ea58929..ed9a724 100644 --- a/src/views/Blogs/index.js +++ b/src/views/Blogs/index.js @@ -1,6 +1,6 @@ import React, { useEffect } from "react"; import { connect } from "react-redux"; -import { blog, publicApi } from "../../redux/actions"; +import { publicApi } from "../../redux/actions"; import { Carousel } from "@trendyol-js/react-carousel"; import Hashtags from "./layouts/Hashtags"; @@ -17,7 +17,6 @@ import arrow from "../../assets/icons/dropdown-blue.svg"; export const Blogs = ({ isMobile, - getList, blogs, setHeaderOptions, headerOptions, @@ -25,11 +24,6 @@ export const Blogs = ({ }) => { useEffect(() => { setHeaderOptions(headerOptions); - getList(); - }, []); - - useEffect(() => { - window.scroll({ top: 0, behavior: "smooth" }); }, []); return ( @@ -143,7 +137,6 @@ const mapStateToProps = (state) => ({ }); const mapDispatchToProps = { - getList: blog.list, setHeaderOptions: publicApi.setHeaderOptions, }; diff --git a/src/views/Dashboard/layouts/Main/MyBooks/index.js b/src/views/Dashboard/layouts/Main/MyBooks/index.js index 7594afa..fa03405 100644 --- a/src/views/Dashboard/layouts/Main/MyBooks/index.js +++ b/src/views/Dashboard/layouts/Main/MyBooks/index.js @@ -2,19 +2,17 @@ import React, { useEffect } from "react"; import { connect } from "react-redux"; import { Link } from "react-router-dom"; -import Product from "../../../../../components/Product"; import ProductSuggestion from "../UserItems/ProductSuggestion"; import { ScrollingCarousel } from "@trendyol-js/react-carousel"; -import { Book } from "../../../../Home/Portrait/Private/MyBooks"; import Progress from "../../../../../components/Progress"; -export const MyBooks = ({ books, grades, isMobile }) => { +export const MyBooks = ({ books, grades, isMobile, userProducts }) => { const Book = ({ book }) => { return ( -
{`پایه ${ - grades[book.gradeId] + grades[book?.product?.book?.gradeId] }`}
@@ -38,36 +36,39 @@ export const MyBooks = ({ books, grades, isMobile }) => { ); }; - useEffect(() => { - window.scrollTo(0, 0); - }, []); - return (+
{window.t("کتاب های من")}
-