Skip to content

Commit

Permalink
fga-eps-mds#164 - Standardization of generic functions related to ins…
Browse files Browse the repository at this point in the history
…pection
  • Loading branch information
Ronyell committed Apr 25, 2018
1 parent 3d89a25 commit 7ee2e5f
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 105 deletions.
3 changes: 1 addition & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"rules": {
"no-console": 0,
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
"linebreak-style": 0,
"class-methods-use-this": 0
"linebreak-style": 0
},
"env": {
"jest": true
Expand Down
37 changes: 3 additions & 34 deletions src/screens/startInspection/StartExpiredInspection.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import PropTypes from 'prop-types';
import stylesList from '../../Styles/ListStyles';
import ScheduleCard from '../../components/ScheduleCard';
import Button from '../../components/Button';
import { getVisitData } from '../../services/extractData';


const styles = StyleSheet.create({
principal: {
Expand Down Expand Up @@ -45,39 +47,6 @@ class StartExpiredInspection extends React.Component {
};
}

getVisitData(visitSchedule) {
const data = [
{
label: 'Escola:',
value: visitSchedule.content.schoolName,
},
{
label: 'Data:',
value: visitSchedule.content.date,
},
{
label: 'Horário:',
value: visitSchedule.content.time,
},
{
label: this.verifyAgentInvited(visitSchedule),
value: '',
},
{
label: 'Número de participantes:',
value: Object.keys(visitSchedule.content.visitListOfInvitees).length,
},
];
return data;
}

verifyAgentInvited(visitSchedule) {
if (visitSchedule.content.invitedAgent) {
return 'Um agente foi convidado';
}
return 'Agente não convidado';
}

arrayScheduleList() {
if (this.props.isLoading) {
return (
Expand All @@ -94,7 +63,7 @@ class StartExpiredInspection extends React.Component {
this.props.listOfExpiredScheduleInAGroup.map(visitSchedule => (
<ScheduleCard
visitSchedule={visitSchedule}
data={this.getVisitData(visitSchedule)}
data={getVisitData(visitSchedule)}
keyProp={`EX${visitSchedule.codPostagem}`}
>
<View style={{ flex: 2 }}>
Expand Down
72 changes: 3 additions & 69 deletions src/screens/startInspection/StartPendingInspection.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import PopupDialog, {
import stylesList from '../../Styles/ListStyles';
import ScheduleCard from '../../components/ScheduleCard';
import Button from '../../components/Button';
import { getVisitData, getCounselorData } from '../../services/extractData';


const styles = StyleSheet.create({
Expand Down Expand Up @@ -200,66 +201,6 @@ class StartPendingInspection extends React.Component {
this.props.counselor.profile.cpf);
}

getVisitData(visitSchedule) {
const data = [
{
label: 'Escola:',
value: visitSchedule.content.schoolName,
},
{
label: 'Data:',
value: visitSchedule.content.date,
},
{
label: 'Horário:',
value: visitSchedule.content.time,
},
{
label: this.verifyAgentInvited(visitSchedule),
value: '',
},
{
label: 'Número de participantes:',
value: Object.keys(visitSchedule.content.visitListOfInvitees).length,
},
];
return data;
}

getCounselorData(counselor) {
const data = [
{
label: 'Nome:',
value: counselor.name,
},
{
label: 'Email:',
value: counselor.email,
},
{
label: 'Telefone:',
value: counselor.profile.phone,
},
{
label: 'Status da Visita:',
value: this.verifyStatus(counselor.confirmed, 'Confirmado'),
},
{
label: 'Status da Fiscalização:',
value: this.verifyStatus(counselor.realizedVisit, 'Realizada'),
},
];

return data;
}

verifyStatus(isConfirmed, text) {
if (isConfirmed === true) {
return text;
}
return `Não , ${text}!`;
}

arrayScheduleList() {
if (this.props.isLoading) {
return (
Expand All @@ -276,7 +217,7 @@ class StartPendingInspection extends React.Component {
return (
this.props.listOfPendingScheduleInAGroup.map(visitSchedule => (
<ScheduleCard
data={this.getVisitData(visitSchedule)}
data={getVisitData(visitSchedule)}
keyProp={`PE${visitSchedule.codPostagem}`}
>
<View style={{ flex: 3 }}>
Expand All @@ -292,13 +233,6 @@ class StartPendingInspection extends React.Component {
);
}

verifyAgentInvited(visitSchedule) {
if (visitSchedule.content.invitedAgent) {
return 'Um agente foi convidado';
}
return 'Agente não convidado';
}

verification(visitListOfInvitees, visitSchedule) {
if (visitListOfInvitees[this.props.counselor.nuvemCode] === undefined) {
return (
Expand Down Expand Up @@ -377,7 +311,7 @@ class StartPendingInspection extends React.Component {
return (
this.state.invitees.map(counselor => (
<ScheduleCard
data={this.getCounselorData(counselor)}
data={getCounselorData(counselor)}
keyProp={`${counselor.nuvemCode}`}
/>
))
Expand Down
66 changes: 66 additions & 0 deletions src/services/extractData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
export const verifyAgentInvited = (visitSchedule) => {
if (visitSchedule.content.invitedAgent) {
return 'Um agente foi convidado';
}
return 'Agente não convidado';
};

export const verifyStatus = (isConfirmed, text) => {
if (isConfirmed === true) {
return text;
}
return `Não , ${text}!`;
};

export const getVisitData = (visitSchedule) => {
const data = [
{
label: 'Escola:',
value: visitSchedule.content.schoolName,
},
{
label: 'Data:',
value: visitSchedule.content.date,
},
{
label: 'Horário:',
value: visitSchedule.content.time,
},
{
label: verifyAgentInvited(visitSchedule),
value: '',
},
{
label: 'Número de participantes:',
value: Object.keys(visitSchedule.content.visitListOfInvitees).length,
},
];
return data;
};

export const getCounselorData = (counselor) => {
const data = [
{
label: 'Nome:',
value: counselor.name,
},
{
label: 'Email:',
value: counselor.email,
},
{
label: 'Telefone:',
value: counselor.profile.phone,
},
{
label: 'Status da Visita:',
value: verifyStatus(counselor.confirmed, 'Confirmado'),
},
{
label: 'Status da Fiscalização:',
value: verifyStatus(counselor.realizedVisit, 'Realizada'),
},
];

return data;
};

0 comments on commit 7ee2e5f

Please sign in to comment.