|
|
@ -25,6 +25,9 @@ import Link from 'next/link' |
|
|
import { ExternalLinks } from '@/config/external-links' |
|
|
import { ExternalLinks } from '@/config/external-links' |
|
|
import { CRYPTO_ADDRESSES } from '@/lib/constants' |
|
|
import { CRYPTO_ADDRESSES } from '@/lib/constants' |
|
|
import Image from 'next/image' |
|
|
import Image from 'next/image' |
|
|
|
|
|
import { ApiEndpoints } from '@/config/api' |
|
|
|
|
|
import httpBrowserClient from '@/lib/httpBrowserClient' |
|
|
|
|
|
import { useQuery } from '@tanstack/react-query' |
|
|
|
|
|
|
|
|
// Add constants for localStorage and timing
|
|
|
// Add constants for localStorage and timing
|
|
|
const STORAGE_KEYS = { |
|
|
const STORAGE_KEYS = { |
|
|
@ -46,15 +49,36 @@ export function ContributeModal() { |
|
|
setTimeout(() => setCopiedAddress(''), 3000) |
|
|
setTimeout(() => setCopiedAddress(''), 3000) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const { |
|
|
|
|
|
data: currentPlan, |
|
|
|
|
|
isLoading: isLoadingPlan, |
|
|
|
|
|
error: planError, |
|
|
|
|
|
} = useQuery({ |
|
|
|
|
|
queryKey: ['currentPlan'], |
|
|
|
|
|
queryFn: () => |
|
|
|
|
|
httpBrowserClient |
|
|
|
|
|
.get(ApiEndpoints.billing.currentPlan()) |
|
|
|
|
|
.then((res) => res.data), |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
const checkAndShowModal = () => { |
|
|
const checkAndShowModal = () => { |
|
|
setIsOpen(true) |
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isLoadingPlan) return |
|
|
|
|
|
if (planError) return |
|
|
|
|
|
|
|
|
|
|
|
if (currentPlan?.name?.toLowerCase() !== 'free') { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const hasContributed = |
|
|
const hasContributed = |
|
|
localStorage.getItem(STORAGE_KEYS.HAS_CONTRIBUTED) === 'true' |
|
|
localStorage.getItem(STORAGE_KEYS.HAS_CONTRIBUTED) === 'true' |
|
|
if (hasContributed) return |
|
|
if (hasContributed) return |
|
|
|
|
|
|
|
|
|
|
|
setIsOpen(true) |
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
const lastShown = localStorage.getItem(STORAGE_KEYS.LAST_SHOWN) |
|
|
const lastShown = localStorage.getItem(STORAGE_KEYS.LAST_SHOWN) |
|
|
const now = Date.now() |
|
|
const now = Date.now() |
|
|
|
|
|
|
|
|
@ -73,7 +97,7 @@ export function ContributeModal() { |
|
|
checkAndShowModal() |
|
|
checkAndShowModal() |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, []) |
|
|
|
|
|
|
|
|
}, [currentPlan?.name, isLoadingPlan, planError]) |
|
|
|
|
|
|
|
|
const handleContributed = () => { |
|
|
const handleContributed = () => { |
|
|
localStorage.setItem(STORAGE_KEYS.HAS_CONTRIBUTED, 'true') |
|
|
localStorage.setItem(STORAGE_KEYS.HAS_CONTRIBUTED, 'true') |
|
|
|