mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-12-05 11:19:03 +01:00
3e9298370d
Port 2c5ab8f647
to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
42 lines
1 KiB
JavaScript
42 lines
1 KiB
JavaScript
import api from '../api';
|
|
|
|
import { openModal } from './modal';
|
|
|
|
export const REPORT_SUBMIT_REQUEST = 'REPORT_SUBMIT_REQUEST';
|
|
export const REPORT_SUBMIT_SUCCESS = 'REPORT_SUBMIT_SUCCESS';
|
|
export const REPORT_SUBMIT_FAIL = 'REPORT_SUBMIT_FAIL';
|
|
|
|
export const initReport = (account, status) => dispatch =>
|
|
dispatch(openModal({
|
|
modalType: 'REPORT',
|
|
modalProps: {
|
|
accountId: account.get('id'),
|
|
statusId: status?.get('id'),
|
|
},
|
|
}));
|
|
|
|
export const submitReport = (params, onSuccess, onFail) => (dispatch) => {
|
|
dispatch(submitReportRequest());
|
|
|
|
api().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,
|
|
});
|