Skip to content

Commit

Permalink
Fixes display of 0 value in config-view
Browse files Browse the repository at this point in the history
  • Loading branch information
FlxRobole committed Aug 5, 2024
1 parent 272b7ce commit 5fbbe9b
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ class AITranslatorConfig extends React.Component {
}

@computed get usagePercentage() {
console.log("computing", this.characterCount);

if (this.characterCount === 0) {
return 0;
}

if (this.characterCount && this.characterLimit) {
return parseInt((this.characterCount / this.characterLimit) * 100);
}
Expand All @@ -38,7 +44,7 @@ class AITranslatorConfig extends React.Component {
return Requester.get("/admin/api/translate/usage")
.then(
action((response) => {
if (response.character_count && response.character_limit) {
if (typeof response.character_count !== "undefined" && typeof response.character_limit !== "undefined") {
this.characterCount = response.character_count;
this.characterLimit = response.character_limit;
}
Expand Down Expand Up @@ -66,7 +72,7 @@ class AITranslatorConfig extends React.Component {
return (
<div>
<h1>{translate("app.translator_config_headline")}</h1>
{this.usagePercentage && (
{!isNaN(this.usagePercentage) && (
<CircularProgressbar percentage={this.usagePercentage} size={200} />
)}
<div style={{ marginTop: 20, marginBottom: 20 }}>
Expand Down

0 comments on commit 5fbbe9b

Please sign in to comment.