mirror of
https://github.com/supabase/supabase.git
synced 2026-10-09 03:15:06 +03:00
24 lines
814 B
TypeScript
24 lines
814 B
TypeScript
import { useEffect, useState } from 'react'
|
|
import { useProjectSubscription } from 'hooks'
|
|
import { useRouter } from 'next/router'
|
|
import { maybeShowUpgradePrompt } from 'components/interfaces/Settings/Logs'
|
|
import { StripeProduct } from 'components/interfaces/Billing'
|
|
|
|
export const useUpgradePrompt = (from: string) => {
|
|
const router = useRouter()
|
|
const { ref } = router.query
|
|
const { subscription } = useProjectSubscription(ref as string)
|
|
const tier = subscription?.tier
|
|
const [showUpgradePrompt, setShowUpgradePrompt] = useState(false)
|
|
|
|
const shouldShowUpgradePrompt = maybeShowUpgradePrompt(from, tier?.key)
|
|
|
|
useEffect(() => {
|
|
if (shouldShowUpgradePrompt) {
|
|
setShowUpgradePrompt(true)
|
|
}
|
|
}, [from])
|
|
|
|
return { showUpgradePrompt, setShowUpgradePrompt, shouldShowUpgradePrompt }
|
|
}
|