diff --git a/app/blog-single/page.tsx b/app/blog-single/page.tsx index 887eb79..6b8b7fb 100644 --- a/app/blog-single/page.tsx +++ b/app/blog-single/page.tsx @@ -1,18 +1,93 @@ 'use client' -import { useState } from 'react' + +import { useState, useEffect, Suspense } from 'react' import { useSearchParams } from 'next/navigation' import ModalVideo from 'react-modal-video' import "@/node_modules/react-modal-video/css/modal-video.css" import Countdown from '@/components/elements/Countdown' import Layout from "@/components/layout/Layout" -import { recipesList } from "@/utility/constant.utils"; import Link from "next/link" -export default function BlogSingle() { +import axios from 'axios' +interface BlogItem { + id: number; + title: string; + slug: string; + image: string; + description: string; + author: string; + profile: string; + date: string; +} + +function BlogSingleContent() { const [isOpen, setOpen] = useState(false) - const searchParams = useSearchParams(); - const currentSlug = searchParams.get('slug'); + const currentSlug = searchParams ? searchParams.get('slug') : null; + + const [blog, setBlog] = useState(null); + const [recentBlogs, setRecentBlogs] = useState([]); + const [loading, setLoading] = useState(true); + + useEffect(() => { + const fetchBlogDetails = async () => { + try { + setLoading(true); + const API_BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL || 'http://localhost:3006/api'; + + // Fetch other blogs for "Read More" section and fallback + const listRes = await axios.get(`${API_BASE_URL}/blogs`); + const allBlogs = listRes.data?.success ? listRes.data.data : []; + setRecentBlogs(allBlogs); + + if (currentSlug) { + // Fetch current blog details by slug + const detailRes = await axios.get(`${API_BASE_URL}/blogs/slug/${currentSlug}`); + if (detailRes.data && detailRes.data.success) { + setBlog(detailRes.data.data); + } + } else { + // No slug provided, load the most recent blog + if (allBlogs.length > 0) { + setBlog(allBlogs[0]); + } + } + } catch (error) { + console.error("Error fetching blog details:", error); + } finally { + setLoading(false); + } + }; + + fetchBlogDetails(); + }, [currentSlug]); + + if (loading) { + return ( + +
+
+ Loading... +
+
+
+ ); + } + + if (!blog) { + return ( + +
+

Blog post not found

+
+ + Back to Blogs + +
+ + ); + } + return ( <> @@ -39,64 +114,34 @@ export default function BlogSingle() {
- + {blog.title}
  • - 26 Jan 2025 | + {blog.date} |
  • - Gisselle | + {blog.author} |
  • - 2 Comments + Comments Disabled
-

Step Into the Future of Business with Eventify

+

{blog.title}

-

At Eventify 2024, you'll join an exclusive gathering of business leaders and innovators shaping the future their industries. This one-day conference offers dynamic sessions on leadership, technology, and strategy to help you stay ahead in today's competitive market. Whether you're looking to unlock new opportunities or build lasting eventify partnerships, Eventify is where you need to be.

+ + {/* Render rich text from Quill editor safely */} +
+
-
-
-
- -
-
-
-
-
- -
-
-
-
-

Eventify: Your Gateway Strategic Growth

-
-

Fuel an your business growth with actionable insights from world-class experts at Eventify 2024. This premier event brings together forward-thinking professionals to explore the latest trends, technologies, and strategies for success. From keynote speeches to interactive workshops, Eventify provides you with the tools you need.

-
-

"Join us at Eventify 2024, where innovation meets opportunity. This conference is the ultimate destination for business leaders seeking to push the boundaries of an what's possible. With sessions on disruptive technologies, leadership trends, and market strategies, you'll walk away with the knowledge and connections to lead.

-
- -
-

Reimagine Business Possibilities Eventify

-
-

"Eventify 2024 is the ultimate destination for professionals eager to stay ahead in the evolving business landscape. This event brings together to innovators, meetup industry leaders, and experts to explore the future of business strategy technology.

-

Tags:

    -
  • #Conferences
  • -
  • #Meetup
  • +
  • #TamilCulture
  • +
  • #Community
@@ -122,7 +167,7 @@ export default function BlogSingle() {

Search

-
+ e.preventDefault()}> @@ -154,7 +199,7 @@ export default function BlogSingle() {
-

Popular Hastag

+

Popular Hashtag

  • #Conferences
  • @@ -204,7 +249,7 @@ export default function BlogSingle() {
- {recipesList + {recentBlogs .filter(post => post.slug !== currentSlug) .slice(0, 3) .map((post) => ( @@ -212,23 +257,23 @@ export default function BlogSingle() {
- {post.title} + {post.title}
  • - {post.date} | + {post.date} |
  • - {post.user} + {post.author}
- {post.title.length > 40 ? `${post.title.slice(0, 40)}...` : post?.title} + {post.title.length > 40 ? `${post.title.slice(0, 40)}...` : post.title}
- read more + read more
- +
@@ -253,10 +298,10 @@ export default function BlogSingle() {
  • - 30 January 2025 - 6pm to 11:30pm + 30 January 2025 - 6pm to 11:30pm
  • - Secret Location In The UK + Secret Location In The UK
@@ -279,10 +324,10 @@ export default function BlogSingle() {
  • - 30 January 2025 - 6pm to 11:30pm + 30 January 2025 - 6pm to 11:30pm
  • - Secret Location In The UK + Secret Location In The UK
@@ -295,4 +340,12 @@ export default function BlogSingle() { ) +} + +export default function BlogSingle() { + return ( + Loading...
}> + + + ) } \ No newline at end of file diff --git a/app/blog/page.tsx b/app/blog/page.tsx index 3fcd3fb..71e7798 100644 --- a/app/blog/page.tsx +++ b/app/blog/page.tsx @@ -1,9 +1,33 @@ +'use client' + +import { useState, useEffect } from "react" +import axios from "axios" import Countdown from '@/components/elements/Countdown' import Layout from "@/components/layout/Layout" import Link from "next/link" + export default function Blog() { + const [blogs, setBlogs] = useState([]); + const [loading, setLoading] = useState(true); + + useEffect(() => { + const fetchBlogs = async () => { + try { + const API_BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL || 'http://localhost:3006/api'; + const response = await axios.get(`${API_BASE_URL}/blogs`); + if (response.data && response.data.success) { + setBlogs(response.data.data); + } + } catch (error) { + console.error("Error fetching blogs:", error); + } finally { + setLoading(false); + } + }; + fetchBlogs(); + }, []); return ( <> @@ -28,243 +52,67 @@ export default function Blog() {
-
-
-
- -
-
-
    -
  • - 26 Jan 2025 | -
  • -
  • - Beverly -
  • -
-
- Save soil, save world Projects in 2020 -
- read more -
- -
+ {loading ? ( +
+
+ Loading...
-
-
-
-
- -
-
-
    -
  • - 26 Jan 2025 | -
  • -
  • - Gisselle -
  • -
-
- Civil Litigation paper’s Of Conference -
- read more -
- + ) : blogs.length === 0 ? ( +
+

No blog posts available at the moment.

+
+ ) : ( + blogs.map((blog) => ( +
+
+
+ {blog.title} +
+
+
    +
  • + {blog.date || 'No Date'} | +
  • +
  • + {blog.author} +
  • +
+
+ {blog.title} +
+ read more +
+ +
+
-
-
-
-
-
- -
-
-
    -
  • - 26 Jan 2025 | -
  • -
  • - Mertie -
  • -
-
- Greetings and Opening Event of health -
- read more -
- -
-
-
-
-
-
-
- -
-
-
    -
  • - 26 Jan 2025 | -
  • -
  • - Beverly -
  • -
-
- Eventify 2024: Unlock the Future of Business -
- read more -
- -
-
-
-
-
-
-
- -
-
-
    -
  • - 26 Jan 2025 | -
  • -
  • - Gisselle -
  • -
-
- Where Vision Meetup Connect: Eventify 2024 -
- read more -
- -
-
-
-
-
-
-
- -
-
-
    -
  • - 26 Jan 2025 | -
  • -
  • - Mertie -
  • -
-
- Fuel Your Business Growth at Eventify -
- read more -
- -
-
-
-
-
-
-
- -
-
-
    -
  • - 26 Jan 2025 | -
  • -
  • - Beverly -
  • -
-
- Ignite Your Business Potential at Eventify -
- read more -
- -
-
-
-
-
-
-
- -
-
-
    -
  • - 26 Jan 2025 | -
  • -
  • - Gisselle -
  • -
-
- Step Into the Future of Business with Eventify -
- read more -
- -
-
-
-
-
-
-
- -
-
-
    -
  • - 26 Jan 2025 | -
  • -
  • - Mertie -
  • -
-
- Empowering Business Growth at Eventify -
- read more -
- -
-
-
-
+ )) + )}
-
- -
+ {blogs.length > 0 && ( +
+ +
+ )}