update 13 files

master
Reza_ashrafi 2 years ago
parent 35cde1c121
commit fab86aa933
  1. 16
      src/router.js
  2. 4
      src/views/Blog/index.js
  3. 9
      src/views/Blogs/index.js
  4. 41
      src/views/Dashboard/layouts/Main/MyBooks/index.js
  5. 8
      src/views/Dashboard/layouts/Main/UserItems/ProductSuggestion/index.js
  6. 9
      src/views/Home/Desktop/index.js
  7. 20
      src/views/Home/Portrait/Private/index.js
  8. 4
      src/views/Home/index.js
  9. 2
      src/views/Product/index.js
  10. 5
      src/views/Products/index.js
  11. 1
      src/views/Products/layouts/Desktop/Main.js
  12. 6
      src/views/ShoppingCart/index.js
  13. 20
      src/views/Videos/index.js

@ -2,7 +2,14 @@ import React, { useEffect } from "react";
import { BrowserRouter, Routes, Route } from "react-router-dom"; import { BrowserRouter, Routes, Route } from "react-router-dom";
import { Navigate } from "react-router-dom"; import { Navigate } from "react-router-dom";
import { connect } from "react-redux"; 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 Navbar from "./components/Navbar";
import BG from "./components/BG"; import BG from "./components/BG";
import BottomNavigation from "./components/BottomNavigation"; import BottomNavigation from "./components/BottomNavigation";
@ -47,10 +54,15 @@ function Router({
device, device,
getAvailableForSell, getAvailableForSell,
getUserProducts, getUserProducts,
getBookList,
getBlogList,
}) { }) {
useEffect(() => { useEffect(() => {
getAvailableForSell(); getAvailableForSell();
getUserProducts(); getUserProducts();
getBookList({ vod: true });
getBlogList();
window.scroll({ top: 0, behavior: "smooth" });
const width = window.innerWidth; const width = window.innerWidth;
if (width <= 640) { if (width <= 640) {
setDevice("mobile"); setDevice("mobile");
@ -627,6 +639,8 @@ const mapDispatchToProps = {
setDevice: config.setDevice, setDevice: config.setDevice,
getAvailableForSell: config.getAvailableForSell, getAvailableForSell: config.getAvailableForSell,
getUserProducts: userProduct.list, getUserProducts: userProduct.list,
getBookList: book.list,
getBlogList: blog.list,
}; };
export default connect(mapStateToProps, mapDispatchToProps)(Router); export default connect(mapStateToProps, mapDispatchToProps)(Router);

@ -18,18 +18,15 @@ export const Blog = ({
blog, blog,
setHeaderOptions, setHeaderOptions,
headerOptions, headerOptions,
getList,
blogs, blogs,
}) => { }) => {
let { id } = useParams(); let { id } = useParams();
useEffect(() => { useEffect(() => {
getList();
setHeaderOptions(headerOptions); setHeaderOptions(headerOptions);
}, []); }, []);
useEffect(() => { useEffect(() => {
window.scroll({ top: 0, behavior: "smooth" });
getInfo({ id }); getInfo({ id });
}, [id]); }, [id]);
@ -181,7 +178,6 @@ const mapStateToProps = (state) => ({
const mapDispatchToProps = { const mapDispatchToProps = {
getInfo: blog.info, getInfo: blog.info,
getList: blog.list,
setHeaderOptions: publicApi.setHeaderOptions, setHeaderOptions: publicApi.setHeaderOptions,
}; };

@ -1,6 +1,6 @@
import React, { useEffect } from "react"; import React, { useEffect } from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { blog, publicApi } from "../../redux/actions"; import { publicApi } from "../../redux/actions";
import { Carousel } from "@trendyol-js/react-carousel"; import { Carousel } from "@trendyol-js/react-carousel";
import Hashtags from "./layouts/Hashtags"; import Hashtags from "./layouts/Hashtags";
@ -17,7 +17,6 @@ import arrow from "../../assets/icons/dropdown-blue.svg";
export const Blogs = ({ export const Blogs = ({
isMobile, isMobile,
getList,
blogs, blogs,
setHeaderOptions, setHeaderOptions,
headerOptions, headerOptions,
@ -25,11 +24,6 @@ export const Blogs = ({
}) => { }) => {
useEffect(() => { useEffect(() => {
setHeaderOptions(headerOptions); setHeaderOptions(headerOptions);
getList();
}, []);
useEffect(() => {
window.scroll({ top: 0, behavior: "smooth" });
}, []); }, []);
return ( return (
@ -143,7 +137,6 @@ const mapStateToProps = (state) => ({
}); });
const mapDispatchToProps = { const mapDispatchToProps = {
getList: blog.list,
setHeaderOptions: publicApi.setHeaderOptions, setHeaderOptions: publicApi.setHeaderOptions,
}; };

@ -2,19 +2,17 @@ import React, { useEffect } from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import Product from "../../../../../components/Product";
import ProductSuggestion from "../UserItems/ProductSuggestion"; import ProductSuggestion from "../UserItems/ProductSuggestion";
import { ScrollingCarousel } from "@trendyol-js/react-carousel"; import { ScrollingCarousel } from "@trendyol-js/react-carousel";
import { Book } from "../../../../Home/Portrait/Private/MyBooks";
import Progress from "../../../../../components/Progress"; import Progress from "../../../../../components/Progress";
export const MyBooks = ({ books, grades, isMobile }) => { export const MyBooks = ({ books, grades, isMobile, userProducts }) => {
const Book = ({ book }) => { const Book = ({ book }) => {
return ( return (
<li className=" flex flex-col lg:ml-6 lg:p-2 lg:border lg:border-solid lg:border-green-200 lg:rounded-md lg:pt-4"> <li className=" flex flex-col lg:ml-6 lg:border lg:border-solid lg:border-green-200 lg:rounded-md lg:p-4">
<Link to={"/products/" + book.id}> <Link to={"/products/" + book?.id}>
<img <img
src={`https://dnvn.ir/api/v1/file/${book.fileIds}`} src={`https://dnvn.ir/api/v1/file/${book?.product?.book?.fileIds}`}
alt="" alt=""
className="rounded-sm" className="rounded-sm"
style={{ style={{
@ -30,7 +28,7 @@ export const MyBooks = ({ books, grades, isMobile }) => {
{book.name} {book.name}
</h2> </h2>
<p className="font-medium text-green7B dark:text-greenBA text-sm lg:text-sm mt-2 lg:mt-2">{`پایه ${ <p className="font-medium text-green7B dark:text-greenBA text-sm lg:text-sm mt-2 lg:mt-2">{`پایه ${
grades[book.gradeId] grades[book?.product?.book?.gradeId]
}`}</p> }`}</p>
<Progress percent={60} direction="float-right" /> <Progress percent={60} direction="float-right" />
</Link> </Link>
@ -38,36 +36,39 @@ export const MyBooks = ({ books, grades, isMobile }) => {
); );
}; };
useEffect(() => {
window.scrollTo(0, 0);
}, []);
return ( return (
<div className="flex flex-1 flex-col"> <div className="flex flex-1 flex-col">
<div className="flex flex-wrap gap-4 mb-5"> <div className="flex flex-wrap gap-4 mb-5">
{/* {books.slice(0, 1).map((product, index) => ( <div className="w-full overflow-x-scroll bg-green-50 bg-opacity-50 lg:p-4 mt-4 pb-2">
<Product key={index} product={product} imageSdize={5} /> <p className="text-green7B mb-2 font-bold text-2xl lg:text-base">
))} */}
<div className="w-full scrolling-carousel mt-4 pb-2">
<p className="text-green7B font-bold text-2xl lg:text-base">
{window.t("کتاب های من")} {window.t("کتاب های من")}
</p> </p>
{userProducts?.filter((product) => product?.condition >= 2)
?.length ? (
<ScrollingCarousel className="py-3"> <ScrollingCarousel className="py-3">
{books?.map((book, index) => ( {userProducts
?.filter((product) => product?.condition >= 2)
?.map((book, index) => (
<Book book={book} key={index} /> <Book book={book} key={index} />
))} ))}
</ScrollingCarousel> </ScrollingCarousel>
) : null}
</div> </div>
</div> </div>
<ProductSuggestion products={books} grades={grades} isMobile={isMobile} /> {/* <ProductSuggestion
products={books?.slice(0, 3)}
grades={grades}
isMobile={isMobile}
/> */}
</div> </div>
); );
}; };
const mapStateToProps = (state) => ({ const mapStateToProps = (state) => ({
books: state.book.list, userProducts: state.userProduct.list,
grades: state.publicApi.grades, grades: state.publicApi.grades,
isMobile: state.publicApi.isMobile, isMobile: state.config.device === 'mobile',
books: state.book.list,
}); });
const mapDispatchToProps = {}; const mapDispatchToProps = {};

@ -10,8 +10,8 @@ function Suggestion({ products, grades, isMobile }) {
<strong className="text-green7B dark:text-white font-bold text-2xl lg:text-base my-4"> <strong className="text-green7B dark:text-white font-bold text-2xl lg:text-base my-4">
پیشنهادات ما به شما پیشنهادات ما به شما
</strong> </strong>
{products.length > 0 && ( {products?.length ? (
<div className="relative w-full" style={{ direction: "ltr" }}> <div className="relative w-full ltr">
<Carousel <Carousel
show={Math.round(window.innerWidth / 400)} show={Math.round(window.innerWidth / 400)}
slide={2} slide={2}
@ -34,12 +34,12 @@ function Suggestion({ products, grades, isMobile }) {
/> />
} }
> >
{products.map((product, index) => ( {products?.map((product, index) => (
<Product key={index} product={product} imageSize={4.5} /> <Product key={index} product={product} imageSize={4.5} />
))} ))}
</Carousel> </Carousel>
</div> </div>
)} ) : null}
</div> </div>
); );
} }

@ -2,13 +2,13 @@ import React, { useEffect } from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import SalesContainer from "./SalesContainer"; import SalesContainer from "./SalesContainer";
import { book, publicApi } from "../../../redux/actions"; import { publicApi } from "../../../redux/actions";
import Part2 from "./Part2"; import Part2 from "./Part2";
import HomeImg from "../../../assets/images/HomeImg.png"; import HomeImg from "../../../assets/images/HomeImg.png";
import Part4 from "./Part4"; import Part4 from "./Part4";
import Design2D from "../../../components/Design2D"; import Design2D from "../../../components/Design2D";
const DesktopHome = ({ grades, getBooks, books }) => { const DesktopHome = ({ grades, books }) => {
const banners = [ const banners = [
{ {
flex: 4, flex: 4,
@ -51,10 +51,6 @@ const DesktopHome = ({ grades, getBooks, books }) => {
}, },
]; ];
useEffect(() => {
getBooks({vod : true});
},[]);
return ( return (
<div className="flex flex-col items-center w-11/12 justify-center py-24"> <div className="flex flex-col items-center w-11/12 justify-center py-24">
<div className="w-full"> <div className="w-full">
@ -80,7 +76,6 @@ const mapStateToProps = (state) => ({
}); });
const mapDispatchToProps = { const mapDispatchToProps = {
getBooks: book.list,
setHeaderOptions: publicApi.setHeaderOptions, setHeaderOptions: publicApi.setHeaderOptions,
}; };

@ -1,20 +1,11 @@
import React, { useEffect } from "react"; import React, { useEffect } from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { book, blog } from "../../../../redux/actions";
import MyBooks from "./MyBooks"; import MyBooks from "./MyBooks";
import Shop from "./Shop"; import Shop from "./Shop";
import Videos from "./Videos"; import Videos from "./Videos";
import Blogs from "./Blogs"; import Blogs from "./Blogs";
function Private({ getList, products, blogs, getBlogList, grades }) { function Private({ products, blogs, grades }) {
useEffect(() => {
if (products.length === 0) {
getList({ vod: true });
}
if(blogs.length === 0){
getBlogList();
}
}, []);
return ( return (
<div className="w-full flex-1 pb-24"> <div className="w-full flex-1 pb-24">
<MyBooks books={products} grades={grades} /> <MyBooks books={products} grades={grades} />
@ -28,12 +19,7 @@ function Private({ getList, products, blogs, getBlogList, grades }) {
const mapStateToProps = (state) => ({ const mapStateToProps = (state) => ({
products: state.book.list, products: state.book.list,
blogs: state.blog.list, blogs: state.blog.list,
grades: state.publicApi.grades grades: state.publicApi.grades,
}); });
const mapDispatchToProps = { export default connect(mapStateToProps)(Private);
getList: book.list,
getBlogList: blog.list
};
export default connect(mapStateToProps, mapDispatchToProps)(Private);

@ -10,10 +10,6 @@ function Home({ setHeaderOptions, headerOptions, isMobile }) {
setHeaderOptions(headerOptions); setHeaderOptions(headerOptions);
}, []); }, []);
useEffect(() => {
window.scrollTo(0, 0);
}, []);
return ( return (
<> <>
{isMobile ? ( {isMobile ? (

@ -3,7 +3,6 @@ import { connect } from "react-redux";
import { toast } from "react-toastify"; import { toast } from "react-toastify";
import { book, userProduct, publicApi, dialog } from "../../redux/actions"; import { book, userProduct, publicApi, dialog } from "../../redux/actions";
import { Link, useNavigate } from "react-router-dom"; import { Link, useNavigate } from "react-router-dom";
import proxy from "../../redux/proxy";
import location from "../../utils/location"; import location from "../../utils/location";
import separate from "../../utils/separate"; import separate from "../../utils/separate";
@ -110,7 +109,6 @@ export const Product = ({
useEffect(() => { useEffect(() => {
if (book && isMobile) { if (book && isMobile) {
setHeaderOptions({ ...headerOptions, productId: book?.id }); setHeaderOptions({ ...headerOptions, productId: book?.id });
window.scroll({ top: 0, behavior: "smooth" });
} }
}, [book]); }, [book]);
return ( return (

@ -1,5 +1,4 @@
import React, { useState, useEffect, useCallback } from "react"; import React, { useState, useEffect, useCallback } from "react";
import { Link } from "react-router-dom";
import { connect } from "react-redux"; import { connect } from "react-redux";
import Sidebar from "./layouts/Desktop/Sidebar"; import Sidebar from "./layouts/Desktop/Sidebar";
@ -14,16 +13,13 @@ export const Products = ({
isDark, isDark,
isMobile, isMobile,
books, books,
getList,
grades, grades,
setHeaderOptions, setHeaderOptions,
headerOptions, headerOptions,
desktopContentTransform, desktopContentTransform,
}) => { }) => {
useEffect(() => { useEffect(() => {
getList({ vod: true });
setHeaderOptions(headerOptions); setHeaderOptions(headerOptions);
window.scroll({top: 0, behavior : 'smooth'});
}, []); }, []);
return ( return (
@ -64,7 +60,6 @@ const mapStateToProps = (state) => ({
}); });
const mapDispatchToProps = { const mapDispatchToProps = {
getList: book.list,
gradeFilter: book.gradeFilter, gradeFilter: book.gradeFilter,
setHeaderOptions: publicApi.setHeaderOptions, setHeaderOptions: publicApi.setHeaderOptions,
setFilterOptions: book.setFilterOptions, setFilterOptions: book.setFilterOptions,

@ -33,7 +33,6 @@ export const Main = ({
useEffect(() => { useEffect(() => {
if(books?.length){ if(books?.length){
setTotal(books.length); setTotal(books.length);
window.scroll({top : 0, behavior : 'smooth'});
} }
}, [books]); }, [books]);

@ -1,4 +1,4 @@
import React, { useState, useEffect, useMemo, useCallback } from "react"; import React, { useState, useEffect, useMemo } from "react";
import { import {
userProduct, userProduct,
userFactor, userFactor,
@ -26,7 +26,6 @@ function ShoppingCart({
isMobile, isMobile,
factorInfo, factorInfo,
user, user,
getList,
getFactorInfo, getFactorInfo,
headerOptions, headerOptions,
setHeaderOptions, setHeaderOptions,
@ -41,8 +40,6 @@ function ShoppingCart({
const [phase, setPhase] = useState("products"); const [phase, setPhase] = useState("products");
const navigation = useNavigate(); const navigation = useNavigate();
useEffect(() => { useEffect(() => {
console.log("gl1");
if (isLogin) getList();
getFactorInfo({ userId: user?.id }); getFactorInfo({ userId: user?.id });
setHeaderOptions(headerOptions); setHeaderOptions(headerOptions);
}, []); }, []);
@ -407,7 +404,6 @@ const mapStateToProps = (state) => ({
}); });
const mapDispatchToProps = { const mapDispatchToProps = {
getList: userProduct.list,
getInfo: userProduct.info, getInfo: userProduct.info,
getFactorInfo: userFactor.info, getFactorInfo: userFactor.info,
payFactor: userFactor.payment, payFactor: userFactor.payment,

@ -11,30 +11,10 @@ function Videos({ headerOptions, setHeaderOptions, getList, videos, grades }) {
useEffect(() => { useEffect(() => {
setHeaderOptions(headerOptions); setHeaderOptions(headerOptions);
getList({ vod: true });
}, []);
useEffect(() => {
// alert();
window.scrollTo(0, 0);
}, []); }, []);
return ( return (
<div className="flex flex-col pb-24 "> <div className="flex flex-col pb-24 ">
{/* <div className="px-4">
<Search
backgroundColor="bg-grayF9 dark:bg-gray2077"
borderColor="border-grayDB dark:border-gray45"
textColor="text-blueC0 dark:text-white"
icon={searchLight}
/>
</div>
<div className="pr-4">
<VerticalGradeFilter />
</div>
<div className="px-4 flex flex-col">
<Divider type={"vertical"} />
</div> */}
<div className="pr-4"> <div className="pr-4">
<MostViewedVideo videos={videos} grades={grades} /> <MostViewedVideo videos={videos} grades={grades} />
</div> </div>

Loading…
Cancel
Save