闭社主体 forked from https://github.com/tootsuite/mastodon
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.

72 lines
1.6 KiB

  1. import api from '../api';
  2. export const REPORT_INIT = 'REPORT_INIT';
  3. export const REPORT_CANCEL = 'REPORT_CANCEL';
  4. export const REPORT_SUBMIT_REQUEST = 'REPORT_SUBMIT_REQUEST';
  5. export const REPORT_SUBMIT_SUCCESS = 'REPORT_SUBMIT_SUCCESS';
  6. export const REPORT_SUBMIT_FAIL = 'REPORT_SUBMIT_FAIL';
  7. export const REPORT_STATUS_TOGGLE = 'REPORT_STATUS_TOGGLE';
  8. export const REPORT_COMMENT_CHANGE = 'REPORT_COMMENT_CHANGE';
  9. export function initReport(account, status) {
  10. return {
  11. type: REPORT_INIT,
  12. account,
  13. status,
  14. };
  15. };
  16. export function cancelReport() {
  17. return {
  18. type: REPORT_CANCEL,
  19. };
  20. };
  21. export function toggleStatusReport(statusId, checked) {
  22. return {
  23. type: REPORT_STATUS_TOGGLE,
  24. statusId,
  25. checked,
  26. };
  27. };
  28. export function submitReport() {
  29. return (dispatch, getState) => {
  30. dispatch(submitReportRequest());
  31. api(getState).post('/api/v1/reports', {
  32. account_id: getState().getIn(['reports', 'new', 'account_id']),
  33. status_ids: getState().getIn(['reports', 'new', 'status_ids']),
  34. comment: getState().getIn(['reports', 'new', 'comment']),
  35. }).then(response => dispatch(submitReportSuccess(response.data))).catch(error => dispatch(submitReportFail(error)));
  36. };
  37. };
  38. export function submitReportRequest() {
  39. return {
  40. type: REPORT_SUBMIT_REQUEST,
  41. };
  42. };
  43. export function submitReportSuccess(report) {
  44. return {
  45. type: REPORT_SUBMIT_SUCCESS,
  46. report,
  47. };
  48. };
  49. export function submitReportFail(error) {
  50. return {
  51. type: REPORT_SUBMIT_FAIL,
  52. error,
  53. };
  54. };
  55. export function changeReportComment(comment) {
  56. return {
  57. type: REPORT_COMMENT_CHANGE,
  58. comment,
  59. };
  60. };