Failed Operate
The operate triggered when the "No" button is pressed:
////////////////
const Failed = () => {
const knowledge = {
habitId: routeData?._id,
responseType: 'FALSE',
};
actions
.UpdateHabit(knowledge)
.then(res => {
setResponseData(res);
routeData = res;
listHabit();
refsheet?.present?.shut();
setIsModalVisible(true);
setShowColor('RED');
})
.catch(error => {
console.log(error, 'Error in Failed operate');
});
};
////////////
main_off_btns View
The view containing the "No" button:
<View model={types.main_off_btns}>
<TouchableOpacity
onPress={Failed}
model={types.noButton}>
<Textual content model={types.Btn_text}>{'No'}</Textual content>
</TouchableOpacity>
<TouchableOpacity
onPress={() => Success()}
model={{...types.box_btn, backgroundColor: colours._B1DC00}}>
<Textual content model={{...types.Btn_text, shade: colours._020202}}>
Sure
</Textual content>
</TouchableOpacity>
</View>
isModalVisible State
The modal visibility state:
const [isModalVisible, setIsModalVisible] = useState(false);
/////////
Modal View
The modal view that's displayed:
<Modal
animationType="slide"
clear={true}
seen={isModalVisible}
onRequestClose={toggleModal}>
<View model={types.modalBackground}>
<View model={types.modalContent}>
{showColor == 'RED' ? (
<View>
<Textual content model={types.delet_red_text}>
{getFailureMessage(routeData?.tags, routeData?.ranges)}
</Textual content>
</View>
) : (
<Textual content model={types.delet_msg_text}>
Y tomorrow to proceed your journey.
</Textual content>
)}
<TouchableOpacity
model={types.OkButton}
onPress={redirectMatch}>
<Textual content model={{...commonStyles.fontBold15, shade: 'black'}}>
Shut
</Textual content>
</TouchableOpacity>
</View>
</View>
</Modal>