import React, { useEffect, useState } from 'react' import { Link } from 'react-router-dom' import { FaArrowRight, FaChevronLeft, FaChevronRight, } from 'react-icons/fa' import { useLocalization } from '@/utils/hooks/useLocalization' import { ROUTES_ENUM } from '@/routes/route.constant' import { Helmet } from 'react-helmet' import { APP_NAME } from '@/constants/app.constant' import { useStoreActions, useStoreState } from '@/store' import Loading from '@/components/shared/Loading' import navigationIcon from '@/proxy/menus/navigation-icon.config' import DesignerDrawer from './designer/DesignerDrawer' import SelectableBlock from './designer/SelectableBlock' import { DesignerSelection } from './designer/types' import { useDesignerState } from './designer/useDesignerState' import { getHome, HomeDto, saveHomePage } from '@/services/home.service' import { Button, Notification, toast } from '@/components/ui' interface HomeSlideServiceContent { icon: string title: string titleKey: string description: string descriptionKey: string styleClass: string } interface HomeSlideContent { title: string titleKey: string subtitle: string subtitleKey: string styleClass: string services: HomeSlideServiceContent[] } interface HomeFeatureContent { icon: string title: string titleKey: string description: string descriptionKey: string styleClass: string } interface HomeSolutionContent { icon: string colorClass: string title: string titleKey: string description: string descriptionKey: string styleClass: string } interface HomeContent { heroBackgroundImage: string heroBackgroundImageKey: string heroPrimaryCtaLabel: string heroPrimaryCtaKey: string heroPrimaryCtaStyle: string heroPrimaryCtaStyleKey: string heroSecondaryCtaLabel: string heroSecondaryCtaKey: string heroSecondaryCtaStyle: string heroSecondaryCtaStyleKey: string featuresTitle: string featuresTitleKey: string featuresTitleStyle: string featuresTitleStyleKey: string featuresSubtitle: string featuresSubtitleKey: string featuresSubtitleStyle: string featuresSubtitleStyleKey: string solutionsTitle: string solutionsTitleKey: string solutionsTitleStyle: string solutionsTitleStyleKey: string solutionsSubtitle: string solutionsSubtitleKey: string solutionsSubtitleStyle: string solutionsSubtitleStyleKey: string ctaTitle: string ctaTitleKey: string ctaTitleStyle: string ctaTitleStyleKey: string ctaSubtitle: string ctaSubtitleKey: string ctaSubtitleStyle: string ctaSubtitleStyleKey: string ctaButtonLabel: string ctaButtonLabelKey: string ctaButtonStyle: string ctaButtonStyleKey: string slides: HomeSlideContent[] features: HomeFeatureContent[] solutions: HomeSolutionContent[] } const HOME_HERO_DEFAULT_IMAGE = 'https://images.pexels.com/photos/3183150/pexels-photo-3183150.jpeg?auto=compress&cs=tinysrgb&w=1920' const HOME_HERO_PRIMARY_CTA_STYLE_KEY = 'Public.home.hero.primaryCta.style' const HOME_HERO_SECONDARY_CTA_STYLE_KEY = 'Public.home.hero.secondaryCta.style' const HOME_FEATURES_TITLE_STYLE_KEY = 'Public.home.features.title.style' const HOME_FEATURES_SUBTITLE_STYLE_KEY = 'Public.home.features.subtitle.style' const HOME_SOLUTIONS_TITLE_STYLE_KEY = 'Public.home.solutions.title.style' const HOME_SOLUTIONS_SUBTITLE_STYLE_KEY = 'Public.home.solutions.subtitle.style' const HOME_CTA_TITLE_STYLE_KEY = 'Public.home.cta.title.style' const HOME_CTA_SUBTITLE_STYLE_KEY = 'Public.home.cta.subtitle.style' const HOME_CTA_BUTTON_STYLE_KEY = 'Public.home.cta.button.style' const HOME_HERO_PRIMARY_CTA_STYLE_DEFAULT = 'inline-flex items-center justify-center px-8 py-4 bg-gradient-to-r from-blue-500 to-purple-500 hover:from-blue-600 hover:to-purple-600 text-white rounded-lg font-semibold transition-all transform hover:scale-105' const HOME_HERO_SECONDARY_CTA_STYLE_DEFAULT = 'inline-flex items-center justify-center px-8 py-4 bg-white/10 hover:bg-white/20 text-white rounded-lg font-semibold backdrop-blur-sm transition-all transform hover:scale-105' const HOME_FEATURES_TITLE_STYLE_DEFAULT = 'text-4xl font-bold text-gray-900 dark:text-gray-100 mb-4' const HOME_FEATURES_SUBTITLE_STYLE_DEFAULT = 'text-xl text-gray-600 dark:text-gray-300 max-w-2xl mx-auto' const HOME_SOLUTIONS_TITLE_STYLE_DEFAULT = 'text-4xl font-bold text-gray-900 dark:text-gray-100 mb-4' const HOME_SOLUTIONS_SUBTITLE_STYLE_DEFAULT = 'text-xl text-gray-600 dark:text-gray-300 max-w-2xl mx-auto' const HOME_CTA_TITLE_STYLE_DEFAULT = 'text-3xl font-bold text-white mb-4' const HOME_CTA_SUBTITLE_STYLE_DEFAULT = 'text-white text-lg mb-8' const HOME_CTA_BUTTON_STYLE_DEFAULT = 'bg-white text-blue-600 px-8 py-3 rounded-lg font-semibold hover:bg-blue-50 transition-colors' const HOME_SLIDE_STYLE_DEFAULT = 'max-w-4xl mx-auto text-center' const HOME_SLIDE_SERVICE_STYLE_DEFAULT = 'bg-white/5 backdrop-blur-sm rounded-2xl p-8 text-center hover:scale-105 hover:bg-white/10 transition-all' const HOME_FEATURE_CARD_STYLE_DEFAULT = 'p-8 bg-white dark:bg-gray-900 rounded-xl shadow-lg hover:shadow-xl transition-shadow dark:shadow-gray-950/40' const HOME_SOLUTION_CARD_STYLE_DEFAULT = 'p-8 h-full rounded-2xl' function isLikelyLocalizationKey(value?: string) { return Boolean(value && /^[A-Za-z0-9_.-]+$/.test(value) && value.includes('.')) } function resolveLocalizedValue( translate: (key: string) => string, keyOrValue: string | undefined, fallback = '', ) { if (!keyOrValue) { return fallback } if (!isLikelyLocalizationKey(keyOrValue)) { return keyOrValue } const translatedValue = translate('::' + keyOrValue) return translatedValue === keyOrValue ? fallback || keyOrValue : translatedValue } function buildHomeContent(home: HomeDto | undefined, translate: (key: string) => string): HomeContent { const slideItems = home?.slidesDto || [] const featureItems = home?.featuresDto || [] const solutionItems = home?.solutionsDto || [] return { heroBackgroundImage: resolveLocalizedValue( translate, home?.heroBackgroundImageKey, HOME_HERO_DEFAULT_IMAGE, ), heroBackgroundImageKey: home?.heroBackgroundImageKey || '', heroPrimaryCtaLabel: resolveLocalizedValue(translate, home?.heroPrimaryCtaKey, ''), heroPrimaryCtaKey: home?.heroPrimaryCtaKey || '', heroPrimaryCtaStyle: resolveLocalizedValue( translate, HOME_HERO_PRIMARY_CTA_STYLE_KEY, HOME_HERO_PRIMARY_CTA_STYLE_DEFAULT, ), heroPrimaryCtaStyleKey: HOME_HERO_PRIMARY_CTA_STYLE_KEY, heroSecondaryCtaLabel: resolveLocalizedValue(translate, home?.heroSecondaryCtaKey, ''), heroSecondaryCtaKey: home?.heroSecondaryCtaKey || '', heroSecondaryCtaStyle: resolveLocalizedValue( translate, HOME_HERO_SECONDARY_CTA_STYLE_KEY, HOME_HERO_SECONDARY_CTA_STYLE_DEFAULT, ), heroSecondaryCtaStyleKey: HOME_HERO_SECONDARY_CTA_STYLE_KEY, featuresTitle: resolveLocalizedValue(translate, home?.featuresTitleKey, ''), featuresTitleKey: home?.featuresTitleKey || '', featuresTitleStyle: resolveLocalizedValue( translate, HOME_FEATURES_TITLE_STYLE_KEY, HOME_FEATURES_TITLE_STYLE_DEFAULT, ), featuresTitleStyleKey: HOME_FEATURES_TITLE_STYLE_KEY, featuresSubtitle: resolveLocalizedValue(translate, home?.featuresSubtitleKey, ''), featuresSubtitleKey: home?.featuresSubtitleKey || '', featuresSubtitleStyle: resolveLocalizedValue( translate, HOME_FEATURES_SUBTITLE_STYLE_KEY, HOME_FEATURES_SUBTITLE_STYLE_DEFAULT, ), featuresSubtitleStyleKey: HOME_FEATURES_SUBTITLE_STYLE_KEY, solutionsTitle: resolveLocalizedValue(translate, home?.solutionsTitleKey, ''), solutionsTitleKey: home?.solutionsTitleKey || '', solutionsTitleStyle: resolveLocalizedValue( translate, HOME_SOLUTIONS_TITLE_STYLE_KEY, HOME_SOLUTIONS_TITLE_STYLE_DEFAULT, ), solutionsTitleStyleKey: HOME_SOLUTIONS_TITLE_STYLE_KEY, solutionsSubtitle: resolveLocalizedValue(translate, home?.solutionsSubtitleKey, ''), solutionsSubtitleKey: home?.solutionsSubtitleKey || '', solutionsSubtitleStyle: resolveLocalizedValue( translate, HOME_SOLUTIONS_SUBTITLE_STYLE_KEY, HOME_SOLUTIONS_SUBTITLE_STYLE_DEFAULT, ), solutionsSubtitleStyleKey: HOME_SOLUTIONS_SUBTITLE_STYLE_KEY, ctaTitle: resolveLocalizedValue(translate, home?.ctaTitleKey, ''), ctaTitleKey: home?.ctaTitleKey || '', ctaTitleStyle: resolveLocalizedValue( translate, HOME_CTA_TITLE_STYLE_KEY, HOME_CTA_TITLE_STYLE_DEFAULT, ), ctaTitleStyleKey: HOME_CTA_TITLE_STYLE_KEY, ctaSubtitle: resolveLocalizedValue(translate, home?.ctaSubtitleKey, ''), ctaSubtitleKey: home?.ctaSubtitleKey || '', ctaSubtitleStyle: resolveLocalizedValue( translate, HOME_CTA_SUBTITLE_STYLE_KEY, HOME_CTA_SUBTITLE_STYLE_DEFAULT, ), ctaSubtitleStyleKey: HOME_CTA_SUBTITLE_STYLE_KEY, ctaButtonLabel: resolveLocalizedValue(translate, home?.ctaButtonLabelKey, ''), ctaButtonLabelKey: home?.ctaButtonLabelKey || '', ctaButtonStyle: resolveLocalizedValue( translate, HOME_CTA_BUTTON_STYLE_KEY, HOME_CTA_BUTTON_STYLE_DEFAULT, ), ctaButtonStyleKey: HOME_CTA_BUTTON_STYLE_KEY, slides: slideItems.map((slide) => ({ title: resolveLocalizedValue(translate, slide.titleKey, slide.titleKey), titleKey: slide.titleKey || '', subtitle: resolveLocalizedValue(translate, slide.subtitleKey, slide.subtitleKey), subtitleKey: slide.subtitleKey || '', styleClass: slide.styleClass || HOME_SLIDE_STYLE_DEFAULT, services: (slide.services || []).map((service) => ({ icon: service.icon || '', title: resolveLocalizedValue(translate, service.titleKey, service.titleKey), titleKey: service.titleKey || '', description: resolveLocalizedValue(translate, service.descriptionKey, service.descriptionKey), descriptionKey: service.descriptionKey || '', styleClass: service.styleClass || HOME_SLIDE_SERVICE_STYLE_DEFAULT, })), })), features: featureItems.map((feature) => ({ icon: feature.icon || '', title: resolveLocalizedValue(translate, feature.titleKey, feature.titleKey), titleKey: feature.titleKey || '', description: resolveLocalizedValue(translate, feature.descriptionKey, feature.descriptionKey), descriptionKey: feature.descriptionKey || '', styleClass: feature.styleClass || HOME_FEATURE_CARD_STYLE_DEFAULT, })), solutions: solutionItems.map((solution) => ({ icon: solution.icon || '', colorClass: solution.colorClass || '', title: resolveLocalizedValue(translate, solution.titleKey, solution.titleKey), titleKey: solution.titleKey || '', description: resolveLocalizedValue(translate, solution.descriptionKey, solution.descriptionKey), descriptionKey: solution.descriptionKey || '', styleClass: solution.styleClass || HOME_SOLUTION_CARD_STYLE_DEFAULT, })), } } const Home: React.FC = () => { const { translate } = useLocalization() const { setLang } = useStoreActions((actions) => actions.locale) const { getConfig } = useStoreActions((actions) => actions.abpConfig) const configCultureName = useStoreState( (state) => state.abpConfig.config?.localization.currentCulture.cultureName, ) const localeCurrentLang = useStoreState((state) => state.locale?.currentLang) const currentLanguage = configCultureName || localeCurrentLang || 'tr' const abpLanguages = useStoreState((state) => state.abpConfig.config?.localization.languages) || [] const languageOptions = abpLanguages .filter((language) => Boolean(language.cultureName)) .map((language) => { const cultureName = language.cultureName || 'tr' return { key: cultureName.toLowerCase().split('-')[0], cultureName, displayName: language.displayName || cultureName, } }) const languagesFromConfig = languageOptions.map((language) => language.key) const editorLanguages = Array.from( new Set((languagesFromConfig.length > 0 ? languagesFromConfig : [currentLanguage]).filter(Boolean)), ) const [home, setHome] = useState() const [loading, setLoading] = useState(true) const [isSaving, setIsSaving] = useState(false) const [isPanelVisible, setIsPanelVisible] = useState(true) const [currentSlide, setCurrentSlide] = useState(0) const initialContent = !loading ? buildHomeContent(home, translate) : null const { content, isDesignMode, selectedBlockId, selectedLanguage, supportedLanguages, setContent, setSelectedBlockId, resetContent, } = useDesignerState('home', initialContent, { currentLanguage, supportedLanguages: editorLanguages, }) useEffect(() => { setLoading(true) const fetchHome = async () => { try { const result = await getHome() setHome(result.data) } catch (error) { console.error('Home alinirken hata olustu:', error) } finally { setLoading(false) } } fetchHome() }, []) useEffect(() => { if (!content?.slides?.length) { return } if (currentSlide >= content.slides.length) { setCurrentSlide(0) } }, [content?.slides.length, currentSlide]) useEffect(() => { if (!content?.slides?.length) { return } const timer = setInterval(() => { setCurrentSlide((prev) => (prev + 1) % content.slides.length) }, 10000) return () => clearInterval(timer) }, [content?.slides.length]) const nextSlide = () => { const size = content?.slides.length || 1 setCurrentSlide((prev) => (prev + 1) % size) } const prevSlide = () => { const size = content?.slides.length || 1 setCurrentSlide((prev) => (prev - 1 + size) % size) } const updateContent = (updater: (current: HomeContent) => HomeContent) => { setContent((current) => { if (!current) { return current } return updater(current) }) } const handleFieldChange = (fieldKey: string, value: string | string[]) => { const nextValue = value as string updateContent((current) => { if ( fieldKey === 'heroBackgroundImage' || fieldKey === 'heroPrimaryCtaLabel' || fieldKey === 'heroPrimaryCtaStyle' || fieldKey === 'heroSecondaryCtaLabel' || fieldKey === 'heroSecondaryCtaStyle' || fieldKey === 'featuresTitle' || fieldKey === 'featuresTitleStyle' || fieldKey === 'featuresSubtitle' || fieldKey === 'featuresSubtitleStyle' || fieldKey === 'solutionsTitle' || fieldKey === 'solutionsTitleStyle' || fieldKey === 'solutionsSubtitle' || fieldKey === 'solutionsSubtitleStyle' || fieldKey === 'ctaTitle' || fieldKey === 'ctaTitleStyle' || fieldKey === 'ctaSubtitle' || fieldKey === 'ctaSubtitleStyle' || fieldKey === 'ctaButtonLabel' || fieldKey === 'ctaButtonStyle' ) { return { ...current, [fieldKey]: nextValue, } } if (selectedBlockId?.startsWith('slide-')) { const index = Number(selectedBlockId.replace('slide-', '')) if (Number.isNaN(index)) { return current } const slides = [...current.slides] const target = { ...slides[index] } if (fieldKey === 'title' || fieldKey === 'subtitle' || fieldKey === 'styleClass') { target[fieldKey] = nextValue } else if (fieldKey.startsWith('service-')) { const parts = fieldKey.split('-') const serviceIndex = Number(parts[1]) const serviceField = parts[2] as 'icon' | 'title' | 'description' | 'styleClass' const services = [...target.services] const service = { ...services[serviceIndex] } service[serviceField] = nextValue services[serviceIndex] = service target.services = services } slides[index] = target return { ...current, slides, } } if (selectedBlockId?.startsWith('feature-')) { const index = Number(selectedBlockId.replace('feature-', '')) if (Number.isNaN(index)) { return current } const features = [...current.features] const feature = { ...features[index] } const key = fieldKey as 'icon' | 'title' | 'description' | 'styleClass' feature[key] = nextValue features[index] = feature return { ...current, features, } } if (selectedBlockId?.startsWith('solution-')) { const index = Number(selectedBlockId.replace('solution-', '')) if (Number.isNaN(index)) { return current } const solutions = [...current.solutions] const solution = { ...solutions[index] } const key = fieldKey as 'icon' | 'title' | 'description' | 'colorClass' | 'styleClass' solution[key] = nextValue solutions[index] = solution return { ...current, solutions, } } return current }) } const selectedSelection: DesignerSelection | null = React.useMemo(() => { if (!content || !selectedBlockId) { return null } if (selectedBlockId === 'hero') { return { id: 'hero', title: 'Public.home.hero.*', description: 'Hero arka planini ve CTA metinlerini duzenleyin.', fields: [ { key: 'heroBackgroundImage', label: content.heroBackgroundImageKey, type: 'image', value: content.heroBackgroundImage, }, { key: 'heroPrimaryCtaLabel', label: content.heroPrimaryCtaKey, type: 'text', value: content.heroPrimaryCtaLabel, }, { key: 'heroPrimaryCtaStyle', label: content.heroPrimaryCtaStyleKey, type: 'text', value: content.heroPrimaryCtaStyle, }, { key: 'heroSecondaryCtaLabel', label: content.heroSecondaryCtaKey, type: 'text', value: content.heroSecondaryCtaLabel, }, { key: 'heroSecondaryCtaStyle', label: content.heroSecondaryCtaStyleKey, type: 'text', value: content.heroSecondaryCtaStyle, }, ], } } if (selectedBlockId.startsWith('slide-')) { const index = Number(selectedBlockId.replace('slide-', '')) const slide = content.slides[index] if (!slide) { return null } return { id: selectedBlockId, title: slide.titleKey, description: 'Slayt baslik, alt baslik ve servis kartlarini duzenleyin.', fields: [ { key: 'title', label: slide.titleKey, type: 'text', value: slide.title, }, { key: 'subtitle', label: slide.subtitleKey, type: 'textarea', value: slide.subtitle, }, { key: 'styleClass', label: `Slide${index + 1}.StyleClass`, type: 'text', value: slide.styleClass, }, ...slide.services.flatMap((service, serviceIndex) => [ { key: `service-${serviceIndex}-icon`, label: `Slide${index + 1}.Service${serviceIndex + 1}.Icon`, type: 'icon' as const, value: service.icon, placeholder: 'Ornek: FaUsers', }, { key: `service-${serviceIndex}-title`, label: service.titleKey, type: 'text' as const, value: service.title, }, { key: `service-${serviceIndex}-description`, label: service.descriptionKey, type: 'textarea' as const, value: service.description, }, { key: `service-${serviceIndex}-styleClass`, label: `Slide${index + 1}.Service${serviceIndex + 1}.StyleClass`, type: 'text' as const, value: service.styleClass, }, ]), ], } } if (selectedBlockId === 'features-heading') { return { id: selectedBlockId, title: content.featuresTitleKey, description: 'Features bolum basliklarini duzenleyin.', fields: [ { key: 'featuresTitle', label: content.featuresTitleKey, type: 'text', value: content.featuresTitle, }, { key: 'featuresTitleStyle', label: content.featuresTitleStyleKey, type: 'text', value: content.featuresTitleStyle, }, { key: 'featuresSubtitle', label: content.featuresSubtitleKey, type: 'textarea', value: content.featuresSubtitle, }, { key: 'featuresSubtitleStyle', label: content.featuresSubtitleStyleKey, type: 'text', value: content.featuresSubtitleStyle, }, ], } } if (selectedBlockId.startsWith('feature-')) { const index = Number(selectedBlockId.replace('feature-', '')) const item = content.features[index] if (!item) { return null } return { id: selectedBlockId, title: item.titleKey, description: 'Feature ikon ve metinlerini duzenleyin.', fields: [ { key: 'icon', label: `Feature${index + 1}.Icon`, type: 'icon', value: item.icon, placeholder: 'Ornek: FaChartBar', }, { key: 'title', label: item.titleKey, type: 'text', value: item.title, }, { key: 'description', label: item.descriptionKey, type: 'textarea', value: item.description, }, { key: 'styleClass', label: `Feature${index + 1}.StyleClass`, type: 'text', value: item.styleClass, }, ], } } if (selectedBlockId === 'solutions-heading') { return { id: selectedBlockId, title: content.solutionsTitleKey, description: 'Solutions bolum basliklarini duzenleyin.', fields: [ { key: 'solutionsTitle', label: content.solutionsTitleKey, type: 'text', value: content.solutionsTitle, }, { key: 'solutionsTitleStyle', label: content.solutionsTitleStyleKey, type: 'text', value: content.solutionsTitleStyle, }, { key: 'solutionsSubtitle', label: content.solutionsSubtitleKey, type: 'textarea', value: content.solutionsSubtitle, }, { key: 'solutionsSubtitleStyle', label: content.solutionsSubtitleStyleKey, type: 'text', value: content.solutionsSubtitleStyle, }, ], } } if (selectedBlockId.startsWith('solution-')) { const index = Number(selectedBlockId.replace('solution-', '')) const item = content.solutions[index] if (!item) { return null } return { id: selectedBlockId, title: item.titleKey, description: 'Solution kartini tamamen duzenleyin.', fields: [ { key: 'colorClass', label: `Solution${index + 1}.ColorClass`, type: 'text', value: item.colorClass, }, { key: 'icon', label: `Solution${index + 1}.Icon`, type: 'icon', value: item.icon, placeholder: 'Ornek: FaDesktop', }, { key: 'title', label: item.titleKey, type: 'text', value: item.title, }, { key: 'description', label: item.descriptionKey, type: 'textarea', value: item.description, }, { key: 'styleClass', label: `Solution${index + 1}.StyleClass`, type: 'text', value: item.styleClass, }, ], } } if (selectedBlockId === 'cta') { return { id: selectedBlockId, title: content.ctaTitleKey, description: 'Sayfa alti cta metinlerini duzenleyin.', fields: [ { key: 'ctaTitle', label: content.ctaTitleKey, type: 'text', value: content.ctaTitle, }, { key: 'ctaTitleStyle', label: content.ctaTitleStyleKey, type: 'text', value: content.ctaTitleStyle, }, { key: 'ctaSubtitle', label: content.ctaSubtitleKey, type: 'textarea', value: content.ctaSubtitle, }, { key: 'ctaSubtitleStyle', label: content.ctaSubtitleStyleKey, type: 'text', value: content.ctaSubtitleStyle, }, { key: 'ctaButtonLabel', label: content.ctaButtonLabelKey, type: 'text', value: content.ctaButtonLabel, }, { key: 'ctaButtonStyle', label: content.ctaButtonStyleKey, type: 'text', value: content.ctaButtonStyle, }, ], } } return null }, [content, selectedBlockId]) const handleSaveAndExit = async () => { if (!content || isSaving) { return } setIsSaving(true) try { await saveHomePage({ cultureName: selectedLanguage, heroBackgroundImageKey: content.heroBackgroundImageKey, heroBackgroundImageValue: content.heroBackgroundImage, heroPrimaryCtaKey: content.heroPrimaryCtaKey, heroPrimaryCtaValue: content.heroPrimaryCtaLabel, heroPrimaryCtaStyleKey: content.heroPrimaryCtaStyleKey, heroPrimaryCtaStyleValue: content.heroPrimaryCtaStyle, heroSecondaryCtaKey: content.heroSecondaryCtaKey, heroSecondaryCtaValue: content.heroSecondaryCtaLabel, heroSecondaryCtaStyleKey: content.heroSecondaryCtaStyleKey, heroSecondaryCtaStyleValue: content.heroSecondaryCtaStyle, featuresTitleKey: content.featuresTitleKey, featuresTitleValue: content.featuresTitle, featuresTitleStyleKey: content.featuresTitleStyleKey, featuresTitleStyleValue: content.featuresTitleStyle, featuresSubtitleKey: content.featuresSubtitleKey, featuresSubtitleValue: content.featuresSubtitle, featuresSubtitleStyleKey: content.featuresSubtitleStyleKey, featuresSubtitleStyleValue: content.featuresSubtitleStyle, solutionsTitleKey: content.solutionsTitleKey, solutionsTitleValue: content.solutionsTitle, solutionsTitleStyleKey: content.solutionsTitleStyleKey, solutionsTitleStyleValue: content.solutionsTitleStyle, solutionsSubtitleKey: content.solutionsSubtitleKey, solutionsSubtitleValue: content.solutionsSubtitle, solutionsSubtitleStyleKey: content.solutionsSubtitleStyleKey, solutionsSubtitleStyleValue: content.solutionsSubtitleStyle, ctaTitleKey: content.ctaTitleKey, ctaTitleValue: content.ctaTitle, ctaTitleStyleKey: content.ctaTitleStyleKey, ctaTitleStyleValue: content.ctaTitleStyle, ctaSubtitleKey: content.ctaSubtitleKey, ctaSubtitleValue: content.ctaSubtitle, ctaSubtitleStyleKey: content.ctaSubtitleStyleKey, ctaSubtitleStyleValue: content.ctaSubtitleStyle, ctaButtonLabelKey: content.ctaButtonLabelKey, ctaButtonLabelValue: content.ctaButtonLabel, ctaButtonStyleKey: content.ctaButtonStyleKey, ctaButtonStyleValue: content.ctaButtonStyle, slides: content.slides.map((slide, slideIndex) => ({ titleKey: slide.titleKey || '', titleValue: slide.title, subtitleKey: slide.subtitleKey || '', subtitleValue: slide.subtitle, styleClass: slide.styleClass, services: slide.services.map((service, serviceIndex) => ({ icon: service.icon, titleKey: service.titleKey || '', titleValue: service.title, descriptionKey: service.descriptionKey || '', descriptionValue: service.description, styleClass: service.styleClass, })), })), features: content.features.map((feature, index) => ({ icon: feature.icon, titleKey: feature.titleKey || '', titleValue: feature.title, descriptionKey: feature.descriptionKey || '', descriptionValue: feature.description, styleClass: feature.styleClass, })), solutions: content.solutions.map((solution, index) => ({ icon: solution.icon, colorClass: solution.colorClass, titleKey: solution.titleKey || '', titleValue: solution.title, descriptionKey: solution.descriptionKey || '', descriptionValue: solution.description, styleClass: solution.styleClass, })), }) await getConfig(false) setSelectedBlockId(null) toast.push( {translate('::ListForms.FormBilgileriKaydedildi')} , { placement: 'top-end', }, ) } catch (error) { console.error('Home tasarimi kaydedilemedi:', error) } finally { setIsSaving(false) } } const handleLanguageChange = (language: string) => { setLang(language) } const handleSelectBlock = (blockId: string) => { setSelectedBlockId(blockId) if (!isPanelVisible) { setIsPanelVisible(true) } } if (loading) { return (
) } return (
{isDesignMode && (
Home designer aktif
)} {isDesignMode && !isPanelVisible && ( )} {/* Hero Carousel */}
{/* Carousel Content */}
{(content?.slides || []).map((slide, index) => (
{ setCurrentSlide(index) handleSelectBlock(id) }} className="h-full" >

{slide.title}

{slide.subtitle}

{content?.heroPrimaryCtaLabel}{' '} {content?.heroSecondaryCtaLabel}
{slide.services.map((service, i) => (
{(() => { const IconComponent = navigationIcon[service.icon || ''] return IconComponent ? ( ) : null })()}

{service.title}

{service.description}

))}
))}
{/* Navigation Buttons */}
{isDesignMode && (
{(content?.slides || []).map((_, index) => ( ))}
)}
{/* Features */}

{content?.featuresTitle}

{content?.featuresSubtitle}

{(content?.features || []).map((feature, i) => (
{(() => { const IconComponent = navigationIcon[feature.icon || ''] return IconComponent ? : null })()}

{feature.title}

{feature.description}

))}
{/* Solutions */}

{content?.solutionsTitle}

{content?.solutionsSubtitle}

{(content?.solutions || []).map((s, i) => (
{(() => { const IconComponent = navigationIcon[s.icon || ''] return IconComponent ? : null })()}

{s.title}

{s.description}

))}
{/* Call to Action */}

{content?.ctaTitle}

{content?.ctaSubtitle}

{content?.ctaButtonLabel}
0 ? languageOptions : supportedLanguages.map((language) => ({ key: language, cultureName: language, displayName: language.toUpperCase(), })) } onClose={() => setIsPanelVisible(false)} onSave={handleSaveAndExit} onLanguageChange={handleLanguageChange} onReset={resetContent} onFieldChange={handleFieldChange} /> ) } export default Home