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.

47 lines
1.1 KiB

  1. import api from '../api';
  2. export const STATUS_CARD_FETCH_REQUEST = 'STATUS_CARD_FETCH_REQUEST';
  3. export const STATUS_CARD_FETCH_SUCCESS = 'STATUS_CARD_FETCH_SUCCESS';
  4. export const STATUS_CARD_FETCH_FAIL = 'STATUS_CARD_FETCH_FAIL';
  5. export function fetchStatusCard(id) {
  6. return (dispatch, getState) => {
  7. dispatch(fetchStatusCardRequest(id));
  8. api(getState).get(`/api/v1/statuses/${id}/card`).then(response => {
  9. if (!response.data.url || !response.data.title || !response.data.description) {
  10. return;
  11. }
  12. dispatch(fetchStatusCardSuccess(id, response.data));
  13. }).catch(error => {
  14. dispatch(fetchStatusCardFail(id, error));
  15. });
  16. };
  17. };
  18. export function fetchStatusCardRequest(id) {
  19. return {
  20. type: STATUS_CARD_FETCH_REQUEST,
  21. id,
  22. skipLoading: true
  23. };
  24. };
  25. export function fetchStatusCardSuccess(id, card) {
  26. return {
  27. type: STATUS_CARD_FETCH_SUCCESS,
  28. id,
  29. card,
  30. skipLoading: true
  31. };
  32. };
  33. export function fetchStatusCardFail(id, error) {
  34. return {
  35. type: STATUS_CARD_FETCH_FAIL,
  36. id,
  37. error,
  38. skipLoading: true
  39. };
  40. };