/* * @Author: ZhaoYing * @Date: 2026-04-14 12:28:23 * @Last Modified by: ZhaoYing * @Last Modified time: 2026-04-16 17:34:02 */ import { useState, forwardRef, useImperativeHandle } from 'react'; import { Flex, Tooltip, Divider } from 'antd'; import { useTranslation } from 'react-i18next'; import clsx from 'clsx'; import RbModal from '@/components/RbModal'; import type { Subscription } from './index' import { billingUnits } from '@/views/Package/constant' import { useI18n } from '@/store/locale' import { UnitWrapper } from '@/views/Package' export interface SubscriptionDetailModalRef { handleOpen: (subscription: Subscription | null) => void; } const SubscriptionDetailModal = forwardRef((_props, ref) => { const { t } = useTranslation(); const [open, setOpen] = useState(false); const { language } = useI18n() const [detail, setDetail] = useState(null); const handleOpen = (subscription: Subscription | null) => { setOpen(true) setDetail(subscription); }; const handleCancel = () => { setOpen(false); }; useImperativeHandle(ref, () => ({ handleOpen, })); const getKeyWithLanguage = (key: string) => { return (language === 'en' ? `${key}_en` : key) as keyof Subscription['package_plan'] } return ( item).join(' - ')} open={open} onCancel={handleCancel} footer={null} > {/* Header */}

{String(detail?.package_plan?.[getKeyWithLanguage('name')] ?? '')}

{/* Subtitle */}

{String(detail?.package_plan?.[getKeyWithLanguage('core_value')] ?? '')}

{/* Price */}
{detail?.package_plan?.billing_cycle !== 'permanent_free' && <> ¥ {detail?.package_plan?.price} } {detail?.package_plan?.billing_cycle && ( {detail?.package_plan?.billing_cycle !== 'permanent_free' && ' /'} {t(`package.${detail?.package_plan?.billing_cycle}`)} )}
{/* Features */} {billingUnits.map(({ key, unit, icon }) => { const value = detail?.quota[key as keyof Subscription['quota']]; if (value === undefined || value === null) return null; return ( ) })} {detail?.package_plan?.tech_support && ( )} {detail?.package_plan?.sla_compliance && ( )}
); }); export default SubscriptionDetailModal;