2022-10-11 08:32:31 +00:00
|
|
|
import api from '../api';
|
2022-02-23 19:03:46 +00:00
|
|
|
import { openModal } from './modal';
|
2017-02-14 19:59:26 +00:00
|
|
|
|
|
|
|
export const REPORT_SUBMIT_REQUEST = 'REPORT_SUBMIT_REQUEST';
|
|
|
|
export const REPORT_SUBMIT_SUCCESS = 'REPORT_SUBMIT_SUCCESS';
|
|
|
|
export const REPORT_SUBMIT_FAIL = 'REPORT_SUBMIT_FAIL';
|
|
|
|
|
2022-02-23 19:03:46 +00:00
|
|
|
export const initReport = (account, status) => dispatch =>
|
|
|
|
dispatch(openModal('REPORT', {
|
|
|
|
accountId: account.get('id'),
|
2022-02-23 20:37:02 +00:00
|
|
|
statusId: status?.get('id'),
|
2022-02-23 19:03:46 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
export const submitReport = (params, onSuccess, onFail) => (dispatch, getState) => {
|
|
|
|
dispatch(submitReportRequest());
|
|
|
|
|
|
|
|
api(getState).post('/api/v1/reports', params).then(response => {
|
|
|
|
dispatch(submitReportSuccess(response.data));
|
|
|
|
if (onSuccess) onSuccess();
|
|
|
|
}).catch(error => {
|
|
|
|
dispatch(submitReportFail(error));
|
|
|
|
if (onFail) onFail();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
export const submitReportRequest = () => ({
|
|
|
|
type: REPORT_SUBMIT_REQUEST,
|
|
|
|
});
|
|
|
|
|
|
|
|
export const submitReportSuccess = report => ({
|
|
|
|
type: REPORT_SUBMIT_SUCCESS,
|
|
|
|
report,
|
|
|
|
});
|
|
|
|
|
|
|
|
export const submitReportFail = error => ({
|
|
|
|
type: REPORT_SUBMIT_FAIL,
|
|
|
|
error,
|
|
|
|
});
|