diff --git a/src/client/components/UsageCard.tsx b/src/client/components/UsageCard.tsx new file mode 100644 index 0000000..704b75e --- /dev/null +++ b/src/client/components/UsageCard.tsx @@ -0,0 +1,61 @@ +import React from 'react'; +import { Card, CardContent, CardHeader } from './ui/card'; +import { formatNumber } from '@/utils/common'; +import { LuAlertCircle } from 'react-icons/lu'; +import { Tooltip, TooltipContent, TooltipTrigger } from './ui/tooltip'; +import { useTranslation } from '@i18next-toolkit/react'; +import colors from 'tailwindcss/colors'; + +interface UsageCardProps { + title: string; + current: number; + limit?: number; +} +export const UsageCard: React.FC = React.memo((props) => { + const { title, current, limit } = props; + const { t } = useTranslation(); + + return ( + + {limit && ( +
+ )} + + {limit && current > limit && ( +
+ + + + + +
+ {t( + 'Exceeded the limit, please upgrade your plan or your workspace will be paused soon.' + )} +
+
+
+
+ )} + + {title} + + {limit && limit >= 0 ? ( +
+ {formatNumber(current)}{' '} + / {formatNumber(limit)} +
+ ) : ( +
+ {formatNumber(current)}{' '} + / +
+ )} +
+ + ); +}); +UsageCard.displayName = 'UsageCard';