2017-02-14 14:59:26 -05:00
|
|
|
import api from '../api';
|
2023-05-23 11:15:17 -04:00
|
|
|
|
2022-02-23 14:03:46 -05:00
|
|
|
import { openModal } from './modal';
|
2017-02-14 14:59:26 -05: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 14:03:46 -05:00
|
|
|
export const initReport = (account, status) => dispatch =>
|
2023-05-25 09:42:37 -04:00
|
|
|
dispatch(openModal({
|
|
|
|
modalType: 'REPORT',
|
|
|
|
modalProps: {
|
|
|
|
accountId: account.get('id'),
|
|
|
|
statusId: status?.get('id'),
|
|
|
|
},
|
2022-02-23 14:03:46 -05:00
|
|
|
}));
|
|
|
|
|
2024-05-22 10:45:18 -04:00
|
|
|
export const submitReport = (params, onSuccess, onFail) => (dispatch) => {
|
2022-02-23 14:03:46 -05:00
|
|
|
dispatch(submitReportRequest());
|
|
|
|
|
2024-05-22 10:45:18 -04:00
|
|
|
api().post('/api/v1/reports', params).then(response => {
|
2022-02-23 14:03:46 -05:00
|
|
|
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,
|
|
|
|
});
|