updates
This commit is contained in:
@@ -34,16 +34,22 @@ const Footer: React.FC = () => {
|
||||
const { settings } = useCompanySettings();
|
||||
const [pageContent, setPageContent] = useState<PageContent | null>(null);
|
||||
const [enabledPages, setEnabledPages] = useState<Set<string>>(new Set());
|
||||
const [apiError, setApiError] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchPageContent = async () => {
|
||||
try {
|
||||
setApiError(false);
|
||||
const response = await pageContentService.getFooterContent();
|
||||
if (response.status === 'success' && response.data?.page_content) {
|
||||
setPageContent(response.data.page_content);
|
||||
} else {
|
||||
setPageContent(null);
|
||||
}
|
||||
} catch (err: any) {
|
||||
console.error('Error fetching footer content:', err);
|
||||
setApiError(true);
|
||||
setPageContent(null);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -82,9 +88,10 @@ const Footer: React.FC = () => {
|
||||
}, []);
|
||||
|
||||
|
||||
// Only use company settings from API, no hardcoded fallbacks
|
||||
const displayPhone = settings.company_phone || null;
|
||||
const displayEmail = settings.company_email || null;
|
||||
const displayAddress = settings.company_address || '123 ABC Street, District 1\nHo Chi Minh City, Vietnam';
|
||||
const displayAddress = settings.company_address || null;
|
||||
const phoneNumber = displayPhone ? displayPhone.replace(/\s+/g, '').replace(/[()]/g, '') : '';
|
||||
const phoneHref = displayPhone ? 'tel:' + phoneNumber : '';
|
||||
|
||||
@@ -134,13 +141,15 @@ const Footer: React.FC = () => {
|
||||
{ label: 'Contact Us', url: '/contact' }
|
||||
];
|
||||
|
||||
// Only use default links if pageContent was successfully loaded but is empty
|
||||
// Don't use defaults if API failed
|
||||
const quickLinks = pageContent?.footer_links?.quick_links && pageContent.footer_links.quick_links.length > 0
|
||||
? pageContent.footer_links.quick_links
|
||||
: defaultQuickLinks;
|
||||
: (pageContent && !apiError ? defaultQuickLinks : []);
|
||||
|
||||
const allSupportLinks = pageContent?.footer_links?.support_links && pageContent.footer_links.support_links.length > 0
|
||||
? pageContent.footer_links.support_links
|
||||
: defaultSupportLinks;
|
||||
: (pageContent && !apiError ? defaultSupportLinks : []);
|
||||
|
||||
// Filter support links to only show enabled policy pages
|
||||
const supportLinks = allSupportLinks.filter((link) => {
|
||||
@@ -284,6 +293,7 @@ const Footer: React.FC = () => {
|
||||
</div>
|
||||
|
||||
{/* Quick Links */}
|
||||
{quickLinks.length > 0 && (
|
||||
<div>
|
||||
<h3 className="text-white font-elegant font-semibold text-lg sm:text-xl mb-6 sm:mb-8 relative inline-block tracking-wide">
|
||||
<span className="relative z-10">Quick Links</span>
|
||||
@@ -303,8 +313,10 @@ const Footer: React.FC = () => {
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Guest Services */}
|
||||
{supportLinks.length > 0 && (
|
||||
<div>
|
||||
<h3 className="text-white font-elegant font-semibold text-lg sm:text-xl mb-6 sm:mb-8 relative inline-block tracking-wide">
|
||||
<span className="relative z-10">Guest Services</span>
|
||||
@@ -324,6 +336,7 @@ const Footer: React.FC = () => {
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Contact Information */}
|
||||
<div>
|
||||
@@ -331,7 +344,9 @@ const Footer: React.FC = () => {
|
||||
<span className="relative z-10">Contact</span>
|
||||
<span className="absolute bottom-0 left-0 w-full h-[2px] bg-gradient-to-r from-[#d4af37] via-[#d4af37]/50 to-transparent"></span>
|
||||
</h3>
|
||||
{(displayAddress || displayPhone || displayEmail) && (
|
||||
<ul className="space-y-5 sm:space-y-6">
|
||||
{displayAddress && (
|
||||
<li className="flex items-start space-x-4 group">
|
||||
<div className="relative mt-1 flex-shrink-0">
|
||||
<div className="p-2 bg-gradient-to-br from-[#d4af37]/10 to-[#c9a227]/5 rounded-lg border border-[#d4af37]/20 group-hover:border-[#d4af37]/40 transition-all duration-300">
|
||||
@@ -340,15 +355,16 @@ const Footer: React.FC = () => {
|
||||
<div className="absolute inset-0 bg-[#d4af37]/20 blur-xl opacity-0 group-hover:opacity-100 transition-opacity duration-500"></div>
|
||||
</div>
|
||||
<span className="text-sm sm:text-base text-gray-400 group-hover:text-gray-300 transition-colors leading-relaxed font-light pt-1">
|
||||
{(displayAddress
|
||||
{displayAddress
|
||||
.split('\n').map((line, i) => (
|
||||
<React.Fragment key={i}>
|
||||
{line}
|
||||
{i < displayAddress.split('\n').length - 1 && <br />}
|
||||
</React.Fragment>
|
||||
)))}
|
||||
))}
|
||||
</span>
|
||||
</li>
|
||||
)}
|
||||
{displayPhone && (
|
||||
<li className="flex items-center space-x-4 group">
|
||||
<div className="relative flex-shrink-0">
|
||||
@@ -376,6 +392,7 @@ const Footer: React.FC = () => {
|
||||
</li>
|
||||
)}
|
||||
</ul>
|
||||
)}
|
||||
|
||||
{/* Rating Section */}
|
||||
<div className="mt-8 sm:mt-10 pt-6 sm:pt-8 border-t border-gray-800/50">
|
||||
|
||||
Reference in New Issue
Block a user