'use client' import type { PropsWithChildren } from 'react' import { useState } from 'react' import { useTranslation } from 'react-i18next' import { PlanUpgradeModal } from '@/app/components/billing/plan-upgrade-modal' import { Plan } from '@/app/components/billing/type' import UpgradeBtn from '@/app/components/billing/upgrade-btn' import { useProviderContext } from '@/context/provider-context' export const WorkflowVersionApiContent = ({ children }: PropsWithChildren) => { const { plan, enableBilling, isFetchedPlan } = useProviderContext() if (enableBilling && (!isFetchedPlan || plan.type === Plan.sandbox)) return
return children } export const WorkflowVersionApiUpgradeNotice = () => { const { t } = useTranslation('billing') const { plan, enableBilling, isFetchedPlan } = useProviderContext() const [isPlanUpgradeModalOpen, setIsPlanUpgradeModalOpen] = useState(false) if (!isFetchedPlan || !enableBilling || plan.type !== Plan.sandbox) return null const title = t(($) => $['upgrade.workflowVersionRun.title']) const description = t(($) => $['upgrade.workflowVersionRun.description']) return ( <> setIsPlanUpgradeModalOpen(true)} /> {isPlanUpgradeModalOpen && ( setIsPlanUpgradeModalOpen(false)} title={title} description={description} /> )} ) }