Skip to content

Commit

Permalink
fix(ValuePanelCard): badge can be undifined
Browse files Browse the repository at this point in the history
  • Loading branch information
Xenepix committed Jan 1, 2024
1 parent b8a3a1f commit 1741efe
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions desktop-app/renderer/components/custom/panel/valuePanelCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function formatCurrencyValue(value: number): string {
function ValuePanelCard({
title = '',
value = 0,
delta = 0,
delta,
description = '',
cardType = 'button',
tooltip = '',
Expand All @@ -40,24 +40,29 @@ function ValuePanelCard({
tooltip?: string
onClick?: () => void
}): JSX.Element {
const badge = (
<BadgeDelta
className="rounded-tremor-full"
deltaType={getDeltaType({ delta })}
isIncreasePositive={true}
size="xs"
>
{delta >= 0
? `+${(delta * 100).toFixed(delta % 1 == 0 ? 0 : 1)}`
: (delta * 100).toFixed(delta % 1 == 0 ? 0 : 1)}{' '}
%
</BadgeDelta>
)
const badge = () => {
if (typeof delta == undefined || delta == null) {
return <></>
}
return (
<BadgeDelta
className="rounded-tremor-full"
deltaType={getDeltaType({ delta })}
isIncreasePositive={true}
size="xs"
>
{delta >= 0
? `+${(delta * 100).toFixed(delta % 1 == 0 ? 0 : 1)}`
: (delta * 100).toFixed(delta % 1 == 0 ? 0 : 1)}{' '}
%
</BadgeDelta>
)
}
return (
<PanelCard
className="h-32 w-80 min-w-fit"
title={title}
badge={badge}
badge={badge()}
description={description}
cardType={cardType}
tooltip={tooltip}
Expand Down

0 comments on commit 1741efe

Please sign in to comment.