mirror of
https://github.com/supabase/supabase.git
synced 2026-10-08 19:05:06 +03:00
21 lines
778 B
TypeScript
21 lines
778 B
TypeScript
import { useEffect, useState } from 'react'
|
|
import { useParams } from 'common/hooks'
|
|
import { maybeShowUpgradePrompt } from 'components/interfaces/Settings/Logs'
|
|
import { useProjectSubscriptionV2Query } from 'data/subscriptions/project-subscription-v2-query'
|
|
|
|
export const useUpgradePrompt = (from: string) => {
|
|
const { ref: projectRef } = useParams()
|
|
const { data: subscription } = useProjectSubscriptionV2Query({ projectRef })
|
|
const [showUpgradePrompt, setShowUpgradePrompt] = useState(false)
|
|
|
|
const shouldShowUpgradePrompt = maybeShowUpgradePrompt(from, subscription?.plan?.id)
|
|
|
|
useEffect(() => {
|
|
if (shouldShowUpgradePrompt) {
|
|
setShowUpgradePrompt(true)
|
|
}
|
|
}, [from])
|
|
|
|
return { showUpgradePrompt, setShowUpgradePrompt, shouldShowUpgradePrompt }
|
|
}
|