Merge branch 'main' of https://gits.techvanguard.vn/UKSOURCE/hailearning.edu.vn into fea/thanh-02022026-news

This commit is contained in:
Wini_Fy
2026-02-05 16:01:26 +07:00
8 changed files with 213 additions and 119 deletions

62
api/footerApi.ts Normal file
View File

@@ -0,0 +1,62 @@
/**
* Footer API Functions
* Fetch footer data from external API
*/
const getApiUrl = (): string => {
return process.env.NEXT_PUBLIC_API_URL || "http://localhost:3001";
};
export interface FooterData {
top: {
bgImage: string;
phone: {
display: string;
href: string;
};
address: string;
logo: {
src: string;
alt: string;
href: string;
};
menuLinks: Array<{
label: string;
href: string;
}>;
socialLinks: Array<{
icon: string;
href: string;
}>;
};
bottom: {
copyright: {
text: string;
brand: string;
rights: string;
};
menuLinks: Array<{
label: string;
href: string;
}>;
};
}
export const footerApi = {
// Get footer data
getFooter: async (): Promise<FooterData> => {
try {
const apiUrl = getApiUrl();
const response = await fetch(`${apiUrl}/api/footer`);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return await response.json();
} catch (error) {
console.error("Error fetching footer data:", error);
// Fallback to static data if API fails
const fallbackData = await import("../app/components/layout/Footer/footer.json");
return fallbackData.default as FooterData;
}
},
};

View File

@@ -1,5 +1,6 @@
/**
* Export all API functions
*/
export * from './blogsApi';
export * from './homeApi';
export * from "./blogsApi";
export * from "./footerApi";
export * from "./servicesApi";