fix: stale report value shown if summary fetch breaks (#11270)
This pull request includes several changes to better show the report metrics fetching status on the dashboard. This also prevents showing stale data in case fetching summary fails due to timeout or other issue The most important changes include adding a new fetching status state to the store called `summaryFetchingStatus`, updating the `useReportMetrics` composable, and modifying the `ChartStats` component to handle different fetching statuses. #### Loading  #### Finished  #### Failed <img width="1512" alt="image" src="https://github.com/user-attachments/assets/d521a785-9299-4e59-94dc-561a7a84377e" /> --------- Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
@@ -7,8 +7,12 @@ import { formatTime } from '@chatwoot/utils';
|
||||
* @param {string} [accountSummaryKey='getAccountSummary'] - The key for accessing account summary data.
|
||||
* @returns {Object} An object containing utility functions for report metrics.
|
||||
*/
|
||||
export function useReportMetrics(accountSummaryKey = 'getAccountSummary') {
|
||||
export function useReportMetrics(
|
||||
accountSummaryKey = 'getAccountSummary',
|
||||
summarFetchingKey = 'getAccountSummaryFetchingStatus'
|
||||
) {
|
||||
const accountSummary = useMapGetter(accountSummaryKey);
|
||||
const fetchingStatus = useMapGetter(summarFetchingKey);
|
||||
|
||||
/**
|
||||
* Calculates the trend percentage for a given metric.
|
||||
@@ -53,5 +57,6 @@ export function useReportMetrics(accountSummaryKey = 'getAccountSummary') {
|
||||
calculateTrend,
|
||||
isAverageMetricType,
|
||||
displayMetric,
|
||||
fetchingStatus,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user