'use client' import type { FC } from 'react' import React, { useState } from 'react' import { createPortal } from 'react-dom' import Header from './header' import PlanSwitcher from './plan-switcher' import Plans from './plans' import Footer from './footer' import { PlanRange } from './plan-switcher/plan-range-switcher' import { useKeyPress } from 'ahooks' import { useProviderContext } from '@/context/provider-context' import { useAppContext } from '@/context/app-context' import { useGetPricingPageLanguage } from '@/context/i18n' import { NoiseBottom, NoiseTop } from './assets' export enum CategoryEnum { CLOUD = 'cloud', SELF = 'self', } export type Category = CategoryEnum.CLOUD | CategoryEnum.SELF type PricingProps = { onCancel: () => void } const Pricing: FC = ({ onCancel, }) => { const { plan } = useProviderContext() const { isCurrentWorkspaceManager } = useAppContext() const [planRange, setPlanRange] = React.useState(PlanRange.monthly) const [currentCategory, setCurrentCategory] = useState(CategoryEnum.CLOUD) const canPay = isCurrentWorkspaceManager useKeyPress(['esc'], onCancel) const pricingPageLanguage = useGetPricingPageLanguage() const pricingPageURL = pricingPageLanguage ? `https://dify.ai/${pricingPageLanguage}/pricing#plans-and-features` : 'https://dify.ai/pricing#plans-and-features' return createPortal(
e.stopPropagation()} >
, document.body, ) } export default React.memo(Pricing)