'use client'; import React, { useEffect, useState } from 'react'; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; import { Heart, Github } from 'lucide-react'; const DONATE_POPUP_KEY = 'opendevsociety-donate-popup-dismissed'; const DONATE_POPUP_DELAY = 3000; // Show after 3 seconds const DONATE_POPUP_COOLDOWN = 24 * 60 * 60 * 1000; // 24 hours in milliseconds const GITHUB_SPONSOR_URL = 'https://github.com/sponsors/ravixalgorithm'; export default function DonatePopup() { const [open, setOpen] = useState(false); useEffect(() => { // Check if user has dismissed popup const dismissed = localStorage.getItem(DONATE_POPUP_KEY); if (dismissed) { const dismissedTime = parseInt(dismissed, 10); const now = Date.now(); // Show again after cooldown period if (now - dismissedTime < DONATE_POPUP_COOLDOWN) { return; } } // Show popup after delay const timer = setTimeout(() => { setOpen(true); }, DONATE_POPUP_DELAY); return () => clearTimeout(timer); }, []); // Listen for custom event from donate button useEffect(() => { const handleOpenPopup = () => setOpen(true); window.addEventListener('open-donate-popup', handleOpenPopup); return () => window.removeEventListener('open-donate-popup', handleOpenPopup); }, []); const handleDismiss = () => { setOpen(false); // Store dismissal time localStorage.setItem(DONATE_POPUP_KEY, Date.now().toString()); }; const handleDonate = () => { window.open(GITHUB_SPONSOR_URL, '_blank', 'noopener,noreferrer'); handleDismiss(); }; return (
Keep OpenStock Free
Your overwhelming love for OpenStock and Open Dev Society has helped us grow, but we're hitting Vercel's free tier limits.

Help us keep OpenStock free and accessible for everyone by supporting us on GitHub Sponsors. Every contribution, no matter how small, makes a difference! 💙

This popup won't appear again for 24 hours after dismissing

); }