From fac4b29c7918951a9f2e4e7141e5d6cdc624b056 Mon Sep 17 00:00:00 2001 From: mahdi andalib Date: Sat, 2 Jul 2022 09:34:24 +0430 Subject: [PATCH] =?UTF-8?q?=D8=B4=D8=B1=D9=88=D8=B9=20=DA=A9=D8=A7=D8=B1?= =?UTF-8?q?=20=D8=A8=D8=B1=D9=88=DB=8C=20=D8=AF=D8=B1=D8=B3=D8=AA=20=DA=A9?= =?UTF-8?q?=D8=B1=D8=AF=D9=86=20=D8=B5=D9=81=D8=AD=D9=87=20=D8=A8=D9=86?= =?UTF-8?q?=D8=AF=DB=8C=20|=2045?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Products/layouts/Desktop/Main.js | 57 +++++++++------------ src/views/Products/layouts/Desktop/Posts.js | 18 +++++++ 2 files changed, 42 insertions(+), 33 deletions(-) create mode 100644 src/views/Products/layouts/Desktop/Posts.js diff --git a/src/views/Products/layouts/Desktop/Main.js b/src/views/Products/layouts/Desktop/Main.js index 717bd66..e41bb9a 100644 --- a/src/views/Products/layouts/Desktop/Main.js +++ b/src/views/Products/layouts/Desktop/Main.js @@ -1,4 +1,6 @@ import React, { useEffect, useState } from "react"; +import axios from "axios"; + import { connect } from "react-redux"; import { Link } from "react-router-dom"; import { ScrollingCarousel, Carousel } from "@trendyol-js/react-carousel"; @@ -10,6 +12,7 @@ import { book, publicApi } from "../../../../redux/actions"; import moment from "jalali-moment"; import dropdownIcon from "../../../../assets/icons/dropdown-blue.svg"; +import Posts from "./Posts"; export const Main = ({ books, @@ -124,11 +127,32 @@ export const Main = ({ )); }; + // pagination + const [posts, setPosts] = useState([]); + const [loading, setLoading] = useState(false); + const [currentPage, setCurrentPage] = useState(1); + const [postsPerPage, setPostsPerPage] = useState(10); + + useEffect(() => { + const fetchPosts = async () => { + setLoading(true); + const res = await axios.get("https://jsonplaceholder.typicode.com/posts"); + setPosts(res.data); + setLoading(false); + }; + + fetchPosts(); + }, []); + return (
+
+

My Blog

+ +
-{(filterOptions?.productType - ? filterOptions.productType === "دوره ویدئویی" - : true) && ( - - } - leftArrow={ - - } - > - {Items(4)} - -)} -
*/ -} diff --git a/src/views/Products/layouts/Desktop/Posts.js b/src/views/Products/layouts/Desktop/Posts.js new file mode 100644 index 0000000..7e5ace7 --- /dev/null +++ b/src/views/Products/layouts/Desktop/Posts.js @@ -0,0 +1,18 @@ +import React from "react"; + +const Posts = ({ posts, loading }) => { + if (loading) { + return

loading...

; + } + return ( +
    + {posts.map((post) => ( +
  • + {post.title} +
  • + ))} +
+ ); +}; + +export default Posts;