This commit is contained in:
2026-05-11 16:24:14 +07:00
commit 6a48d6351c
313 changed files with 41936 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
import { HeaderData, HeaderMenuItem } from '@/types/header';
const CMS_API_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3001';
export async function fetchHeaderData(): Promise<HeaderData> {
const res = await fetch(`${CMS_API_URL}/api/header`, {
next: { revalidate: 60 },
});
if (!res.ok) {
throw new Error(`Failed to fetch header: ${res.status}`);
}
const json = await res.json();
if (!json.success) {
throw new Error(json.message || 'Header API error');
}
return json.data as HeaderData;
}
export async function fetchHeaderMenu(): Promise<HeaderMenuItem[]> {
const res = await fetch(`${CMS_API_URL}/api/header-menu`, {
next: { revalidate: 60 },
});
if (!res.ok) {
throw new Error(`Failed to fetch menu: ${res.status}`);
}
const json = await res.json();
if (!json.success) {
throw new Error(json.message || 'Menu API error');
}
return json.data as HeaderMenuItem[];
}