'use client' import type { FC } from 'react' import React from 'react' import { createPortal } from 'react-dom' import { useTranslation } from 'react-i18next' import { RiArrowRightUpLine, RiCloseLine, RiCloudFill, RiTerminalBoxFill } from '@remixicon/react' import Link from 'next/link' import { useKeyPress } from 'ahooks' import { Plan, SelfHostedPlan } from '../type' import TabSlider from '../../base/tab-slider' import SelectPlanRange, { PlanRange } from './select-plan-range' import PlanItem from './plan-item' import SelfHostedPlanItem from './self-hosted-plan-item' import { useProviderContext } from '@/context/provider-context' import GridMask from '@/app/components/base/grid-mask' import { useAppContext } from '@/context/app-context' import classNames from '@/utils/classnames' type Props = { onCancel: () => void } const Pricing: FC = ({ onCancel, }) => { const { t } = useTranslation() const { plan } = useProviderContext() const { isCurrentWorkspaceManager } = useAppContext() const canPay = isCurrentWorkspaceManager const [planRange, setPlanRange] = React.useState(PlanRange.monthly) const [currentPlan, setCurrentPlan] = React.useState('cloud') useKeyPress(['esc'], onCancel) return createPortal(
e.stopPropagation()} >
{t('billing.plansCommon.title')}
{t('billing.plansCommon.freeTrialTipPrefix')} {t('billing.plansCommon.freeTrialTip')} {t('billing.plansCommon.freeTrialTipSuffix')}
{t('billing.plansCommon.cloud')}
, }, { value: 'self', text:
{t('billing.plansCommon.self')}
, }]} onChange={v => setCurrentPlan(v)} /> {currentPlan === 'cloud' && }
{currentPlan === 'cloud' && <> } {currentPlan === 'self' && <> }
{t('billing.plansCommon.comparePlanAndFeatures')}
, document.body, ) } export default React.memo(Pricing)