import { Pie } from '@nivo/pie'; import { Box } from '@rocket.chat/fuselage'; import colors from '@rocket.chat/fuselage-tokens/colors'; import React, { useMemo, useCallback } from 'react'; const graphColors = (color) => ({ used: color || colors.b500, free: colors.n300 }); const UsageGraph = ({ used = 0, total = 0, label, color, size }) => { const parsedData = useMemo( () => [ { id: 'used', label: 'used', value: used, }, { id: 'free', label: 'free', value: total - used, }, ], [total, used], ); const getColor = useCallback((data) => graphColors(color)[data.id], [color]); const unlimited = total === 0; return ( {unlimited ? '∞' : `${Number((100 / total) * used).toFixed(2)}%`} {used} {' '} / {unlimited ? '∞' : total} {label} ); }; export default UsageGraph;