Attempting to fix the Paid Mix empty state for Tiers

refs: https://github.com/TryGhost/Team/issues/1531
This commit is contained in:
James Morris 2022-05-12 18:05:20 +01:00
parent f4df91aee7
commit d2f356e2a4

View File

@ -250,6 +250,9 @@ export default class PaidMix extends Component {
}
get areTiersAllZero() {
if (this.dashboardStats.paidMembersByTier === null || this.dashboardStats.paidMembersByTier.length === 0) {
return true;
}
const data = this.dashboardStats.paidMembersByTier.map(stat => stat.members);
let areAllTiersZero = true;
for (let i = 0; i < data.length; i++) {
@ -329,13 +332,19 @@ export default class PaidMix extends Component {
// tiers all have 0 data
if (this.areTiersAllZero) {
let equalPercentageData = Math.round(100 / data.length);
totalTiersAmount = 100;
if (data.length > 0) {
let equalPercentageData = Math.round(100 / data.length);
for (let i = 0; i < data.length; i++) {
data[i] = equalPercentageData;
}
}
else {
labels[0] = "Tier 1";
labels[1] = "Tier 2";
data[0] = 50;
data[1] = 50;
}
// tiers have good data
} else {
totalTiersAmount = 0;