Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 5311 | Rev 5314 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 5311 Rev 5313
Línea 38... Línea 38...
38
        dispatch(addNotification({ style: 'danger', message: errorMessage }))
38
        dispatch(addNotification({ style: 'danger', message: errorMessage }))
39
      })
39
      })
40
      .finally(() => dispatch(finishLoading()))
40
      .finally(() => dispatch(finishLoading()))
41
  }
41
  }
42
}
42
}
43
 
-
 
44
export const sendMessage = async (url, message) => {
-
 
45
  return (dispatch) => {
-
 
46
    dispatch(startLoading())
-
 
47
 
-
 
48
    const formData = new FormData()
-
 
49
    formData.append('message', emojione.toShort(message))
-
 
50
 
-
 
51
    axios.post(url, formData)
-
 
52
      .then(({ data: response }) => {
-
 
53
        if (!response.success) {
-
 
54
          dispatch(addNotification({ style: 'danger', message: 'Ha ocurrido un error' }))
-
 
55
          return
-
 
56
        }
-
 
57
 
-
 
58
        dispatch(setNewMessage(response.data))
-
 
59
      })
-
 
60
      .catch((err) => {
-
 
61
        const errorMessage = new Error(err).message
-
 
62
        dispatch(addNotification({ style: 'danger', message: errorMessage }))
-
 
63
      })
-
 
64
      .finally(() => dispatch(finishLoading()))
-
 
65
  }
-
 
66
}
-