From ec2eb6df317b25c90cbe7fdd09b86f29aa06ff2e Mon Sep 17 00:00:00 2001 From: "DESKTOP-QHP1O2H\\MIKE" Date: Mon, 16 Jan 2023 02:54:34 -0800 Subject: [PATCH] made changes for blog api data --- src/component/Blog/Blog/Main.js | 271 +++++++++++++------------- src/component/Blog/BlogSingle/Main.js | 41 ++-- src/routes/index.js | 2 +- src/vendors/service/siteService.js | 2 +- 4 files changed, 165 insertions(+), 151 deletions(-) diff --git a/src/component/Blog/Blog/Main.js b/src/component/Blog/Blog/Main.js index 2ee2880..36d7625 100644 --- a/src/component/Blog/Blog/Main.js +++ b/src/component/Blog/Blog/Main.js @@ -1,27 +1,62 @@ -import React from 'react' -import { Link } from 'react-router-dom' -import BGImg from "../../../assets/images/bread_crumb_bg.png" -import BGImg1 from "../../../assets/images/bread_crumb_bg_one.png" -import BGImg2 from "../../../assets/images/bread_crumb_bg_two.png" +import React, { useEffect, useState } from "react"; +import { Link } from "react-router-dom"; +import BGImg from "../../../assets/images/bread_crumb_bg.png"; +import BGImg1 from "../../../assets/images/bread_crumb_bg_one.png"; +import BGImg2 from "../../../assets/images/bread_crumb_bg_two.png"; +import SiteService from "../../../vendors/service/siteService"; +const Main = ({ brdcum, bgimg }) => { + const [blogData, setBlogData] = useState([]); -const Main = ({brdcum,bgimg}) => { + const api = new SiteService(); + useEffect(() => { + getBlogData(); + }, []); + + const getBlogData = async () => { + try { + const res = await api.blogData(); + + setBlogData(res.data); + + console.log(res.data); + + + } catch (error) { + console.log("Error from blog data ", error); + } + }; + return ( <> - -
-
- image - image - image +
+
+ + {" "} + image{" "} + + + {" "} + image{" "} + + + {" "} + image{" "} + -
-

Latest Blog Post

-
    -
  • Home
  • -
  • »
  • -
  • Blog
  • -
- {/*
+
+

Latest Blog Post

+
    +
  • + Home +
  • +
  • + » +
  • +
  • + Blog +
  • +
+ {/*
@@ -29,126 +64,92 @@ const Main = ({brdcum,bgimg}) => {
*/} -
-
+
+
- -
-
-
-
-
- image - 20 min ago -
+
+ {blogData.map((data,index) => { + if (index == 0){ + return ( +
+
+
+
+ image + {/* 20 min ago */} + + {new Date (data.post_date).toDateString()} +
-
-
-

Top rated app of the year!

-

myFit has powerful connectivity, fitness, health, and safety features - Also makes provision Fitness tracking,Workout tracking,Heart rate monitoringscrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic Lorem Ipsum is simply dummy text of the printing and typesetting.

- READ MORE -
+
+
+

{data.post_title}

+
+ + READ MORE +
+
-
+
-
-
-
-
-
-
-
- image - 45 min ago -
-
-

Cool features added!

-

Lorem Ipsum is simply dummy text of the printing and typesetting - industry lorem Ipsum has.

- READ MORE -
-
-
-
-
-
- image - 45 min ago -
-
-

Top rated app! Yupp.

-

Simply dummy text of the printing and typesetting industry lorem Ipsum has Lorem Ipsum is.

- READ MORE -
-
-
-
-
-
- image - 45 min ago -
-
-

Creative ideas on app.

-

Printing and typesetting industry lorem Ipsum has Lorem simply dummy text of the.

- READ MORE -
-
-
-
-
-
- image - 45 min ago -
-
-

Excellence UI design

-

Lorem Ipsum is simply dummy text of the printing and typesetting - industry lorem Ipsum has.

- READ MORE -
-
-
-
-
-
- image - 45 min ago -
-
-

Quick and easy Search

-

Simply dummy text of the printing and typesetting industry lorem Ipsum has Lorem Ipsum is.

- READ MORE -
-
-
-
-
-
- image - 45 min ago -
-
-

Chat function eded

-

Printing and typesetting industry lorem Ipsum has Lorem simply dummy text of the.

- READ MORE -
-
-
-
-
-
    -
  • Visit our blog
  • -
-
-
-
- - ) -} -export default Main \ No newline at end of file + ) + } + })} + + +
+
+
+
+ {blogData.map((data, index) => { + if (index > 0){ + return ( +
+
+
+ image + {new Date (data && data.post_date).toDateString()} +
+
+

{data.post_title}

+
+ + READ MORE + +
+
+
+ + )} + + + })} +
+
+
    +
  • + + {" "} + Visit our blog + +
  • +
+
+
+
+ + ); +}; + +export default Main; diff --git a/src/component/Blog/BlogSingle/Main.js b/src/component/Blog/BlogSingle/Main.js index 3ff6fd5..08a0686 100644 --- a/src/component/Blog/BlogSingle/Main.js +++ b/src/component/Blog/BlogSingle/Main.js @@ -1,11 +1,18 @@ -import React from 'react' -import { Link } from 'react-router-dom' +import React, { useEffect, useState } from "react"; +import { Link, useLocation } from 'react-router-dom' import Bredcrumb from '../../Bredcrumb/Main' import BGImg from "../../../assets/images/bread_crumb_bg.png" import BGImg1 from "../../../assets/images/bread_crumb_bg_one.png" import BGImg2 from "../../../assets/images/bread_crumb_bg_two.png" +import { useParams } from "react-router-dom"; const Main = ({brdcum}) => { + + const { id } = useParams(); + const location = useLocation(); + const data = location.state?.data; + + console.log("location", location, data); return ( <> @@ -49,15 +56,21 @@ const Main = ({brdcum}) => {
Review - 45 min ago + {/* 45 min ago */} + {new Date (data && data.post_modified).toDateString()} +
-

Top rated app of the year!

+

{data && data.post_title}

- image + image
+

{data && data.post_name}

+
+
+ {/*

Lorem Ipsum is simply dummy text of the printing and typesetting in dustry lorem Ipsum has been the industrys standard dummy text ev er since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic Lorem Ipsum is simply dummy text of the printing and typesettingindustry lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived.

Printing and typesetting in dustry lorem Ipsum has been the industrys standard dummy text ev er since the 1500s, when an unnown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic Lorem Ipsum is simply dummy text of the printing and typesettingindustry lorem Ipsum has been the industrys centuries, but also the leap into electronic.

Why we are best

@@ -72,7 +85,7 @@ const Main = ({brdcum}) => {
  • Unknown printer took a galley of type and scrambled it to make.

  • Type specimen book. It has survived not only.

  • -
    +
    @@ -86,21 +99,21 @@ const Main = ({brdcum}) => {

    Why we are best

    Lorem Ipsum is simply dummy text of the printing and typesetting in dustry lorem Ipsum has been the industrys standard dummy text ev er since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic Lorem Ipsum is simply dummy text of the printing and typesettingindustry lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived.

    -
    -
    +
    +
    image

    Lorem Ipsum is simply dummy text of the printing and typesetting in dustry lorem Ipsum has been the industrys standard dummy.

    Mr. John Doe, Apper Inc

    -
    -

    Lorem Ipsum is simply dummy text of the printing and typesetting in dustry lorem Ipsum has been the industrys standard dummy text ev er since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic industry.

    +
    */} + {/*

    Lorem Ipsum is simply dummy text of the printing and typesetting in dustry lorem Ipsum has been the industrys standard dummy text ev er since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic industry.

    */}
    -
    + {/*
    image -
    +
    */}
    -

    By: John Dow

    - July 25, 2022 +

    {data && data.post_author}

    + {new Date (data && data.post_date).toDateString()}
    diff --git a/src/routes/index.js b/src/routes/index.js index faae420..af34beb 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -84,7 +84,7 @@ const Routing = () => { } /> } /> } /> - } /> + } /> } /> } /> diff --git a/src/vendors/service/siteService.js b/src/vendors/service/siteService.js index 9312a14..70df633 100644 --- a/src/vendors/service/siteService.js +++ b/src/vendors/service/siteService.js @@ -7,7 +7,7 @@ class SiteService { } // Blog Data {Get} blogData() { - return this.getAuxEnd("blogdata", null); + return this.getAuxEnd("/blogdata", null); } // Country Data {GET}