diff --git a/src/api/reports.js b/src/api/reports.js index 073f84ad..27936859 100644 --- a/src/api/reports.js +++ b/src/api/reports.js @@ -24,4 +24,13 @@ export async function fetchReports(filter, page, pageSize, authHost, token) { }) } +export async function fetchGroupedReports(authHost, token) { + return await request({ + baseURL: baseName(authHost), + url: `/api/pleroma/admin/grouped_reports`, + method: 'get', + headers: authHeaders(token) + }) +} + const authHeaders = (token) => token ? { 'Authorization': `Bearer ${getToken()}` } : {} diff --git a/src/store/modules/reports.js b/src/store/modules/reports.js index 8e3d2c4f..43443e97 100644 --- a/src/store/modules/reports.js +++ b/src/store/modules/reports.js @@ -1,8 +1,9 @@ -import { changeState, fetchReports } from '@/api/reports' +import { changeState, fetchReports, fetchGroupedReports } from '@/api/reports' const reports = { state: { fetchedReports: [], + fetchedGroupedReports: [], totalReportsCount: 0, currentPage: 1, pageSize: 50, @@ -23,6 +24,9 @@ const reports = { SET_REPORTS: (state, reports) => { state.fetchedReports = reports }, + SET_GROUPED_REPORTS: (state, reports) => { + state.fetchedGroupedReports = reports + }, SET_REPORTS_COUNT: (state, total) => { state.totalReportsCount = total }, @@ -51,6 +55,14 @@ const reports = { commit('SET_PAGE', page) commit('SET_LOADING', false) }, + async FetchGroupedReports({ commit, getters }) { + commit('SET_LOADING', true) + const { data } = await fetchGroupedReports(getters.authHost, getters.token) + console.log(reports) + + commit('SET_GROUPED_REPORTS', data.reports) + commit('SET_LOADING', false) + }, SetFilter({ commit }, filter) { commit('SET_REPORTS_FILTER', filter) }, diff --git a/src/views/reports/components/GroupedReport.vue b/src/views/reports/components/GroupedReport.vue index dcad3ad9..941d57da 100644 --- a/src/views/reports/components/GroupedReport.vue +++ b/src/views/reports/components/GroupedReport.vue @@ -70,6 +70,9 @@ export default { required: true } }, + mounted() { + this.$store.dispatch('FetchGroupedReports', 1) + }, methods: { changeAllReports(reportState, groupOfReports) { console.log(groupOfReports)