import React, { useState, useEffect } from 'react'; import { Hotel, Heart, MapPin, Phone, Mail, Linkedin, Twitter } from 'lucide-react'; import * as LucideIcons from 'lucide-react'; import { Link } from 'react-router-dom'; import pageContentService from '../services/pageContentService'; import type { PageContent } from '../services/pageContentService'; import { useCompanySettings } from '../../../shared/contexts/CompanySettingsContext'; import { createSanitizedHtml } from '../../../shared/utils/htmlSanitizer'; const AboutPage: React.FC = () => { const { settings } = useCompanySettings(); const [pageContent, setPageContent] = useState(null); const [apiError, setApiError] = useState(false); const [loading, setLoading] = useState(true); useEffect(() => { const fetchPageContent = async () => { try { setLoading(true); setApiError(false); const response = await pageContentService.getAboutContent(); if (response.status === 'success' && response.data?.page_content) { setPageContent(response.data.page_content); if (response.data.page_content.meta_title) { document.title = response.data.page_content.meta_title; } if (response.data.page_content.meta_description) { let metaDescription = document.querySelector('meta[name="description"]'); if (!metaDescription) { metaDescription = document.createElement('meta'); metaDescription.setAttribute('name', 'description'); document.head.appendChild(metaDescription); } metaDescription.setAttribute('content', response.data.page_content.meta_description); } } else { // No data received - don't set error, just leave pageContent as null setPageContent(null); } } catch (err: any) { console.error('Error fetching page content:', err); setApiError(true); setPageContent(null); } finally { setLoading(false); } }; fetchPageContent(); }, []); // 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 || null; const defaultValues = [ { icon: 'Heart', title: 'Passion', description: 'We are passionate about hospitality and dedicated to creating exceptional experiences for every guest.' }, { icon: 'Award', title: 'Excellence', description: 'We strive for excellence in every aspect of our service, from the smallest detail to the grandest gesture.' }, { icon: 'Shield', title: 'Integrity', description: 'We conduct our business with honesty, transparency, and respect for our guests and community.' }, { icon: 'Users', title: 'Service', description: 'Our guests are at the heart of everything we do. Your comfort and satisfaction are our top priorities.' } ]; const defaultFeatures = [ { icon: 'Star', title: 'Premium Accommodations', description: 'Luxuriously appointed rooms and suites designed for ultimate comfort and relaxation.' }, { icon: 'Clock', title: '24/7 Service', description: 'Round-the-clock concierge and room service to attend to your needs at any time.' }, { icon: 'Award', title: 'Award-Winning', description: 'Recognized for excellence in hospitality and guest satisfaction.' } ]; // Only use default values/features if pageContent was successfully loaded but is empty // Don't use defaults if API failed const values = pageContent && pageContent.values && pageContent.values.length > 0 ? pageContent.values.map((v: any) => ({ icon: v.icon || defaultValues.find(d => d.title === v.title)?.icon || 'Heart', title: v.title, description: v.description })) : (pageContent && !apiError ? defaultValues : []); const features = pageContent && pageContent.features && pageContent.features.length > 0 ? pageContent.features.map((f: any) => ({ icon: f.icon || defaultFeatures.find(d => d.title === f.title)?.icon || 'Star', title: f.title, description: f.description })) : (pageContent && !apiError ? defaultFeatures : []); const team = pageContent?.team && typeof pageContent.team === 'string' ? JSON.parse(pageContent.team) : (Array.isArray(pageContent?.team) ? pageContent.team : []); const timeline = pageContent?.timeline && typeof pageContent.timeline === 'string' ? JSON.parse(pageContent.timeline) : (Array.isArray(pageContent?.timeline) ? pageContent.timeline : []); const achievements = pageContent?.achievements && typeof pageContent.achievements === 'string' ? JSON.parse(pageContent.achievements) : (Array.isArray(pageContent?.achievements) ? pageContent.achievements : []); const getIconComponent = (iconName?: string) => { if (!iconName) return Heart; const IconComponent = (LucideIcons as any)[iconName] || Heart; return IconComponent; }; // Show error state if API failed if (apiError) { return (

Unable to Load Content

Please check your connection and try again later.

); } // Show loading state if (loading) { return (

Loading...

); } return (
{}
{pageContent?.about_hero_image && (
About Hero
)} {!pageContent?.about_hero_image && (
)}
{!pageContent?.about_hero_image && (
)}

{pageContent?.title || 'About Luxury Hotel'}

{pageContent?.subtitle || pageContent?.description || 'Where Excellence Meets Unforgettable Experiences'}

{}
Our Heritage

Our Story

{pageContent?.story_content ? (
'))} /> ) : ( <>

Welcome to Luxury Hotel, where timeless elegance meets modern sophistication. Since our founding, we have been dedicated to providing exceptional hospitality and creating unforgettable memories for our guests.

Nestled in the heart of the city, our hotel combines classic architecture with contemporary amenities, offering a perfect blend of comfort and luxury. Every detail has been carefully curated to ensure your stay exceeds expectations.

Our commitment to excellence extends beyond our beautiful rooms and facilities. We believe in creating meaningful connections with our guests, understanding their needs, and delivering personalized service that makes each visit special.

)}
{} {values.length > 0 && (
Core Principles

Our Values

{values.map((value, index) => (
{(() => { const ValueIcon = getIconComponent(value.icon); return ; })()}

{value.title}

{value.description}

))}
)} {} {features.length > 0 && (
Excellence Defined

Why Choose Us

{features.map((feature, index) => { const FeatureIcon = getIconComponent(feature.icon); return (

{feature.title}

{feature.description}

); })}
)} {(pageContent?.mission || pageContent?.vision) && (
{pageContent.mission && (

Our Mission

{pageContent.mission}

)} {pageContent.vision && (

Our Vision

{pageContent.vision}

)}
)} {} {team && team.length > 0 && (
Meet The Experts

Our Team

{team.map((member: any, index: number) => (
{member.image && (
{member.name}
)}

{member.name}

{member.role}

{member.bio &&

{member.bio}

} {member.social_links && (
{member.social_links.linkedin && ( )} {member.social_links.twitter && ( )}
)}
))}
)} {} {timeline && timeline.length > 0 && (
Our Journey

Our History

{timeline.map((event: any, index: number) => (
{event.year}

{event.title}

{event.description}

{event.image && (
{event.title}
)}
))}
)} {} {achievements && achievements.length > 0 && (
Recognition

Achievements & Awards

{achievements.map((achievement: any, index: number) => { const AchievementIcon = getIconComponent(achievement.icon); return (
{achievement.year && (
{achievement.year}
)}

{achievement.title}

{achievement.description}

{achievement.image && (
{achievement.title}
)}
); })}
)} {}
Connect With Us

Get In Touch

We'd love to hear from you. Contact us for reservations or inquiries.

{(displayAddress || displayPhone || displayEmail) && (
{displayAddress && (

Address

{displayAddress .split('\n').map((line, i) => ( {line} {i < displayAddress.split('\n').length - 1 &&
}
))}

)} {displayPhone && ( )} {displayEmail && ( )}
)}
Explore Our Rooms
); }; export default AboutPage;