/** * Project iLinkWorld * File ValidateConsultationDetailScreen * Path screens/wallet/user * Created by BRICE ZELE * Date: 01/12/2021 */ import React, {useEffect, useState} from "react"; import {BaseStyle} from "../../../config/BaseStyle"; import {Alert, SafeAreaView, ScrollView, StyleSheet, View} from "react-native"; import I18n from 'react-native-i18n'; import {Color as BaseColor} from "../../../config/Color"; import Text from '../../../components/Text'; import {createStructuredSelector} from "reselect"; import { selectAcceptRefuseConsultation, selectActivatePaySubscription, selectGetConsultation, selectSubscriptionList } from "../../../redux/insurance/insurance.selector"; import {connect, useDispatch} from "react-redux"; import { fetchAcceptRejectConsultation, fetchAcceptRejectConsultationReset, fetchActivePaySubscription, fetchGetConsultation, fetchStopSubscriptionReset } from "../../../redux/insurance/insurance.actions"; import * as Utils from "../../../utils/UtilsFunction"; import {uppercaseFirstLetter} from "../../../utils/UtilsFunction"; import moment from "moment-timezone"; import CustomButton from "../../../components/CustomButton"; import {readUser} from "../../../webservice/AuthApi"; import DropdownAlert from "react-native-dropdownalert"; const ValidateConsultationDetailScreen = ({navigation, fetchAcceptRejectConsultation, acceptRefuseConsultation}) => { const dispatch = useDispatch(); const [consultation, setConsultation] = useState(navigation.getParam('item')); const [user, setUser] = useState(null); let dropDownAlertRef: any = null; useEffect(() => { readUser().then((user) => { setUser(user); }); dispatch(fetchAcceptRejectConsultationReset()); }, []); useEffect(() => { if (acceptRefuseConsultation.result !== null) { Alert.alert( I18n.t("SUCCESS"), acceptRefuseConsultation.result.response, [ { text: I18n.t("OK"), onPress: () => { dispatch(fetchAcceptRejectConsultationReset()); navigation.goBack(); } } ], {cancelable: false} ); } if (acceptRefuseConsultation.error) { Alert.alert( I18n.t("ERROR_LABLE"), Utils.getErrorMsg(acceptRefuseConsultation), [ { text: I18n.t("OK"), onPress: () => { dispatch(fetchAcceptRejectConsultationReset()); } } ], { cancelable: false } ); /* dropDownAlertRef.alertWithType( 'error', I18n.t('ERROR_LABEL'), Utils.getErrorMsg(acceptRefuseConsultation), ); dispatch(fetchAcceptRejectConsultationReset());*/ } }, [acceptRefuseConsultation]); console.log("Consultation", consultation); return ( (dropDownAlertRef = ref)}/> {I18n.t('PATIENT')} {`${consultation.patient_lastname} ${consultation.patient_firstname}`} {consultation.patient_situation.toLowerCase()} {I18n.t('PRATICIEN')} {`${consultation.practitioner_lastname} ${consultation.practitioner_firstname}`} {uppercaseFirstLetter(consultation.practitioner_provider_class.toLowerCase())} {I18n.t('STATE')} {uppercaseFirstLetter(consultation.state.toLowerCase())} Type {uppercaseFirstLetter(consultation.type.toLowerCase())} {I18n.t('CONDITION_PRISE_CHARGE')} {uppercaseFirstLetter(consultation.care_condition.toLowerCase())} {I18n.t('INSTITUTE_NAME')} {uppercaseFirstLetter(consultation.institution_name.toLowerCase())} Date {moment(consultation.created_at).format('YYYY-MM-DD')} {I18n.t('EXAMEN')} {consultation.exams.length} {I18n.t('MEDICAMENT')} {consultation.prescriptions.length} {I18n.t('PRESTATION')} {consultation.performances.length} { fetchAcceptRejectConsultation({ health_care_sheet_id: consultation.id, user_id: user.id, action: "ACCEPT" }); }}> {I18n.t("ACCEPT")} { fetchAcceptRejectConsultation({ health_care_sheet_id: consultation.id, user_id: user.id, action: "REJECT" }); }}> {I18n.t("REJECT")} ); } const mapStateToProps = createStructuredSelector({ subscriptionList: selectSubscriptionList, activatePaySubscription: selectActivatePaySubscription, getConsultation: selectGetConsultation, acceptRefuseConsultation: selectAcceptRefuseConsultation }); export default connect(mapStateToProps, { fetchActivePaySubscription, fetchGetConsultation, fetchAcceptRejectConsultation })( ValidateConsultationDetailScreen, ); const styles = StyleSheet.create({ contain: { padding: 20, width: "100%" }, classContent: { flexDirection: "row", justifyContent: "flex-end", marginBottom: 15 }, line: { width: "100%", height: 1, borderWidth: 0.5, borderColor: BaseColor.dividerColor, borderStyle: "dashed", marginVertical: 20 }, code: { width: "100%", padding: 20, alignItems: "center", justifyContent: "center" }, contentRow: {flexDirection: "row"}, centerView: { alignItems: "center", justifyContent: "center", marginHorizontal: 10 }, colCenter: {flex: 1, alignItems: "flex-start"} });