This commit is contained in:
Iliyan Angelov
2025-11-21 10:55:05 +02:00
parent 722997bb19
commit 4ab7546de0
53 changed files with 3091 additions and 56 deletions

View File

@@ -34,6 +34,7 @@ import { useCompanySettings } from '../../contexts/CompanySettingsContext';
const Footer: React.FC = () => {
const { settings } = useCompanySettings();
const [pageContent, setPageContent] = useState<PageContent | null>(null);
const [enabledPages, setEnabledPages] = useState<Set<string>>(new Set());
useEffect(() => {
const fetchPageContent = async () => {
@@ -44,11 +45,41 @@ const Footer: React.FC = () => {
}
} catch (err: any) {
console.error('Error fetching footer content:', err);
}
};
const checkEnabledPages = async () => {
const enabled = new Set<string>();
const policyPages = [
{ type: 'privacy', url: '/privacy', service: () => pageContentService.getPrivacyContent() },
{ type: 'terms', url: '/terms', service: () => pageContentService.getTermsContent() },
{ type: 'refunds', url: '/refunds', service: () => pageContentService.getRefundsContent() },
{ type: 'cancellation', url: '/cancellation', service: () => pageContentService.getCancellationContent() },
{ type: 'accessibility', url: '/accessibility', service: () => pageContentService.getAccessibilityContent() },
{ type: 'faq', url: '/faq', service: () => pageContentService.getFAQContent() },
];
await Promise.all(
policyPages.map(async (page) => {
try {
const response = await page.service();
if (response.status === 'success' && response.data?.page_content?.is_active) {
enabled.add(page.url);
}
} catch (err: any) {
// If 404, page is disabled, don't add to enabled set
if (err.response?.status !== 404) {
console.error(`Error checking ${page.type} page:`, err);
}
}
})
);
setEnabledPages(enabled);
};
fetchPageContent();
checkEnabledPages();
}, []);
@@ -97,6 +128,9 @@ const Footer: React.FC = () => {
{ label: 'FAQ', url: '/faq' },
{ label: 'Terms of Service', url: '/terms' },
{ label: 'Privacy Policy', url: '/privacy' },
{ label: 'Refunds Policy', url: '/refunds' },
{ label: 'Cancellation Policy', url: '/cancellation' },
{ label: 'Accessibility', url: '/accessibility' },
{ label: 'Contact Us', url: '/contact' }
];
@@ -104,10 +138,18 @@ const Footer: React.FC = () => {
? pageContent.footer_links.quick_links
: defaultQuickLinks;
const supportLinks = pageContent?.footer_links?.support_links && pageContent.footer_links.support_links.length > 0
const allSupportLinks = pageContent?.footer_links?.support_links && pageContent.footer_links.support_links.length > 0
? pageContent.footer_links.support_links
: defaultSupportLinks;
// Filter support links to only show enabled policy pages
const supportLinks = allSupportLinks.filter((link) => {
// Always show Contact Us
if (link.url === '/contact') return true;
// Only show policy pages if they are enabled
return enabledPages.has(link.url);
});
return (
<footer className="relative bg-gradient-to-b from-[#0f0f0f] via-[#1a1a1a] to-black text-gray-300 overflow-hidden">
{/* Top Gold Accent Line */}
@@ -370,9 +412,11 @@ const Footer: React.FC = () => {
})()}
</div>
<div className="flex items-center space-x-4 sm:space-x-6 text-xs sm:text-sm text-gray-600">
<span className="hover:text-[#d4af37] transition-colors cursor-pointer font-light tracking-wide">Privacy</span>
<Link to="/privacy" className="hover:text-[#d4af37] transition-colors cursor-pointer font-light tracking-wide">Privacy</Link>
<span className="text-gray-700"></span>
<span className="hover:text-[#d4af37] transition-colors cursor-pointer font-light tracking-wide">Terms</span>
<Link to="/terms" className="hover:text-[#d4af37] transition-colors cursor-pointer font-light tracking-wide">Terms</Link>
<span className="text-gray-700"></span>
<Link to="/refunds" className="hover:text-[#d4af37] transition-colors cursor-pointer font-light tracking-wide">Refunds</Link>
<span className="text-gray-700"></span>
<CookiePreferencesLink />
</div>