You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
1.8 KiB
81 lines
1.8 KiB
7 years ago
|
import api from 'flavours/glitch/util/api';
|
||
8 years ago
|
import { openModal, closeModal } from './modal';
|
||
8 years ago
|
|
||
|
export const REPORT_INIT = 'REPORT_INIT';
|
||
|
export const REPORT_CANCEL = 'REPORT_CANCEL';
|
||
|
|
||
|
export const REPORT_SUBMIT_REQUEST = 'REPORT_SUBMIT_REQUEST';
|
||
|
export const REPORT_SUBMIT_SUCCESS = 'REPORT_SUBMIT_SUCCESS';
|
||
|
export const REPORT_SUBMIT_FAIL = 'REPORT_SUBMIT_FAIL';
|
||
|
|
||
8 years ago
|
export const REPORT_STATUS_TOGGLE = 'REPORT_STATUS_TOGGLE';
|
||
|
export const REPORT_COMMENT_CHANGE = 'REPORT_COMMENT_CHANGE';
|
||
8 years ago
|
|
||
|
export function initReport(account, status) {
|
||
8 years ago
|
return dispatch => {
|
||
|
dispatch({
|
||
|
type: REPORT_INIT,
|
||
|
account,
|
||
|
status,
|
||
|
});
|
||
|
|
||
|
dispatch(openModal('REPORT'));
|
||
8 years ago
|
};
|
||
|
};
|
||
|
|
||
|
export function cancelReport() {
|
||
|
return {
|
||
8 years ago
|
type: REPORT_CANCEL,
|
||
8 years ago
|
};
|
||
|
};
|
||
|
|
||
|
export function toggleStatusReport(statusId, checked) {
|
||
|
return {
|
||
|
type: REPORT_STATUS_TOGGLE,
|
||
|
statusId,
|
||
|
checked,
|
||
|
};
|
||
|
};
|
||
|
|
||
|
export function submitReport() {
|
||
|
return (dispatch, getState) => {
|
||
|
dispatch(submitReportRequest());
|
||
|
|
||
|
api(getState).post('/api/v1/reports', {
|
||
|
account_id: getState().getIn(['reports', 'new', 'account_id']),
|
||
|
status_ids: getState().getIn(['reports', 'new', 'status_ids']),
|
||
8 years ago
|
comment: getState().getIn(['reports', 'new', 'comment']),
|
||
8 years ago
|
}).then(response => {
|
||
|
dispatch(closeModal());
|
||
|
dispatch(submitReportSuccess(response.data));
|
||
|
}).catch(error => dispatch(submitReportFail(error)));
|
||
8 years ago
|
};
|
||
|
};
|
||
|
|
||
|
export function submitReportRequest() {
|
||
|
return {
|
||
8 years ago
|
type: REPORT_SUBMIT_REQUEST,
|
||
8 years ago
|
};
|
||
|
};
|
||
|
|
||
|
export function submitReportSuccess(report) {
|
||
|
return {
|
||
|
type: REPORT_SUBMIT_SUCCESS,
|
||
8 years ago
|
report,
|
||
8 years ago
|
};
|
||
|
};
|
||
|
|
||
|
export function submitReportFail(error) {
|
||
|
return {
|
||
|
type: REPORT_SUBMIT_FAIL,
|
||
8 years ago
|
error,
|
||
8 years ago
|
};
|
||
|
};
|
||
8 years ago
|
|
||
|
export function changeReportComment(comment) {
|
||
|
return {
|
||
|
type: REPORT_COMMENT_CHANGE,
|
||
8 years ago
|
comment,
|
||
8 years ago
|
};
|
||
|
};
|