mirror of
https://github.com/supabase/supabase.git
synced 2026-10-15 14:19:11 +03:00
22 lines
792 B
TypeScript
22 lines
792 B
TypeScript
import { useEffect, useState } from 'react'
|
|
import { useParams } from 'common/hooks'
|
|
import { maybeShowUpgradePrompt } from 'components/interfaces/Settings/Logs'
|
|
import { useProjectSubscriptionQuery } from 'data/subscriptions/project-subscription-query'
|
|
|
|
export const useUpgradePrompt = (from: string) => {
|
|
const { ref: projectRef } = useParams()
|
|
const { data: subscription } = useProjectSubscriptionQuery({ projectRef })
|
|
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 }
|
|
}
|