diff --git a/components/cycle-day/symptoms/action-button-footer.js b/components/cycle-day/symptoms/action-button-footer.js index dac39a6a82fa036b6a4645bcec941064c588551b..ea96f948a78e346e9ff16aee11c4edfb340aed77 100644 --- a/components/cycle-day/symptoms/action-button-footer.js +++ b/components/cycle-day/symptoms/action-button-footer.js @@ -3,13 +3,11 @@ import { View, TouchableOpacity, Text } from 'react-native' import Icon from 'react-native-vector-icons/MaterialCommunityIcons' -import { saveSymptom } from '../../../db' import styles, {iconStyles} from '../../../styles' export default class ActionButtonFooter extends Component { render() { const { - symptom, cycleDay, saveAction, saveDisabled, @@ -17,53 +15,33 @@ export default class ActionButtonFooter extends Component { autoShowDayView = true} = this.props const navigateToOverView = () => navigate('CycleDay', {cycleDay}) - const buttons = [ - { - title: 'Cancel', - action: () => navigateToOverView(), - icon: 'cancel' + const saveButton = { + title: 'Save', + action: () => { + saveAction() + if (autoShowDayView) navigateToOverView() }, - { - title: 'Delete', - action: () => { - saveSymptom(symptom, cycleDay) - navigateToOverView() - }, - disabledCondition: !cycleDay[symptom], - icon: 'delete-outline' - }, { - title: 'Save', - action: () => { - saveAction() - if (autoShowDayView) navigateToOverView() - }, - disabledCondition: saveDisabled, - icon: 'content-save-outline' - } - ] + disabledCondition: saveDisabled, + icon: 'content-save-outline' + } + const textStyle = saveButton.disabledCondition ? styles.menuTextInActive : styles.menuText + const iconStyle = saveButton.disabledCondition ? + Object.assign({}, iconStyles.menuIcon, iconStyles.menuIconInactive) : + iconStyles.menuIcon return ( <View style={styles.menu}> - {buttons.map(({ title, action, disabledCondition, icon }, i) => { - const textStyle = disabledCondition ? styles.menuTextInActive : styles.menuText - const iconStyle = disabledCondition ? - Object.assign({}, iconStyles.menuIcon, iconStyles.menuIconInactive) : - iconStyles.menuIcon - - return ( - <TouchableOpacity - onPress={action} - style={styles.menuItem} - disabled={disabledCondition} - key={i.toString()} - > - <Icon name={icon} {...iconStyle} /> - <Text style={textStyle}> - {title} - </Text> - </TouchableOpacity> - ) - })} + <TouchableOpacity + onPress={saveButton.action} + style={styles.menuItem} + disabled={saveButton.disabledCondition} + key={'save'} + > + <Icon name={saveButton.icon} {...iconStyle} /> + <Text style={textStyle}> + {saveButton.title} + </Text> + </TouchableOpacity> </View> ) } diff --git a/components/cycle-day/symptoms/bleeding.js b/components/cycle-day/symptoms/bleeding.js index 3c88ec5cc665eb1a4ea70e826d1511589b4374a8..6357c261c92619ffa0d0137b1758f69c7cc3a443 100644 --- a/components/cycle-day/symptoms/bleeding.js +++ b/components/cycle-day/symptoms/bleeding.js @@ -56,7 +56,6 @@ export default class Bleeding extends Component { </SymptomSection> </ScrollView> <ActionButtonFooter - symptom='bleeding' cycleDay={this.props.cycleDay} saveAction={() => { saveSymptom('bleeding', this.props.cycleDay, {