The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

65 lines
1.4 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 function initReport(account, status) {
  9. return {
  10. type: REPORT_INIT,
  11. account,
  12. status
  13. };
  14. };
  15. export function cancelReport() {
  16. return {
  17. type: REPORT_CANCEL
  18. };
  19. };
  20. export function toggleStatusReport(statusId, checked) {
  21. return {
  22. type: REPORT_STATUS_TOGGLE,
  23. statusId,
  24. checked,
  25. };
  26. };
  27. export function submitReport() {
  28. return (dispatch, getState) => {
  29. dispatch(submitReportRequest());
  30. api(getState).post('/api/v1/reports', {
  31. account_id: getState().getIn(['reports', 'new', 'account_id']),
  32. status_ids: getState().getIn(['reports', 'new', 'status_ids']),
  33. comment: getState().getIn(['reports', 'new', 'comment'])
  34. }).then(response => dispatch(submitReportSuccess(response.data))).catch(error => dispatch(submitReportFail(error)));
  35. };
  36. };
  37. export function submitReportRequest() {
  38. return {
  39. type: REPORT_SUBMIT_REQUEST
  40. };
  41. };
  42. export function submitReportSuccess(report) {
  43. return {
  44. type: REPORT_SUBMIT_SUCCESS,
  45. report
  46. };
  47. };
  48. export function submitReportFail(error) {
  49. return {
  50. type: REPORT_SUBMIT_FAIL,
  51. error
  52. };
  53. };