|
|
@@ -0,0 +1,54 @@
|
|
|
+import _ from 'lodash';
|
|
|
+import React, { Component } from 'react';
|
|
|
+import { Text, ListView, View } from 'react-native';
|
|
|
+import { connect } from 'react-redux';
|
|
|
+import { cursadaFetch } from '../actions/';
|
|
|
+import { Card, CardSection } from './common';
|
|
|
+
|
|
|
+class Cursada extends Component {
|
|
|
+
|
|
|
+ componentWillMount() {
|
|
|
+ this.props.cursadaFetch(this.props);
|
|
|
+ this.createDataSource(this.props);
|
|
|
+ }
|
|
|
+ componentWillReceiveProps(nextProps) {
|
|
|
+ this.createDataSource(nextProps);
|
|
|
+ }
|
|
|
+ createDataSource({cursada}){
|
|
|
+ const { clases } = cursada;
|
|
|
+ const ds = new ListView.DataSource({
|
|
|
+ rowHasChanged: (r1,r2) => r1 !== r2
|
|
|
+ });
|
|
|
+ this.dataSource = ds.cloneWithRows(clases);
|
|
|
+ }
|
|
|
+
|
|
|
+ renderRow(data) {
|
|
|
+ return (
|
|
|
+ <CardSection>
|
|
|
+ <Text>{data.titulo}</Text>
|
|
|
+ </CardSection>
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ render() {
|
|
|
+ const { cursada } = this.props;
|
|
|
+ return (
|
|
|
+ <View>
|
|
|
+ <CardSection>
|
|
|
+ <Text style={{fontSize:18}}>{cursada.titulo}</Text>
|
|
|
+ </CardSection>
|
|
|
+ <ListView
|
|
|
+ enableEmptySections
|
|
|
+ dataSource={this.dataSource}
|
|
|
+ renderRow={this.renderRow}
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+ );
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+const mapStateToProps = state => {
|
|
|
+ return { cursada: state.cursadasR.curCursada };
|
|
|
+};
|
|
|
+
|
|
|
+export default connect(mapStateToProps, { cursadaFetch })(Cursada);
|