import React, { useState, useEffect } from 'react'; import { X, Zap, Timer } from 'lucide-react'; import { Language, WeddingStyle, AdminConfig, UserAccount } from '../types'; import { TRANSLATIONS } from '../constants/translations'; interface SlashModalProps { isVisible: boolean; onClose: () => void; language: Language; style: WeddingStyle | null; onUnlock: () => void; adminConfig: AdminConfig; user?: UserAccount; onUpdateUser: (progress: Record) => void; onOpenShare: () => void; } export const SlashModal: React.FC = ({ isVisible, onClose, language, style, onUnlock, adminConfig, user, onUpdateUser, onOpenShare }) => { const t = TRANSLATIONS[language]; const [progress, setProgress] = useState(98); useEffect(() => { if (isVisible && style) { if (user?.slashProgress && user.slashProgress[style.id]) { setProgress(user.slashProgress[style.id]); } else { setProgress(98); } } }, [isVisible, style, user]); if (!isVisible || !style) return null; const styleName = (t.styles as any)[style.id] || style.name; const handleInvite = () => { onOpenShare(); // Update progress logic const remaining = 100 - progress; // Slash logic: Cut 50-80% of remaining const cutPercent = 0.5 + Math.random() * 0.3; let newProgress = progress + (remaining * cutPercent); // If very close, complete it (e.g. > 99.5) if (newProgress > 99.5) { newProgress = 100; } setProgress(newProgress); if (user) { const newMap = { ...(user.slashProgress || {}), [style.id]: newProgress }; onUpdateUser(newMap); } if (newProgress >= 100) { onUnlock(); } onClose(); }; return (
Ends in 23:59:10

{t.pddSlashTitle}

{t.pddSlashDesc}

{/* Product Card */}
IMG

{styleName}

VIP Premium Collection

¥0.00 ¥199

{/* Progress Bar */}
{t.pddSlashProgress} {progress.toFixed(2)}%
Only {(100 - progress).toFixed(2)}% left!
{/* Social Proof List */}

Friends who helped

{[1,2,3].map(i => (
))}
+99
); };