Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions app/research/page.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
import Hero from "@/components/Hero";
import CallToAction from "@/components/CallToAction";
import BlogClientList from "@/components/BlogClientList";
import { fetchBlogs } from "@/services/blogService";


import "./ResearchPage.css";
import AOSWrapper from "@/components/AOSWrapper";

export default async function ResearchPage() {
const blogs = await fetchBlogs();

return (
<div>
<AOSWrapper />
<Hero
title="Blog & Research"
subtitle="Stay Updated with the Latest News, Events, and Insight"
backgroundClass="research-hero"
/>
<BlogClientList initialBlogs={blogs} />
<CallToAction />
<AOSWrapper />
<Hero
title="Blog & Research"
subtitle="Stay Updated with the Latest News, Events, and Insight"
backgroundClass="research-hero"
/>
<BlogClientList />
<CallToAction />
</div>
);
}
34 changes: 15 additions & 19 deletions components/BlogClientList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,28 @@ import { useState, useEffect } from "react";
import { Container, Button } from "react-bootstrap";
import BlogCard from "./BlogCard";
import LoadingSpinner from "./LoadingSpinner"; // Import LoadingSpinner
import { fetchBlogs } from "@/services/blogService";

const BlogClientList = ({ initialBlogs }) => {
const [blogs, setBlogs] = useState(initialBlogs || []);
const [isLoading, setIsLoading] = useState(false); // Use isLoading for managing loading state
const BlogClientList = () => {
const [blogs, setBlogs] = useState([]);
const [isLoading, setIsLoading] = useState(true); // Use isLoading for managing loading state
const [visibleBlogs, setVisibleBlogs] = useState(6);

const handleLoadMore = () => setVisibleBlogs((prev) => prev + 6);

// Optional: To fetch blogs dynamically if needed (for client-side fetching)
useEffect(() => {
if (!initialBlogs || initialBlogs.length === 0) {
setIsLoading(true);
// Fetch blogs from an API or service if the initialBlogs prop is empty
const fetchBlogs = async () => {
try {
const response = await fetchBlogs(); // Fetching data from the service
setBlogs(response);
} catch (error) {
console.log("Error fetching blogs:", error);
} finally {
setIsLoading(false);
}
};
fetchBlogs();
}
}, [initialBlogs]);
(async () => {
try {
const response = await fetchBlogs(); // Fetching data from the service
setBlogs(response);
} catch (error) {
console.log("Error fetching blogs:", error);
} finally {
setIsLoading(false);
}
})()
}, []);

return (
<section className="sections-container blog-section">
Expand Down