'use client' import { useState, useEffect } from 'react' import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from '@/components/ui/dialog' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' import { Button } from '@/components/ui/button' import { CircleDollarSign, Github, Heart, MessageSquare, Star, } from 'lucide-react' import Link from 'next/link' import { ExternalLinks } from '@/config/external-links' // Add constants for localStorage and timing const STORAGE_KEYS = { LAST_SHOWN: 'contribute_modal_last_shown', HAS_CONTRIBUTED: 'contribute_modal_has_contributed', } const SHOW_INTERVAL = 1 * 24 * 60 * 60 * 1000 // 1 days in milliseconds const RANDOM_CHANCE = 0.2 // 20% chance to show when eligible export function ContributeModal() { const [isOpen, setIsOpen] = useState(false) useEffect(() => { const checkAndShowModal = () => { const hasContributed = localStorage.getItem(STORAGE_KEYS.HAS_CONTRIBUTED) === 'true' if (hasContributed) return const lastShown = localStorage.getItem(STORAGE_KEYS.LAST_SHOWN) const now = Date.now() if (!lastShown || now - parseInt(lastShown) >= SHOW_INTERVAL) { if (Math.random() < RANDOM_CHANCE) { setIsOpen(true) localStorage.setItem(STORAGE_KEYS.LAST_SHOWN, now.toString()) } } } checkAndShowModal() document.addEventListener('visibilitychange', () => { if (document.visibilityState === 'visible') { checkAndShowModal() } }) }, []) const handleContributed = () => { localStorage.setItem(STORAGE_KEYS.HAS_CONTRIBUTED, 'true') setIsOpen(false) } return ( Support textbee.dev Your contribution helps keep this project alive and growing.
Financial Support
Code Contributions
) }