feat(about): Implement about API integration and migrate from static JSON

This commit is contained in:
2026-02-06 02:01:42 +07:00
parent a85182ff20
commit dc68fe17ab
5 changed files with 65 additions and 143 deletions

35
api/aboutApi.ts Normal file
View File

@@ -0,0 +1,35 @@
/**
* About API Functions
* Fetch about us data from external API
*/
const getApiUrl = (): string => {
return process.env.NEXT_PUBLIC_API_URL || "http://localhost:3001";
};
import { AboutData } from "../app/about/types";
export const aboutApi = {
// Get about us data
getAbout: async (): Promise<AboutData | null> => {
try {
const apiUrl = getApiUrl();
const response = await fetch(`${apiUrl}/api/about`, {
cache: 'no-store',
headers: {
'Cache-Control': 'no-cache',
'Pragma': 'no-cache'
}
});
if (!response.ok) {
console.error(`HTTP error! status: ${response.status}`);
return null;
}
return await response.json();
} catch (error) {
console.error("Error fetching about data:", error);
return null;
}
},
};

View File

@@ -1,121 +0,0 @@
{
"hero": {
"title": "About Us",
"subtitle": "Global Education Simplified",
"breadcrumb": ["Home", "About Us"],
"backgroundImage": "/assets/img/inner-page/breadcrumb.jpg"
},
"intro": {
"subheading": "Company Intro",
"heading": "Building Pathways to Your Immigration Success",
"description": "We provide expert guidance, personalized solutions, and transparent processes to help you achieve your immigration goals. Our dedicated team ensures a smooth journey, building pathways to your international success.",
"image": "/assets/img/inner-page/intro.jpg"
},
"mission": {
"subheading": "About Our Consultancy",
"heading": "Turning Study Abroad Dreams Into Reality",
"description": "We guide students with expert visa consulting, ensuring a smooth process from application to approval, turning study abroad aspirations into life-changing opportunities for a brighter future.",
"images": {
"main": "/assets/img/home-1/about/about-1.jpg",
"secondary": "/assets/img/home-1/about/about-02.jpg",
"bgShape": "/assets/img/home-1/about/Vector.png",
"planeShape": "/assets/img/home-1/about/plane.png",
"topShape": "/assets/img/home-1/about/shape.png",
"globeShape": "/assets/img/home-1/about/globe.png"
},
"items": [
{
"icon": "/assets/img/home-1/icon/01.svg",
"label": "Global Reach",
"description": "Expanding Opportunities Worldwide"
},
{
"icon": "/assets/img/home-1/icon/01.svg",
"label": "Global Reach",
"description": "Expanding Opportunities Worldwide"
}
],
"features": [
"Fastest Visa form processing with skilled immigration agents",
"Partnership with International Educational Institutions"
],
"ctaButton": {
"label": "Get Started",
"href": "/about"
}
},
"features": {
"backgroundImage": "/assets/img/home-2/feature/bg-shape.png",
"subheading": "Your Travel Made Easy",
"heading": "Smooth Visa Journey Guaranteed",
"description": "We provide expert guidance for every visa application, ensuring smooth processing, personalized support, and reliable assistance",
"image": "/assets/img/home-2/feature/02.png",
"items": [
{
"icon": "/assets/img/home-2/icon/01.png",
"title": "Expert Consultants",
"description": "Skilled and knowledgeable visa advisors. Skilled and knowledgeable visa advisors."
},
{
"icon": "/assets/img/home-2/icon/01.png",
"title": "Personalized Support",
"description": "Skilled and knowledgeable visa advisors. Skilled and knowledgeable visa advisors."
},
{
"icon": "/assets/img/home-2/icon/01.png",
"title": "Transparent Process",
"description": "Skilled and knowledgeable visa advisors. Skilled and knowledgeable visa advisors."
}
],
"ctaButton": {
"label": "Get Started Today",
"href": "/contact"
}
},
"news": {
"subheading": "Visa Tips & Guides",
"heading": "Latest Insights & Updates",
"ctaButton": {
"label": "view all articles",
"href": "/blog"
},
"items": [
{
"title": "Step-by-Step Guide to Applying for a Student Visa",
"category": "Student Visa",
"date": "20 August ,2025",
"comments": 8,
"author": {
"name": "Sohel",
"avatar": "/assets/img/home-1/news/client.png"
},
"link": "/blog/step-by-step-guide-student-visa",
"thumbnail": "/assets/img/home-1/news/news-1.jpg"
},
{
"title": "Tips to Prepare Financial Documents for Visa Approval",
"category": "IELTS / TOEFL",
"date": "20 August ,2025",
"comments": 8,
"author": {
"name": "Sohel",
"avatar": "/assets/img/home-1/news/client.png"
},
"link": "/blog/financial-documents-visa-approval",
"thumbnail": "/assets/img/home-1/news/news-2.jpg"
},
{
"title": "Post-Arrival Guide What Every Student Should Know",
"category": "Study Abroad",
"date": "20 August ,2025",
"comments": 8,
"author": {
"name": "Sohel",
"avatar": "/assets/img/home-1/news/client.png"
},
"link": "/blog/post-arrival-guide-students",
"thumbnail": "/assets/img/home-1/news/news-3.jpg"
}
]
}
}

View File

@@ -1,14 +1,21 @@
import { AboutHero, AboutIntro, AboutMission, AboutFeatures, AboutNews } from "../components/about";
import aboutData from "./about.json";
import { aboutApi } from "../../api/aboutApi";
export default async function AboutPage() {
const data = await aboutApi.getAbout();
if (!data) {
return null;
}
export default function AboutPage() {
return (
<>
<AboutHero data={aboutData.hero} />
<AboutIntro data={aboutData.intro} />
<AboutMission data={aboutData.mission} />
<AboutFeatures data={aboutData.features} />
<AboutNews data={aboutData.news} />
<AboutHero data={data.hero} />
<AboutIntro data={data.intro} />
<AboutMission data={data.mission} />
<AboutFeatures data={data.features} />
<AboutNews data={data.news} />
</>
);
}

View File

@@ -1,7 +1,6 @@
export interface AboutData {
hero: {
title: string;
subtitle: string;
breadcrumb: string[];
backgroundImage: string;
};

View File

@@ -14,6 +14,7 @@ const AboutHero = ({ data }: AboutHeroProps) => {
<div className="container">
<div className="page-heading">
<h1 className="breadcrumb-title">{data.title}</h1>
{Array.isArray(data.breadcrumb) && (
<ul className="breadcrumb-list">
{data.breadcrumb.map((item, index) => (
<li key={index}>
@@ -28,6 +29,7 @@ const AboutHero = ({ data }: AboutHeroProps) => {
</li>
))}
</ul>
)}
</div>
</div>
</section>