Create api function and module action for fetching single report

This commit is contained in:
Angelina Filippova 2020-10-21 21:27:58 +03:00
parent c64ccc863c
commit 6cdd2f42fe
2 changed files with 21 additions and 1 deletions

View file

@ -24,6 +24,15 @@ export async function fetchReports(filter, page, pageSize, authHost, token) {
})
}
export async function fetchSingleReport(id, authHost, token) {
return await request({
baseURL: baseName(authHost),
url: `/api/pleroma/admin/reports/${id}`,
method: 'get',
headers: authHeaders(token)
})
}
export async function createNote(content, reportID, authHost, token) {
return await request({
baseURL: baseName(authHost),

View file

@ -1,4 +1,4 @@
import { changeState, fetchReports, createNote, deleteNote } from '@/api/reports'
import { changeState, fetchReports, fetchSingleReport, createNote, deleteNote } from '@/api/reports'
import {
activateUsers,
deactivateUsers,
@ -14,6 +14,7 @@ const reports = {
loading: true,
openReportsCount: 0,
pageSize: 50,
singleReport: {},
stateFilter: '',
totalReportsCount: 0
},
@ -38,6 +39,9 @@ const reports = {
},
SET_REPORTS_FILTER: (state, filter) => {
state.stateFilter = filter
},
SET_SINGLE_REPORT: (state, report) => {
state.singleReport = report
}
},
actions: {
@ -120,6 +124,13 @@ const reports = {
commit('SET_PAGE', page)
commit('SET_LOADING', false)
},
async FetchSingleReport({ commit, getters }, id) {
commit('SET_LOADING', true)
const { data } = await fetchSingleReport(id, getters.authHost, getters.token)
commit('SET_SINGLE_REPORT', data)
commit('SET_LOADING', false)
},
async FetchOpenReportsCount({ commit, getters, state }) {
commit('SET_LOADING', true)
const { data } = await fetchReports('open', state.currentPage, state.pageSize, getters.authHost, getters.token)