'use client' import type { FC } from 'react' import React from 'react' import { useTranslation } from 'react-i18next' import { useRouter } from 'next/navigation' import { RiBook2Line, RiBox3Line, RiFileEditLine, RiGraduationCapLine, RiGroup3Line, RiGroupLine, RiSquareLine, } from '@remixicon/react' import { Plan, SelfHostedPlan } from '../type' import VectorSpaceInfo from '../usage-info/vector-space-info' import AppsInfo from '../usage-info/apps-info' import UpgradeBtn from '../upgrade-btn' import { useProviderContext } from '@/context/provider-context' import { useAppContext } from '@/context/app-context' import Button from '@/app/components/base/button' import UsageInfo from '@/app/components/billing/usage-info' import VerifyStateModal from '@/app/education-apply/verify-state-modal' import { EDUCATION_VERIFYING_LOCALSTORAGE_ITEM } from '@/app/education-apply/constants' import { useEducationVerify } from '@/service/use-education' import { useModalContextSelector } from '@/context/modal-context' type Props = { loc: string } const PlanComp: FC = ({ loc, }) => { const { t } = useTranslation() const router = useRouter() const { userProfile } = useAppContext() const { plan, enableEducationPlan, isEducationAccount } = useProviderContext() const { type, } = plan const { usage, total, } = plan const [showModal, setShowModal] = React.useState(false) const { mutateAsync } = useEducationVerify() const setShowAccountSettingModal = useModalContextSelector(s => s.setShowAccountSettingModal) const handleVerify = () => { mutateAsync().then((res) => { localStorage.removeItem(EDUCATION_VERIFYING_LOCALSTORAGE_ITEM) router.push(`/education-apply?token=${res.token}`) setShowAccountSettingModal(null) }).catch(() => { setShowModal(true) }) } return (
{plan.type === Plan.sandbox && ( )} {plan.type === Plan.professional && ( )} {plan.type === Plan.team && ( )} {(plan.type as any) === SelfHostedPlan.enterprise && ( )}
{t(`billing.plans.${type}.name`)}
{t('billing.currentPlan')}
{t(`billing.plans.${type}.for`)}
{enableEducationPlan && !isEducationAccount && ( )} {(plan.type as any) !== SelfHostedPlan.enterprise && ( )}
{/* Plan detail */}
setShowModal(false)} onCancel={() => setShowModal(false)} />
) } export default React.memo(PlanComp)