mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Updated default MRR currency from settings
closes https://github.com/TryGhost/Team/issues/550 The MRR chart relied on first currency from the list in case of data for multiple currencies, falling back to USD in case of no MRR data for the site. This can be misleading, specially when the active currency set in payment settings is different from one picked to show on MRR chart. The change updates dashboard to always pick the currency from Payment settings as default for showing chart data.
This commit is contained in:
parent
6213587ad9
commit
fde76becc4
1 changed files with 13 additions and 3 deletions
|
@ -71,10 +71,14 @@ export default class DashboardController extends Controller {
|
|||
this.mrrStatsLoading = true;
|
||||
this.membersStats.fetchMRR().then((stats) => {
|
||||
this.mrrStatsLoading = false;
|
||||
const statsData = stats.data;
|
||||
let currencyStats = statsData[0] || {
|
||||
const statsData = stats.data || [];
|
||||
const defaultCurrency = this.getDefaultCurrency() || 'usd';
|
||||
let currencyStats = statsData.find((stat) => {
|
||||
return stat.currency === defaultCurrency;
|
||||
});
|
||||
currencyStats = currencyStats || {
|
||||
data: [],
|
||||
currency: 'usd'
|
||||
currency: defaultCurrency
|
||||
};
|
||||
if (currencyStats) {
|
||||
const currencyStatsData = this.membersStats.fillDates(currencyStats.data) || {};
|
||||
|
@ -240,6 +244,12 @@ export default class DashboardController extends Controller {
|
|||
});
|
||||
}
|
||||
|
||||
getDefaultCurrency() {
|
||||
const plans = this.settings.get('stripePlans') || [];
|
||||
const monthly = plans.find(plan => plan.interval === 'month');
|
||||
return monthly && monthly.currency;
|
||||
}
|
||||
|
||||
@action
|
||||
dismissLaunchBanner() {
|
||||
this.feature.set('launchComplete', true);
|
||||
|
|
Loading…
Add table
Reference in a new issue