fix: NaN on stat card (#179)
* fix: NaN % change * ref: format Co-authored-by: Jonathan <axis@axis.moe> Co-authored-by: Jonathan <axis@axis.moe> Co-authored-by: dicedtomato <35403473+diced@users.noreply.github.com>
This commit is contained in:
parent
a095768eae
commit
4cb92a7257
2 changed files with 4 additions and 1 deletions
|
@ -62,7 +62,7 @@ export default function StatCard({ stat }: StatsGridProps) {
|
|||
weight={500}
|
||||
className={classes.diff}
|
||||
>
|
||||
<span>{stat.diff}%</span>
|
||||
<span>{stat.diff === Infinity ? '∞' : stat.diff}%</span>
|
||||
{
|
||||
stat.diff >= 0 ? (
|
||||
<ArrowUpRight size={16} />
|
||||
|
|
|
@ -85,5 +85,8 @@ export function parseExpiry(header: string): Date | null {
|
|||
}
|
||||
|
||||
export function percentChange(initial: number, final: number) {
|
||||
if (initial === 0 && final === 0) return 0;
|
||||
if (initial === 0) return Infinity;
|
||||
|
||||
return ((final - initial) / initial) * 100;
|
||||
}
|
Loading…
Add table
Reference in a new issue