import { Actions } from 'react-native-router-flux'; import { post } from '../api/' import { CURSADA_FETCH_SUCCESS, CURSADAS_FETCH_SUCCESS, CURSADAS_FETCH_FAIL, CLASE_FETCH_SUCCESS, CLASE_FETCH } from './types'; export const cursadasFetch = () => { return (dispatch) => { //const path = 'listaCursos.php'; const path = 'qwrpoiewquewquoiewquoiewq.php'; post(path, { cursadas: 1 }) .then( (response) => { dispatch({ type: CURSADAS_FETCH_SUCCESS, payload: response }); }) .catch( (error) => { dispatch({ type: CURSADAS_FETCH_FAIL }) }); }; }; export const cursadaFetch = ({_id}) => { return (dispatch) => { fetch('https://plataforma.especificosba.com.ar/back/getCourse.php', { method: 'POST', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', }, body: JSON.stringify({ id: _id }) }) .then( (response) => response.json() ) .then( (responseJson) => { dispatch({ type: CURSADA_FETCH_SUCCESS, payload: responseJson }); }); }; }; export const claseFetch = ({cursada, _id}) => { return (dispatch) => { dispatch({type: CLASE_FETCH}); fetch('https://plataforma.especificosba.com.ar/back/getClase.php', { method: 'POST', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', }, body: JSON.stringify({ cursada, id: _id }) }) .then( (response) => response.json() ) .then( (responseJson) => { dispatch({ type: CLASE_FETCH_SUCCESS, payload: responseJson }); }); }; };