Bladeren bron

soporte profesor

David 9 jaren geleden
bovenliggende
commit
86b64bdcc7

+ 2 - 0
src/Router.js

@@ -5,6 +5,7 @@ import LiveVideo from './components/LiveVideo';
 import ListaCursadas from './components/ListaCursadas';
 import Cursada from './components/Cursada';
 import Clase from './components/Clase';
+import Profesor from './components/Profesor';
 
 const RouterComponent = () => {
 	return (
@@ -17,6 +18,7 @@ const RouterComponent = () => {
 				<Scene key="ListaCursadas" component={ListaCursadas} title="Cursadas" />
 				<Scene key="ViewCursada" component={Cursada} title="Clases" />
 				<Scene key="ViewClase" component={Clase} title="Clase" />
+				<Scene key="ViewProf" component={Profesor} title="Profesor" />
 				<Scene key="Live" component={LiveVideo} />
 			</Scene>
 		</Router>

+ 24 - 0
src/actions/ProfActions.js

@@ -0,0 +1,24 @@
+import {
+  PROFESOR_FETCH_SUCCESS
+} from './types';
+
+export const profFetch = ({id}) => {
+  return (dispatch) => {
+    fetch('https://plataforma.especificosba.com.ar/back/getProfesor.php', {
+      method: 'POST',
+      headers: {
+          'Accept': 'application/json',
+          'Content-Type': 'application/json',
+      },
+      body: JSON.stringify({ id })
+    })
+    .then( (response) => response.json() )
+      .then( (responseJson) => {
+        console.log("prof response", responseJson);
+        dispatch({
+          type: PROFESOR_FETCH_SUCCESS,
+          payload: responseJson
+        });
+      });
+  };
+};

+ 1 - 0
src/actions/index.js

@@ -1,2 +1,3 @@
 export * from './AuthActions';
 export * from './CursadaActions';
+export * from './ProfActions';

+ 1 - 0
src/actions/types.js

@@ -6,3 +6,4 @@ 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";
+export const PROFESOR_FETCH_SUCCESS = "profesor_fetch_success";

+ 12 - 3
src/components/Cursada.js

@@ -1,6 +1,6 @@
 import _ from 'lodash';
 import React, { Component } from 'react';
-import { Text, ListView, View } from 'react-native';
+import { Text, ListView, View, TouchableOpacity } from 'react-native';
 import { connect } from 'react-redux';
 import { Actions } from 'react-native-router-flux';
 import { cursadaFetch } from '../actions/';
@@ -22,7 +22,12 @@ class Cursada extends Component  {
 	}
 
 	onClassPress(cursada,id) {
-		Actions.ViewClase({ cursada, _id:id});
+		Actions.ViewClase({ cursada, _id:id });
+	}
+
+	onProfPress(id){
+		console.log("profid", id);
+		Actions.ViewProf({ id });
 	}
 
 	renderButton(data) {
@@ -51,7 +56,11 @@ class Cursada extends Component  {
 
         <CardSection>
           <Text style={{flex:1}}>Profesor:</Text>
-          <Text style={{flex:1}}>{data.profesor.nombre} {data.profesor.apellido}</Text>
+					<TouchableOpacity onPress={() => this.onProfPress(data.profesor._id)}>
+          	<Text style={{flex:1, color: '#007aff', fontWeight: '600'}}>
+							{data.profesor.nombre} {data.profesor.apellido}
+						</Text>
+					</TouchableOpacity>
         </CardSection>
 
         <CardSection>

+ 52 - 0
src/components/Profesor.js

@@ -0,0 +1,52 @@
+import React, { Component } from 'react';
+import { Text, ScrollView, View, Image } from 'react-native';
+import { connect } from 'react-redux';
+import { profFetch } from '../actions/';
+import { Card, CardSection, Button } from './common';
+
+class Clase extends Component  {
+
+	componentWillMount() {
+    console.log("profProps", this.props);
+    this.props.profFetch({id:this.props.id});
+	}
+
+	render() {
+    console.log("ProfRender", this.props);
+		const { profesor } = this.props;
+		const image = `https://plataforma.especificosba.com.ar${profesor.imagen}`;
+		console.log(image);
+		return (
+			<ScrollView>
+	      <Card>
+					<CardSection>
+						<Text style={{textAlign:'center',fontSize:18,flex:1,fontWeight:'700'}}>
+							{profesor.nombre} {profesor.apellido}
+						</Text>
+					</CardSection>
+					<CardSection>
+						<Image source={{uri:image}}
+							style={{height:300,flex:1}}
+						/>
+					</CardSection>
+					<CardSection>
+						<Text>E-mail: {profesor.email}</Text>
+					</CardSection>
+					<CardSection>
+						<Text>Web: {profesor.web}</Text>
+					</CardSection>
+					<CardSection>
+						<Text>{profesor.intro}</Text>
+					</CardSection>
+	      </Card>
+			</ScrollView>
+		);
+	}
+};
+
+const mapStateToProps = state => {
+  console.log("ProfState:", state);
+	return { profesor: state.profR.profesor };
+};
+
+export default connect(mapStateToProps, { profFetch })(Clase);

+ 14 - 0
src/reducers/ProfReducer.js

@@ -0,0 +1,14 @@
+import {
+  PROFESOR_FETCH_SUCCESS
+} from '../actions/types';
+
+const INITIAL_STATE = { profesor: {} };
+
+export default (state = INITIAL_STATE, action) => {
+  switch(action.type) {
+    case PROFESOR_FETCH_SUCCESS:
+      return { ...state, profesor: action.payload };
+    default:
+      return state;
+  }
+};

+ 3 - 1
src/reducers/index.js

@@ -1,8 +1,10 @@
 import { combineReducers } from 'redux';
 import AuthReducer from './AuthReducer';
 import CursadaReducer from './CursadaReducer';
+import ProfReducer from './ProfReducer';
 
 export default combineReducers({
   auth: AuthReducer,
-  cursadasR: CursadaReducer
+  cursadasR: CursadaReducer,
+  profR: ProfReducer
 });