Skip to content
Snippets Groups Projects
Commit d2a452e3 authored by MariaZ's avatar MariaZ
Browse files

Add toast to saving/deleting symptom data

parent 4bff5a3d
No related branches found
No related tags found
No related merge requests found
import React, { Component } from 'react' import React, { Component } from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { Dimensions, ScrollView, StyleSheet, View } from 'react-native' import { Dimensions, ScrollView, StyleSheet, View } from 'react-native'
import { connect } from 'react-redux'
import AppModal from '../common/app-modal' import AppModal from '../common/app-modal'
import AppSwitch from '../common/app-switch' import AppSwitch from '../common/app-switch'
...@@ -13,9 +14,9 @@ import SelectBoxGroup from './select-box-group' ...@@ -13,9 +14,9 @@ import SelectBoxGroup from './select-box-group'
import SelectTabGroup from './select-tab-group' import SelectTabGroup from './select-tab-group'
import Temperature from './temperature' import Temperature from './temperature'
import { connect } from 'react-redux'
import { getDate } from '../../slices/date' import { getDate } from '../../slices/date'
import { blank, save, shouldShow, symtomPage } from '../helpers/cycle-day' import { blank, save, shouldShow, symtomPage } from '../helpers/cycle-day'
import { showToast } from '../helpers/general'
import { shared as sharedLabels } from '../../i18n/en/labels' import { shared as sharedLabels } from '../../i18n/en/labels'
import info from '../../i18n/en/symptom-info' import info from '../../i18n/en/symptom-info'
...@@ -84,11 +85,13 @@ class SymptomEditView extends Component { ...@@ -84,11 +85,13 @@ class SymptomEditView extends Component {
onRemove = () => { onRemove = () => {
this.saveData(true) this.saveData(true)
showToast(sharedLabels.dataDeleted)
this.props.onClose() this.props.onClose()
} }
onSave = () => { onSave = () => {
this.saveData() this.saveData()
showToast(sharedLabels.dataSaved)
this.props.onClose() this.props.onClose()
} }
...@@ -135,8 +138,15 @@ class SymptomEditView extends Component { ...@@ -135,8 +138,15 @@ class SymptomEditView extends Component {
save[symptom](data, date, shouldDeleteData) save[symptom](data, date, shouldDeleteData)
} }
closeView = () => {
const { onClose } = this.props
showToast(sharedLabels.dataSaved)
onClose()
}
render() { render() {
const { onClose, symptom } = this.props const { symptom } = this.props
const { data, const { data,
shouldShowExclude, shouldShowExclude,
shouldShowInfo, shouldShowInfo,
...@@ -148,13 +158,13 @@ class SymptomEditView extends Component { ...@@ -148,13 +158,13 @@ class SymptomEditView extends Component {
const noteText = symptom === 'note' ? data.value : data.note const noteText = symptom === 'note' ? data.value : data.note
return ( return (
<AppModal onClose={onClose}> <AppModal onClose={this.closeView}>
<ScrollView <ScrollView
contentContainerStyle={styles.modalContainer} contentContainerStyle={styles.modalContainer}
style={styles.modalWindow} style={styles.modalWindow}
> >
<View style={styles.headerContainer}> <View style={styles.headerContainer}>
<CloseIcon onClose={onClose} /> <CloseIcon onClose={this.closeView} />
</View> </View>
{symptom === 'temperature' && {symptom === 'temperature' &&
<Temperature <Temperature
......
...@@ -13,6 +13,8 @@ export const chart = { ...@@ -13,6 +13,8 @@ export const chart = {
export const shared = { export const shared = {
cancel: 'Cancel', cancel: 'Cancel',
save: 'Save', save: 'Save',
dataSaved: 'Symptom data was saved',
dataDeleted: 'Symptom data was deleted',
errorTitle: 'Error', errorTitle: 'Error',
successTitle: 'Success', successTitle: 'Success',
warning: 'Warning', warning: 'Warning',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment