Bläddra i källkod

cursadas list fetch error

David 9 år sedan
förälder
incheckning
d5eed395aa

+ 43 - 43
src/actions/CursadaActions.js

@@ -13,40 +13,40 @@ 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
-				})
+		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
-        });
-      });
+	  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
+		});
+	  });
 	};
 };
 
@@ -54,22 +54,22 @@ 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({
+	  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
-        });
-      });
+		id: _id
+	  })
+	})
+	.then( (response) => response.json() )
+	  .then( (responseJson) => {
+		dispatch({
+		  type: CLASE_FETCH_SUCCESS,
+		  payload: responseJson
+		});
+	  });
 	};
 };

+ 13 - 0
src/components/common/ConnectionError.js

@@ -0,0 +1,13 @@
+import React from 'react';
+import { View, Text, ListView } from 'react-native';
+
+const ConnectionError = () => {
+	return (
+		<View style={{padding:15,justifyContent:'center',backgroundColor:'red'}}>
+			<Text style={{fontSize:25,color:'white',alignSelf:'center'}}>Error en la conexión</Text>
+			<Text style={{fontSize:15,color:'white',alignSelf:'center'}}>Hubo un problema conectandose al servidor. Por favor revise su conexión y vuelva a intentar.</Text>
+		</View>
+	);
+};
+
+export { ConnectionError };

+ 1 - 0
src/components/common/index.js

@@ -6,3 +6,4 @@ export * from './Header';
 export * from './Input';
 export * from './Spinner';
 export * from './Confirm';
+export * from './ConnectionError';

+ 2 - 9
src/scenes/ListaCursadas.js

@@ -1,11 +1,10 @@
-import _ from 'lodash';
 import React, { Component } from 'react';
 import { View, Text, ListView } from 'react-native';
 import { connect } from 'react-redux';
 import { cursadasFetch } from '../actions/';
 import ItemCursada from './Cursada/ItemCursada';
 import MyActionButton from '../components/ActionButton';
-
+import { ConnectionError } from '../components/common';
 
 class ListaCursadas extends Component  {
 
@@ -18,8 +17,6 @@ class ListaCursadas extends Component  {
 	}
 
 	createDataSource({cursadas,cursos}){
-    //const {cursadas, cursos} = cursada;
-
 		const ds = new ListView.DataSource({
 			rowHasChanged: (r1,r2) => r1 !== r2
 		});
@@ -32,11 +29,7 @@ class ListaCursadas extends Component  {
 
 	render() {
 		if (this.props.error) {
-			return (
-				<View>
-					<Text>Error obteniendo las cursadas</Text>
-				</View>
-			);
+			return <ConnectionError />;
 		}
 
 		return (