"use client"; import { useEffect, useState } from "react"; import { Button } from "@/components/ui/button"; import { Flame, Sparkles } from "lucide-react"; import { useActiveUser } from "@/hooks/useActiveUser"; import { useTheme } from "next-themes"; export function StreakOnboardingModal() { const { user, loading } = useActiveUser(); const { theme } = useTheme(); const [isOpen, setIsOpen] = useState(false); useEffect(() => { if (loading || !user) return; // Check sessionStorage const hasSeen = sessionStorage.getItem(`hasSeenStreakPopup_${user.id}`); if (!hasSeen) { setIsOpen(true); } }, [user, loading]); if (!isOpen || !user) return null; const streak = user.streak_count; const targetExam = user.target_exam?.replace("_", " ") || "JEE/NEET"; // Streak-based wishes and titles let wishTitle = "Welcome to PragatiVeer! 🌟"; let wishMessage = `Prepare yourself to conquer ${targetExam}. Your daily practice starts here!`; if (streak === 0) { wishTitle = "Start Your Streak Today! 🚀"; wishMessage = "Today is Day 1 of your journey. Establish your streak now and build the consistency needed for IIT/AIIMS!"; } else if (streak < 4) { wishTitle = "Keep the Fire Burning! 🔥"; wishMessage = `Great job! You have maintained a ${streak}-day study streak. Keep practicing daily to build solid muscle memory!`; } else { wishTitle = "Unstoppable Dedication! ⚡"; wishMessage = `Incredible! A ${streak}-day streak shows true championship discipline. You are outperforming the competition. Let's make today count!`; } const handleEnter = () => { sessionStorage.setItem(`hasSeenStreakPopup_${user.id}`, "true"); setIsOpen(false); }; // Calculate trial days left let trialDaysLeft = 0; if (user.trial_end) { const end = new Date(user.trial_end); const now = new Date(); const diffTime = end.getTime() - now.getTime(); trialDaysLeft = Math.ceil(diffTime / (1000 * 60 * 60 * 24)); } return (
{wishMessage}