import React, { useState, useRef, useEffect } from 'react'; import { Check, ChevronRight } from 'lucide-react'; import { renderDisclaimerContent } from '../utils/renderDisclaimerContent'; export interface DisclaimerSection { title: string; content: React.ReactNode; required?: boolean; } export interface DisclaimerContent { title: string; required?: boolean; content: { title: string; sections: { heading: string; text: string; list?: string[]; }[]; }; } export interface ThemeConfig { modal: string; header: string; tabBorder: string; activeTab: string; inactiveTab: string; completedTab: string; content: string; footer: string; checkbox: { base: string; checked: string; disabled: string; }; text: { enabled: string; disabled: string; }; } export interface DisclaimerModalProps { isOpen: boolean; onClose: () => void; title: string; disclaimerContent?: Record; disclaimerSections?: DisclaimerSection[]; theme?: 'dark' | 'light'; customTheme?: ThemeConfig; setAllAgreed?: (allAgreed: boolean) => void; onAllSectionsAgreed?: (allAgreed: boolean) => void; accentColor?: string; } const getThemeClasses = (theme: 'dark' | 'light'): ThemeConfig => { const themes: Record<'dark' | 'light', ThemeConfig> = { dark: { modal: 'bg-gray-900 text-white', header: 'border-gray-800 bg-gray-900/95 backdrop-blur-sm', tabBorder: 'border-gray-800', activeTab: 'text-blue-400 border-blue-400', inactiveTab: 'text-gray-400 border-transparent hover:text-blue-400/80', completedTab: 'text-emerald-400', content: 'prose-invert', footer: 'border-gray-800 bg-gray-900/95 backdrop-blur-sm', checkbox: { base: 'border-gray-600 group-hover:border-blue-400', checked: 'bg-blue-500 border-blue-500', disabled: 'opacity-50 cursor-not-allowed' }, text: { enabled: 'text-gray-200', disabled: 'text-gray-500' } }, light: { modal: 'bg-white text-gray-900', header: 'border-gray-200 bg-white/95 backdrop-blur-sm', tabBorder: 'border-gray-200', activeTab: 'text-blue-600 border-blue-600', inactiveTab: 'text-gray-500 border-transparent hover:text-blue-600/80', completedTab: 'text-emerald-600', content: 'prose-base', footer: 'border-gray-200 bg-white/95 backdrop-blur-sm', checkbox: { base: 'border-gray-300 group-hover:border-blue-500', checked: 'bg-blue-600 border-blue-600', disabled: 'opacity-50 cursor-not-allowed' }, text: { enabled: 'text-gray-900', disabled: 'text-gray-500' } } }; return themes[theme]; }; const TabContent: React.FC<{ content: React.ReactNode; onScroll: (isComplete: boolean) => void; onAgree: () => void; isActive: boolean; isScrolled: boolean; isAgreed: boolean; sectionTitle: string; theme: 'dark' | 'light'; }> = ({ content, onScroll, onAgree, isActive, isScrolled, isAgreed, sectionTitle, theme }) => { const contentRef = useRef(null); const themeClasses = getThemeClasses(theme); useEffect(() => { const checkScroll = () => { if (!contentRef.current) return; const { scrollHeight, scrollTop, clientHeight } = contentRef.current; const isAtBottom = scrollHeight - scrollTop - clientHeight < 20; if (isAtBottom && !isScrolled) { onScroll(true); } }; const contentElement = contentRef.current; if (contentElement) { contentElement.addEventListener('scroll', checkScroll); // Check initial scroll position checkScroll(); return () => contentElement.removeEventListener('scroll', checkScroll); } }, [onScroll, isScrolled]); if (!isActive) return null; return (
{content}