Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not show flagsPerUser when calculation results to NaN #6639

Merged
merged 11 commits into from
Mar 21, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ export const FlagStats: React.FC<IFlagStatsProps> = ({
</StyledRingContainer>

<ConditionallyRender
condition={flagsPerUser !== undefined && flagsPerUser !== ''}
condition={
flagsPerUser !== undefined &&
flagsPerUser !== '' &&
flagsPerUser !== 'NaN'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, are you saying that the value we store here the string "NaN"? Or is it the value NaN?

I would expect this comparison to be done using the Number.isNan function, but I don't know what the value we get from the API is in this case? If it is the string, then we should fix this on the API level, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value is coming from a calculation parsed to a string. So yes the value that gets here is 'NaN' and because of the other string comparisons here, I added it here for consistency

                        count={summary.total}
                        flagsPerUser={
                            showAllProjects
                                ? (summary.total / users.total).toFixed(2)
                                : ''
                        }
                    />```

}
show={
<StyledInsightsContainer>
<StyledTextContainer>
Expand All @@ -102,7 +106,7 @@ export const FlagStats: React.FC<IFlagStatsProps> = ({
</Typography>
</StyledTextContainer>
<StyledFlagCountPerUser>
{flagsPerUser}
{flagsPerUser ?? 'N/A'}
andreas-unleash marked this conversation as resolved.
Show resolved Hide resolved
</StyledFlagCountPerUser>
</StyledInsightsContainer>
}
Expand Down
Loading