CursadaActions.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import { Actions } from 'react-native-router-flux';
  2. import { post } from '../api/'
  3. import {
  4. CURSADA_FETCH_SUCCESS,
  5. CURSADAS_FETCH_SUCCESS,
  6. CURSADAS_FETCH_FAIL,
  7. CLASE_FETCH_SUCCESS,
  8. CLASE_FETCH
  9. } from './types';
  10. export const cursadasFetch = () => {
  11. return (dispatch) => {
  12. //const path = 'listaCursos.php';
  13. const path = 'qwrpoiewquewquoiewquoiewq.php';
  14. post(path, { cursadas: 1 })
  15. .then( (response) => {
  16. dispatch({
  17. type: CURSADAS_FETCH_SUCCESS,
  18. payload: response
  19. });
  20. })
  21. .catch( (error) => {
  22. dispatch({
  23. type: CURSADAS_FETCH_FAIL
  24. })
  25. });
  26. };
  27. };
  28. export const cursadaFetch = ({_id}) => {
  29. return (dispatch) => {
  30. fetch('https://plataforma.especificosba.com.ar/back/getCourse.php', {
  31. method: 'POST',
  32. headers: {
  33. 'Accept': 'application/json',
  34. 'Content-Type': 'application/json',
  35. },
  36. body: JSON.stringify({
  37. id: _id
  38. })
  39. })
  40. .then( (response) => response.json() )
  41. .then( (responseJson) => {
  42. dispatch({
  43. type: CURSADA_FETCH_SUCCESS,
  44. payload: responseJson
  45. });
  46. });
  47. };
  48. };
  49. export const claseFetch = ({cursada, _id}) => {
  50. return (dispatch) => {
  51. dispatch({type: CLASE_FETCH});
  52. fetch('https://plataforma.especificosba.com.ar/back/getClase.php', {
  53. method: 'POST',
  54. headers: {
  55. 'Accept': 'application/json',
  56. 'Content-Type': 'application/json',
  57. },
  58. body: JSON.stringify({
  59. cursada,
  60. id: _id
  61. })
  62. })
  63. .then( (response) => response.json() )
  64. .then( (responseJson) => {
  65. dispatch({
  66. type: CLASE_FETCH_SUCCESS,
  67. payload: responseJson
  68. });
  69. });
  70. };
  71. };