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. 43
      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 { 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);

@ -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,
};

@ -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,
};

@ -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 (
<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">
<Link to={"/products/" + book.id}>
<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}>
<img
src={`https://dnvn.ir/api/v1/file/${book.fileIds}`}
src={`https://dnvn.ir/api/v1/file/${book?.product?.book?.fileIds}`}
alt=""
className="rounded-sm"
style={{
@ -30,7 +28,7 @@ export const MyBooks = ({ books, grades, isMobile }) => {
{book.name}
</h2>
<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>
<Progress percent={60} direction="float-right" />
</Link>
@ -38,36 +36,39 @@ export const MyBooks = ({ books, grades, isMobile }) => {
);
};
useEffect(() => {
window.scrollTo(0, 0);
}, []);
return (
<div className="flex flex-1 flex-col">
<div className="flex flex-wrap gap-4 mb-5 ">
{/* {books.slice(0, 1).map((product, index) => (
<Product key={index} product={product} imageSdize={5} />
))} */}
<div className="w-full scrolling-carousel mt-4 pb-2">
<p className="text-green7B font-bold text-2xl lg:text-base">
<div className="flex flex-wrap gap-4 mb-5">
<div className="w-full overflow-x-scroll bg-green-50 bg-opacity-50 lg:p-4 mt-4 pb-2">
<p className="text-green7B mb-2 font-bold text-2xl lg:text-base">
{window.t("کتاب های من")}
</p>
{userProducts?.filter((product) => product?.condition >= 2)
?.length ? (
<ScrollingCarousel className="py-3">
{books?.map((book, index) => (
{userProducts
?.filter((product) => product?.condition >= 2)
?.map((book, index) => (
<Book book={book} key={index} />
))}
</ScrollingCarousel>
) : null}
</div>
</div>
<ProductSuggestion products={books} grades={grades} isMobile={isMobile} />
{/* <ProductSuggestion
products={books?.slice(0, 3)}
grades={grades}
isMobile={isMobile}
/> */}
</div>
);
};
const mapStateToProps = (state) => ({
books: state.book.list,
userProducts: state.userProduct.list,
grades: state.publicApi.grades,
isMobile: state.publicApi.isMobile,
isMobile: state.config.device === 'mobile',
books: state.book.list,
});
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>
{products.length > 0 && (
<div className="relative w-full" style={{ direction: "ltr" }}>
{products?.length ? (
<div className="relative w-full ltr">
<Carousel
show={Math.round(window.innerWidth / 400)}
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} />
))}
</Carousel>
</div>
)}
) : null}
</div>
);
}

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

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

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

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

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

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

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

@ -11,30 +11,10 @@ function Videos({ headerOptions, setHeaderOptions, getList, videos, grades }) {
useEffect(() => {
setHeaderOptions(headerOptions);
getList({ vod: true });
}, []);
useEffect(() => {
// alert();
window.scrollTo(0, 0);
}, []);
return (
<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">
<MostViewedVideo videos={videos} grades={grades} />
</div>

Loading…
Cancel
Save