forked from UKSOURCE/hailearning.edu.vn
66 lines
2.6 KiB
TypeScript
66 lines
2.6 KiB
TypeScript
"use client";
|
|
|
|
import Link from "next/link";
|
|
import { FooterData } from "../../../../api/footerApi";
|
|
import footerData from "./footer.json";
|
|
|
|
interface FooterTopProps {
|
|
data: FooterData;
|
|
}
|
|
|
|
const FooterTop = ({ data }: FooterTopProps) => {
|
|
// Use passed data, fallback to static json if needed
|
|
const effectiveData = data || footerData;
|
|
|
|
// Ensure we always have a valid `top` object, even if API shape changes
|
|
const top = effectiveData?.top || footerData.top;
|
|
|
|
// If for some reason `top` is still missing, avoid rendering to prevent runtime errors
|
|
if (!top) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<footer
|
|
className="footer-section fix bg-cover"
|
|
style={top.bgImage ? { backgroundImage: `url('${top.bgImage}')` } : undefined}
|
|
>
|
|
<div className="container">
|
|
<div className="footer-wrapper">
|
|
<div className="row">
|
|
<div className="col-xl-12">
|
|
<div className="footer-item">
|
|
<h2>
|
|
<a href={top.phone.href}>{top.phone.display}</a>
|
|
</h2>
|
|
<h2 className="text">{top.address}</h2>
|
|
<div className="footer-list-item">
|
|
<Link href={top.logo.href}>
|
|
<img src={top.logo.src} alt={top.logo.alt} />
|
|
</Link>
|
|
<ul className="footer-list">
|
|
{top.menuLinks.map((item, index) => (
|
|
<li key={index}>
|
|
<Link href={item.href}>{item.label}</Link>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
<div className="social-icon">
|
|
{top.socialLinks.map((social, index) => (
|
|
<a key={index} href={social.href}>
|
|
<i className={social.icon}></i>
|
|
</a>
|
|
))}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
);
|
|
};
|
|
|
|
export default FooterTop;
|