Skip to content

Commit

Permalink
fga-eps-mds#164 - Composing items for scheduled visits and counselor…
Browse files Browse the repository at this point in the history
…s related to it

Co-authored-by: Ronyell <[email protected]>
Co-authored-by: ThalissonMelo <[email protected]>
  • Loading branch information
3 people committed Apr 22, 2018
1 parent 7b9428f commit d984a9c
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 11 deletions.
16 changes: 11 additions & 5 deletions src/components/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,21 @@ import styles from '../Styles/GeneralStyles';

class Button extends React.Component {
defineStyle() {
if (this.props.enabled) {
if(this.props.style === undefined){
this.props.style.text = styles.buttonText;
if (this.props.enabled) {
return (
styles.bigButton
);
}
return (
styles.bigButton
styles.disabledBigButton
);
}

return (
styles.disabledBigButton
this.props.style.design
);

}

render() {
Expand All @@ -26,7 +32,7 @@ class Button extends React.Component {
disabled={!this.props.enabled}
onPress={() => this.props.onPress()}
>
<Text style={styles.buttonText}>{this.props.text}</Text>
<Text style={this.props.style.text}>{this.props.text}</Text>
</TouchableOpacity>
</View>
);
Expand Down
83 changes: 83 additions & 0 deletions src/components/ScheduleCard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import React from 'react';
import { Text, View, TouchableOpacity, StyleSheet } from 'react-native';
import { Actions } from 'react-native-router-flux';
import PropTypes from 'prop-types';

const styles = StyleSheet.create({
listSchedule: {
flex: 1,
marginHorizontal: 15,
marginVertical: 10,
borderColor: 'black',
borderWidth: 1,
borderRadius: 3,
backgroundColor: '#FAFAFA',
justifyContent: 'space-between',
flexDirection: 'row',
alignItems: 'center',
},

textBox: {
flex: 4,
paddingLeft: 4,
justifyContent: 'flex-start',
marginRight: 15,
},

text: {
fontSize: 15,
paddingVertical: 2,
},
});

class ScheduleCard extends React.Component {
constructor(props) {
super(props);
this.state = {
data: {},
counselor: this.props.counselor,
};
}

render(){
return(
<View style={styles.listSchedule} key={this.props.keyProp}>
<View style={styles.textBox}>
{
this.props.data.map( (item) =>(
<Text style={styles.text}>
<Text style={{ fontWeight: 'bold' }}>{item.label} </Text>
{item.value}
</Text>
)
)}
</View>
{this.props.children}
</View>
);
}
}

ScheduleCard.propTypes = {
data: PropTypes.arrayOf(PropTypes.shape({
label: PropTypes.string.isRequired,
value: PropTypes.string.isRequired
})).isRequired,
keyProp: PropTypes.string.isRequired,
counselor: PropTypes.shape({
name: PropTypes.string.isRequired,
email: PropTypes.string.isRequired,
token: PropTypes.string.isRequired,
nuvemCode: PropTypes.number.isRequired,
profile: PropTypes.shape({
cpf: PropTypes.string.isRequired,
phone: PropTypes.string.isRequired,
isPresident: PropTypes.bool.isRequired,
segment: PropTypes.string.isRequired,
CAE: PropTypes.string.isRequired,
CAE_Type: PropTypes.string,
}).isRequired,
}).isRequired,
};

export default ScheduleCard;
4 changes: 2 additions & 2 deletions src/screens/startInspection/StartExpiredInspection.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class StartExpiredInspection extends React.Component {
<ScheduleCard
visitSchedule={visitSchedule}
counselor={this.props.counselor}
data={this.getData(visitSchedule)}
data={this.getVisitData(visitSchedule)}
keyProp={`EX${visitSchedule.codPostagem}`}
>
<View style={{ flex: 2 }}>
Expand All @@ -87,7 +87,7 @@ class StartExpiredInspection extends React.Component {
}
}

getData(visitSchedule) {
getVisitData(visitSchedule) {
let data = [
{
label: 'Escola:',
Expand Down
8 changes: 4 additions & 4 deletions src/screens/startInspection/StartPendingInspection.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ class StartPendingInspection extends React.Component {
}
}

getData(visitSchedule) {
getVisitData(visitSchedule) {
let data = [
{
label: 'Escola:',
Expand Down Expand Up @@ -310,7 +310,7 @@ class StartPendingInspection extends React.Component {
this.props.listOfPendingScheduleInAGroup.map(visitSchedule => (
<ScheduleCard
counselor={this.props.counselor}
data={this.getData(visitSchedule)}
data={this.getVisitData(visitSchedule)}
keyProp={`PE${visitSchedule.codPostagem}`}
>
<View style={{ flex: 3 }}>
Expand Down Expand Up @@ -351,7 +351,7 @@ class StartPendingInspection extends React.Component {
}
}

getDataCounselor(counselor){
getCounselorData(counselor){
let data = [
{
label: "Nome:",
Expand Down Expand Up @@ -383,7 +383,7 @@ class StartPendingInspection extends React.Component {
this.state.invitees.map(counselor => (
<ScheduleCard
counselor={this.props.counselor}
data={this.getDataCounselor(counselor)}
data={this.getCounselorData(counselor)}
keyProp={`${counselor.nuvemCode}`}
/>
))
Expand Down

0 comments on commit d984a9c

Please sign in to comment.