MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / useNumber

Function useNumber

apps/start/src/hooks/use-numer-formatter.ts:73–108  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

71 };
72
73export function useNumber() {
74 const locale = 'en-US';
75 const format = formatNumber(locale);
76 const short = shortNumber(locale);
77 const currency = formatCurrency(locale);
78
79 return {
80 currency,
81 format,
82 short,
83 shortWithUnit: (value: number | null | undefined, unit?: string | null) => {
84 if (isNil(value)) {
85 return 'N/A';
86 }
87 if (unit === 'min') {
88 return fancyMinutes(value);
89 }
90 return `${short(value)}${unit ? ` ${unit}` : ''}`;
91 },
92 formatWithUnit: (
93 value: number | null | undefined,
94 unit?: string | null,
95 ) => {
96 if (isNil(value)) {
97 return 'N/A';
98 }
99 if (unit === 'min') {
100 return fancyMinutes(value);
101 }
102 if (unit === '%') {
103 return `${format(round(value * 100, 1))}${unit ? ` ${unit}` : ''}`;
104 }
105 return `${format(value)}${unit ? ` ${unit}` : ''}`;
106 },
107 };
108}

Callers 15

TooltipFunction · 0.90
SummaryFunction · 0.90
ChartFunction · 0.90
chart.tsxFile · 0.90
ConversionTableFunction · 0.90
ChartFunction · 0.90
TooltipContentFunction · 0.90
MetricCardFunction · 0.90
useYAxisPropsFunction · 0.90
ReportTableFunction · 0.90
PreviousDiffIndicatorFunction · 0.90

Calls 6

roundFunction · 0.90
shortNumberFunction · 0.85
formatCurrencyFunction · 0.85
fancyMinutesFunction · 0.85
formatFunction · 0.85
formatNumberFunction · 0.70

Tested by

no test coverage detected