David %!s(int64=9) %!d(string=hai) anos
pai
achega
51b571773b

+ 2 - 0
src/Router.js

@@ -4,6 +4,7 @@ import LoginForm from './components/LoginForm';
 import LiveVideo from './components/LiveVideo';
 import ListaCursadas from './components/ListaCursadas';
 import Cursada from './components/Cursada';
+import Clase from './components/Clase';
 
 const RouterComponent = () => {
 	return (
@@ -15,6 +16,7 @@ const RouterComponent = () => {
 			<Scene key="main">
 				<Scene key="ListaCursadas" component={ListaCursadas} title="Cursadas" />
 				<Scene key="ViewCursada" component={Cursada} title="Clases" />
+				<Scene key="ViewClase" component={Clase} title="Clase" />
 				<Scene key="Live" component={LiveVideo} />
 			</Scene>
 		</Router>

+ 25 - 2
src/actions/CursadaActions.js

@@ -1,7 +1,8 @@
 import { Actions } from 'react-native-router-flux';
 import {
 	CURSADA_FETCH_SUCCESS,
-	CURSADAS_FETCH_SUCCESS
+	CURSADAS_FETCH_SUCCESS,
+	CLASE_FETCH_SUCCESS
 } from './types';
 
 export const cursadasFetch = () => {
@@ -28,7 +29,6 @@ export const cursadasFetch = () => {
 };
 
 export const cursadaFetch = ({_id}) => {
-	console.log("Fetching",_id);
 	return (dispatch) => {
 		fetch('https://plataforma.especificosba.com.ar/back/getCourse.php', {
       method: 'POST',
@@ -49,3 +49,26 @@ export const cursadaFetch = ({_id}) => {
       });
 	};
 };
+
+export const claseFetch = ({cursada, _id}) => {
+	return (dispatch) => {
+		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
+        });
+      });
+	};
+};

+ 1 - 0
src/actions/types.js

@@ -5,3 +5,4 @@ export const LOGIN_USER_FAIL = "login_user_fail";
 export const LOGIN_USER = "login_user";
 export const CURSADA_FETCH_SUCCESS = "cursada_fetch_success";
 export const CURSADAS_FETCH_SUCCESS = "cursadas_fetch_success";
+export const CLASE_FETCH_SUCCESS = "clase_fetch_success";

+ 43 - 0
src/components/Clase.js

@@ -0,0 +1,43 @@
+import _ from 'lodash';
+import React, { Component } from 'react';
+import { Text, WebView, View } from 'react-native';
+import { connect } from 'react-redux';
+import { Actions } from 'react-native-router-flux';
+import { claseFetch } from '../actions/';
+import { Card, CardSection, Button } from './common';
+
+class Clase extends Component  {
+
+	componentWillMount() {
+    this.props.claseFetch(this.props);
+	}
+
+	render() {
+    const { clase } = this.props;
+    console.log("props", this.props);
+		return (
+      <Card>
+        <CardSection>
+          <Text>{clase.titulo}</Text>
+        </CardSection>
+        <CardSection>
+          <Text>{clase.profesor.nombre} {clase.profesor.apellido}</Text>
+        </CardSection>
+        <CardSection>
+          <WebView
+            style={{height:300}}
+            scalesPageToFit={true}
+            source={{html: clase.texto}} />
+        </CardSection>
+      </Card>
+		);
+	}
+};
+
+const mapStateToProps = state => {
+  const { curClase } = state.cursadasR;
+  console.log("State:", state);
+	return { clase: curClase };
+};
+
+export default connect(mapStateToProps, { claseFetch })(Clase);

+ 9 - 1
src/components/Cursada.js

@@ -2,6 +2,7 @@ import _ from 'lodash';
 import React, { Component } from 'react';
 import { Text, ListView, View } from 'react-native';
 import { connect } from 'react-redux';
+import { Actions } from 'react-native-router-flux';
 import { cursadaFetch } from '../actions/';
 import { Card, CardSection, Button } from './common';
 
@@ -21,13 +22,20 @@ class Cursada extends Component  {
     this.dataSource = ds.cloneWithRows(clases);
 	}
 
+	onClassPress(cursada,id) {
+		Actions.ViewClase({ cursada, _id:id});
+	}
+
 	renderButton(data) {
 		if (data.desactivada){
 			return <View />;
 		}
 		return (
 			<CardSection>
-				<Button>Ingresar</Button>
+				<Button
+					onPress={ () => this.onClassPress(this.props._id, data._id)}>
+					Ingresar
+				</Button>
 			</CardSection>
 		);
 	}

+ 6 - 2
src/reducers/CursadaReducer.js

@@ -1,12 +1,14 @@
 import {
   CURSADAS_FETCH_SUCCESS,
-  CURSADA_FETCH_SUCCESS
+  CURSADA_FETCH_SUCCESS,
+  CLASE_FETCH_SUCCESS
 } from '../actions/types';
 
 const INITIAL_STATE = {
   cursos: [],
   cursadas: [],
-  curCursada: { clases: [] }
+  curCursada: { clases: [] },
+  curClase: {}
 };
 
 export default (state = INITIAL_STATE, action) => {
@@ -16,6 +18,8 @@ export default (state = INITIAL_STATE, action) => {
       return { ...state, cursadas, cursos };
     case CURSADA_FETCH_SUCCESS:
       return { ...state, curCursada: action.payload };
+    case CLASE_FETCH_SUCCESS:
+      return { ...state, curClase: action.payload };
     default:
       return state;
   }