diff --git a/.eslintrc.json b/.eslintrc.json index 25fb3da..a4dc910 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -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 diff --git a/src/screens/startInspection/StartExpiredInspection.js b/src/screens/startInspection/StartExpiredInspection.js index a98f3d9..39f0a89 100644 --- a/src/screens/startInspection/StartExpiredInspection.js +++ b/src/screens/startInspection/StartExpiredInspection.js @@ -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: { @@ -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 ( @@ -94,7 +63,7 @@ class StartExpiredInspection extends React.Component { this.props.listOfExpiredScheduleInAGroup.map(visitSchedule => ( diff --git a/src/screens/startInspection/StartPendingInspection.js b/src/screens/startInspection/StartPendingInspection.js index a3f34b6..07a08f5 100644 --- a/src/screens/startInspection/StartPendingInspection.js +++ b/src/screens/startInspection/StartPendingInspection.js @@ -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({ @@ -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 ( @@ -276,7 +217,7 @@ class StartPendingInspection extends React.Component { return ( this.props.listOfPendingScheduleInAGroup.map(visitSchedule => ( @@ -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 ( @@ -377,7 +311,7 @@ class StartPendingInspection extends React.Component { return ( this.state.invitees.map(counselor => ( )) diff --git a/src/services/extractData.js b/src/services/extractData.js new file mode 100644 index 0000000..8a24dbd --- /dev/null +++ b/src/services/extractData.js @@ -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; +};