'use client' import type { FC } from 'react' import React from 'react' import { useTranslation } from 'react-i18next' import ProgressBar from '../progress-bar' import { NUM_INFINITE } from '../config' import Tooltip from '@/app/components/base/tooltip' type Props = { className?: string Icon: any name: string tooltip?: string usage: number total: number unit?: string } const LOW = 50 const MIDDLE = 80 const UsageInfo: FC = ({ className, Icon, name, tooltip, usage, total, unit = '', }) => { const { t } = useTranslation() const percent = usage / total * 100 const color = (() => { if (percent < LOW) return '#155EEF' if (percent < MIDDLE) return '#F79009' return '#F04438' })() return (
{name}
{tooltip && ( {tooltip}
} /> )}
{usage}{unit}
/
{total === NUM_INFINITE ? t('billing.plansCommon.unlimited') : `${total}${unit}`}
) } export default React.memo(UsageInfo)