2019-08-14 09:48:44 +00:00
|
|
|
/* eslint no-console: 0 */
|
|
|
|
import * as types from '../mutation-types';
|
|
|
|
import Report from '../../api/reports';
|
2022-05-17 15:31:45 +00:00
|
|
|
import { downloadCsvFile } from '../../helper/downloadHelper';
|
2021-10-06 18:23:51 +00:00
|
|
|
|
2019-08-14 09:48:44 +00:00
|
|
|
const state = {
|
|
|
|
fetchingStatus: false,
|
|
|
|
reportData: [],
|
|
|
|
accountReport: {
|
|
|
|
isFetching: false,
|
|
|
|
data: [],
|
|
|
|
},
|
|
|
|
accountSummary: {
|
|
|
|
avg_first_response_time: 0,
|
|
|
|
avg_resolution_time: 0,
|
|
|
|
conversations_count: 0,
|
|
|
|
incoming_messages_count: 0,
|
|
|
|
outgoing_messages_count: 0,
|
|
|
|
resolutions_count: 0,
|
2022-03-14 12:45:27 +00:00
|
|
|
previous: {},
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2022-04-25 14:34:41 +00:00
|
|
|
overview: {
|
|
|
|
uiFlags: {
|
|
|
|
isFetchingAccountConversationMetric: false,
|
|
|
|
isFetchingAgentConversationMetric: false,
|
|
|
|
},
|
|
|
|
accountConversationMetric: {},
|
|
|
|
agentConversationMetric: [],
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const getters = {
|
|
|
|
getAccountReports(_state) {
|
|
|
|
return _state.accountReport;
|
|
|
|
},
|
|
|
|
getAccountSummary(_state) {
|
|
|
|
return _state.accountSummary;
|
|
|
|
},
|
2022-04-25 14:34:41 +00:00
|
|
|
getAccountConversationMetric(_state) {
|
|
|
|
return _state.overview.accountConversationMetric;
|
|
|
|
},
|
|
|
|
getAgentConversationMetric(_state) {
|
|
|
|
return _state.overview.agentConversationMetric;
|
|
|
|
},
|
|
|
|
getOverviewUIFlags($state) {
|
|
|
|
return $state.overview.uiFlags;
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
};
|
|
|
|
|
2020-12-15 18:05:03 +00:00
|
|
|
export const actions = {
|
2019-08-14 09:48:44 +00:00
|
|
|
fetchAccountReport({ commit }, reportObj) {
|
|
|
|
commit(types.default.TOGGLE_ACCOUNT_REPORT_LOADING, true);
|
feat - Add filter for reports by agent, label and inboxes (#3084)
* Adds filter for agents, labels and inboxes
* Added Inboxes Reports Feature
* Fixed populating of filter dropdown issue
* If applied, fixes code climate style-lint warnings
* Fixes codeclimate warnings
* if applied, Refactors sidebar file to fix codclimate warnings
* if applied, fixes the download reports button for filtered report-data
* If applied, replaces native img tag with thumbnail component
* If applied, replaces hardcoded color string with variable
* If applied, adds a11y labels to multiselect dropdowns
* If applied, Renames reports methods to generic names
* If applied, Adds test cases for Labels and Inboxes
* If applied, write a test spec for fileDownload helper
* if applied, Moves fileDownload method to a utils folder
* If applied, Fixes the report file name type
* Test Spec for Reports Store module
* Fix specs - add restoreAllMocks
Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
2021-09-30 07:43:45 +00:00
|
|
|
Report.getReports(
|
2019-08-21 07:29:56 +00:00
|
|
|
reportObj.metric,
|
|
|
|
reportObj.from,
|
feat - Add filter for reports by agent, label and inboxes (#3084)
* Adds filter for agents, labels and inboxes
* Added Inboxes Reports Feature
* Fixed populating of filter dropdown issue
* If applied, fixes code climate style-lint warnings
* Fixes codeclimate warnings
* if applied, Refactors sidebar file to fix codclimate warnings
* if applied, fixes the download reports button for filtered report-data
* If applied, replaces native img tag with thumbnail component
* If applied, replaces hardcoded color string with variable
* If applied, adds a11y labels to multiselect dropdowns
* If applied, Renames reports methods to generic names
* If applied, Adds test cases for Labels and Inboxes
* If applied, write a test spec for fileDownload helper
* if applied, Moves fileDownload method to a utils folder
* If applied, Fixes the report file name type
* Test Spec for Reports Store module
* Fix specs - add restoreAllMocks
Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
2021-09-30 07:43:45 +00:00
|
|
|
reportObj.to,
|
|
|
|
reportObj.type,
|
2022-02-15 11:40:49 +00:00
|
|
|
reportObj.id,
|
2022-04-08 07:18:18 +00:00
|
|
|
reportObj.groupBy,
|
|
|
|
reportObj.businessHours
|
2019-08-21 07:29:56 +00:00
|
|
|
).then(accountReport => {
|
|
|
|
let { data } = accountReport;
|
2020-09-14 09:44:26 +00:00
|
|
|
data = data.filter(
|
2022-02-28 05:26:24 +00:00
|
|
|
el =>
|
|
|
|
reportObj.to - el.timestamp > 0 && el.timestamp - reportObj.from >= 0
|
2020-09-14 09:44:26 +00:00
|
|
|
);
|
2019-08-21 07:29:56 +00:00
|
|
|
commit(types.default.SET_ACCOUNT_REPORTS, data);
|
|
|
|
commit(types.default.TOGGLE_ACCOUNT_REPORT_LOADING, false);
|
|
|
|
});
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
fetchAccountSummary({ commit }, reportObj) {
|
feat - Add filter for reports by agent, label and inboxes (#3084)
* Adds filter for agents, labels and inboxes
* Added Inboxes Reports Feature
* Fixed populating of filter dropdown issue
* If applied, fixes code climate style-lint warnings
* Fixes codeclimate warnings
* if applied, Refactors sidebar file to fix codclimate warnings
* if applied, fixes the download reports button for filtered report-data
* If applied, replaces native img tag with thumbnail component
* If applied, replaces hardcoded color string with variable
* If applied, adds a11y labels to multiselect dropdowns
* If applied, Renames reports methods to generic names
* If applied, Adds test cases for Labels and Inboxes
* If applied, write a test spec for fileDownload helper
* if applied, Moves fileDownload method to a utils folder
* If applied, Fixes the report file name type
* Test Spec for Reports Store module
* Fix specs - add restoreAllMocks
Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
2021-09-30 07:43:45 +00:00
|
|
|
Report.getSummary(
|
|
|
|
reportObj.from,
|
|
|
|
reportObj.to,
|
|
|
|
reportObj.type,
|
2022-02-15 11:40:49 +00:00
|
|
|
reportObj.id,
|
2022-04-08 07:18:18 +00:00
|
|
|
reportObj.groupBy,
|
|
|
|
reportObj.businessHours
|
feat - Add filter for reports by agent, label and inboxes (#3084)
* Adds filter for agents, labels and inboxes
* Added Inboxes Reports Feature
* Fixed populating of filter dropdown issue
* If applied, fixes code climate style-lint warnings
* Fixes codeclimate warnings
* if applied, Refactors sidebar file to fix codclimate warnings
* if applied, fixes the download reports button for filtered report-data
* If applied, replaces native img tag with thumbnail component
* If applied, replaces hardcoded color string with variable
* If applied, adds a11y labels to multiselect dropdowns
* If applied, Renames reports methods to generic names
* If applied, Adds test cases for Labels and Inboxes
* If applied, write a test spec for fileDownload helper
* if applied, Moves fileDownload method to a utils folder
* If applied, Fixes the report file name type
* Test Spec for Reports Store module
* Fix specs - add restoreAllMocks
Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
2021-09-30 07:43:45 +00:00
|
|
|
)
|
2019-08-21 07:29:56 +00:00
|
|
|
.then(accountSummary => {
|
2019-08-14 09:48:44 +00:00
|
|
|
commit(types.default.SET_ACCOUNT_SUMMARY, accountSummary.data);
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
commit(types.default.TOGGLE_ACCOUNT_REPORT_LOADING, false);
|
|
|
|
});
|
|
|
|
},
|
2022-04-25 14:34:41 +00:00
|
|
|
fetchAccountConversationMetric({ commit }, reportObj) {
|
|
|
|
commit(types.default.TOGGLE_ACCOUNT_CONVERSATION_METRIC_LOADING, true);
|
|
|
|
Report.getConversationMetric(reportObj.type)
|
|
|
|
.then(accountConversationMetric => {
|
|
|
|
commit(
|
|
|
|
types.default.SET_ACCOUNT_CONVERSATION_METRIC,
|
|
|
|
accountConversationMetric.data
|
|
|
|
);
|
|
|
|
commit(types.default.TOGGLE_ACCOUNT_CONVERSATION_METRIC_LOADING, false);
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
commit(types.default.TOGGLE_ACCOUNT_CONVERSATION_METRIC_LOADING, false);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
fetchAgentConversationMetric({ commit }, reportObj) {
|
|
|
|
commit(types.default.TOGGLE_AGENT_CONVERSATION_METRIC_LOADING, true);
|
|
|
|
Report.getConversationMetric(reportObj.type, reportObj.page)
|
|
|
|
.then(agentConversationMetric => {
|
|
|
|
commit(
|
|
|
|
types.default.SET_AGENT_CONVERSATION_METRIC,
|
|
|
|
agentConversationMetric.data
|
|
|
|
);
|
|
|
|
commit(types.default.TOGGLE_AGENT_CONVERSATION_METRIC_LOADING, false);
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
commit(types.default.TOGGLE_AGENT_CONVERSATION_METRIC_LOADING, false);
|
|
|
|
});
|
|
|
|
},
|
2020-12-15 18:05:03 +00:00
|
|
|
downloadAgentReports(_, reportObj) {
|
2022-05-27 03:56:59 +00:00
|
|
|
return Report.getAgentReports(reportObj)
|
2020-12-15 18:05:03 +00:00
|
|
|
.then(response => {
|
2021-10-06 18:23:51 +00:00
|
|
|
downloadCsvFile(reportObj.fileName, response.data);
|
2020-12-15 18:05:03 +00:00
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
console.error(error);
|
|
|
|
});
|
|
|
|
},
|
feat - Add filter for reports by agent, label and inboxes (#3084)
* Adds filter for agents, labels and inboxes
* Added Inboxes Reports Feature
* Fixed populating of filter dropdown issue
* If applied, fixes code climate style-lint warnings
* Fixes codeclimate warnings
* if applied, Refactors sidebar file to fix codclimate warnings
* if applied, fixes the download reports button for filtered report-data
* If applied, replaces native img tag with thumbnail component
* If applied, replaces hardcoded color string with variable
* If applied, adds a11y labels to multiselect dropdowns
* If applied, Renames reports methods to generic names
* If applied, Adds test cases for Labels and Inboxes
* If applied, write a test spec for fileDownload helper
* if applied, Moves fileDownload method to a utils folder
* If applied, Fixes the report file name type
* Test Spec for Reports Store module
* Fix specs - add restoreAllMocks
Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
2021-09-30 07:43:45 +00:00
|
|
|
downloadLabelReports(_, reportObj) {
|
2022-05-27 03:56:59 +00:00
|
|
|
return Report.getLabelReports(reportObj)
|
feat - Add filter for reports by agent, label and inboxes (#3084)
* Adds filter for agents, labels and inboxes
* Added Inboxes Reports Feature
* Fixed populating of filter dropdown issue
* If applied, fixes code climate style-lint warnings
* Fixes codeclimate warnings
* if applied, Refactors sidebar file to fix codclimate warnings
* if applied, fixes the download reports button for filtered report-data
* If applied, replaces native img tag with thumbnail component
* If applied, replaces hardcoded color string with variable
* If applied, adds a11y labels to multiselect dropdowns
* If applied, Renames reports methods to generic names
* If applied, Adds test cases for Labels and Inboxes
* If applied, write a test spec for fileDownload helper
* if applied, Moves fileDownload method to a utils folder
* If applied, Fixes the report file name type
* Test Spec for Reports Store module
* Fix specs - add restoreAllMocks
Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
2021-09-30 07:43:45 +00:00
|
|
|
.then(response => {
|
2021-10-06 18:23:51 +00:00
|
|
|
downloadCsvFile(reportObj.fileName, response.data);
|
feat - Add filter for reports by agent, label and inboxes (#3084)
* Adds filter for agents, labels and inboxes
* Added Inboxes Reports Feature
* Fixed populating of filter dropdown issue
* If applied, fixes code climate style-lint warnings
* Fixes codeclimate warnings
* if applied, Refactors sidebar file to fix codclimate warnings
* if applied, fixes the download reports button for filtered report-data
* If applied, replaces native img tag with thumbnail component
* If applied, replaces hardcoded color string with variable
* If applied, adds a11y labels to multiselect dropdowns
* If applied, Renames reports methods to generic names
* If applied, Adds test cases for Labels and Inboxes
* If applied, write a test spec for fileDownload helper
* if applied, Moves fileDownload method to a utils folder
* If applied, Fixes the report file name type
* Test Spec for Reports Store module
* Fix specs - add restoreAllMocks
Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
2021-09-30 07:43:45 +00:00
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
console.error(error);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
downloadInboxReports(_, reportObj) {
|
2022-05-27 03:56:59 +00:00
|
|
|
return Report.getInboxReports(reportObj)
|
feat - Add filter for reports by agent, label and inboxes (#3084)
* Adds filter for agents, labels and inboxes
* Added Inboxes Reports Feature
* Fixed populating of filter dropdown issue
* If applied, fixes code climate style-lint warnings
* Fixes codeclimate warnings
* if applied, Refactors sidebar file to fix codclimate warnings
* if applied, fixes the download reports button for filtered report-data
* If applied, replaces native img tag with thumbnail component
* If applied, replaces hardcoded color string with variable
* If applied, adds a11y labels to multiselect dropdowns
* If applied, Renames reports methods to generic names
* If applied, Adds test cases for Labels and Inboxes
* If applied, write a test spec for fileDownload helper
* if applied, Moves fileDownload method to a utils folder
* If applied, Fixes the report file name type
* Test Spec for Reports Store module
* Fix specs - add restoreAllMocks
Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
2021-09-30 07:43:45 +00:00
|
|
|
.then(response => {
|
2021-10-06 18:23:51 +00:00
|
|
|
downloadCsvFile(reportObj.fileName, response.data);
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
console.error(error);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
downloadTeamReports(_, reportObj) {
|
2022-05-27 03:56:59 +00:00
|
|
|
return Report.getTeamReports(reportObj)
|
2021-10-06 18:23:51 +00:00
|
|
|
.then(response => {
|
|
|
|
downloadCsvFile(reportObj.fileName, response.data);
|
feat - Add filter for reports by agent, label and inboxes (#3084)
* Adds filter for agents, labels and inboxes
* Added Inboxes Reports Feature
* Fixed populating of filter dropdown issue
* If applied, fixes code climate style-lint warnings
* Fixes codeclimate warnings
* if applied, Refactors sidebar file to fix codclimate warnings
* if applied, fixes the download reports button for filtered report-data
* If applied, replaces native img tag with thumbnail component
* If applied, replaces hardcoded color string with variable
* If applied, adds a11y labels to multiselect dropdowns
* If applied, Renames reports methods to generic names
* If applied, Adds test cases for Labels and Inboxes
* If applied, write a test spec for fileDownload helper
* if applied, Moves fileDownload method to a utils folder
* If applied, Fixes the report file name type
* Test Spec for Reports Store module
* Fix specs - add restoreAllMocks
Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
2021-09-30 07:43:45 +00:00
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
console.error(error);
|
|
|
|
});
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const mutations = {
|
|
|
|
[types.default.SET_ACCOUNT_REPORTS](_state, accountReport) {
|
|
|
|
_state.accountReport.data = accountReport;
|
|
|
|
},
|
|
|
|
[types.default.TOGGLE_ACCOUNT_REPORT_LOADING](_state, flag) {
|
|
|
|
_state.accountReport.isFetching = flag;
|
|
|
|
},
|
|
|
|
[types.default.SET_ACCOUNT_SUMMARY](_state, summaryData) {
|
|
|
|
_state.accountSummary = summaryData;
|
|
|
|
},
|
2022-04-25 14:34:41 +00:00
|
|
|
[types.default.SET_ACCOUNT_CONVERSATION_METRIC](_state, metricData) {
|
|
|
|
_state.overview.accountConversationMetric = metricData;
|
|
|
|
},
|
|
|
|
[types.default.TOGGLE_ACCOUNT_CONVERSATION_METRIC_LOADING](_state, flag) {
|
|
|
|
_state.overview.uiFlags.isFetchingAccountConversationMetric = flag;
|
|
|
|
},
|
|
|
|
[types.default.SET_AGENT_CONVERSATION_METRIC](_state, metricData) {
|
|
|
|
_state.overview.agentConversationMetric = metricData;
|
|
|
|
},
|
|
|
|
[types.default.TOGGLE_AGENT_CONVERSATION_METRIC_LOADING](_state, flag) {
|
|
|
|
_state.overview.uiFlags.isFetchingAgentConversationMetric = flag;
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default {
|
|
|
|
state,
|
|
|
|
getters,
|
|
|
|
actions,
|
|
|
|
mutations,
|
|
|
|
};
|