Fix labels and clean up code

This commit is contained in:
Liv
2023-11-20 11:50:46 +01:00
parent 503ce6e82d
commit 3b797b8500
5 changed files with 19 additions and 29 deletions
+2 -2
View File
@@ -63,11 +63,11 @@ const SymptomBox = ({
/>
<View style={styles.textContainer}>
<AppText style={symptomNameStyle}>{t(symptom)}</AppText>
{symptomDataToDisplay && (
{symptomDataToDisplay ? (
<AppText style={textStyle} numberOfLines={4}>
{symptomDataToDisplay}
</AppText>
)}
) : null}
</View>
</TouchableOpacity>
</>
+1 -1
View File
@@ -134,7 +134,7 @@ const SymptomEditView = ({ date, onClose, symptom, symptomData }) => {
<Segment key={group.key} style={styles.segmentBorder}>
<AppText style={styles.title}>{group.title}</AppText>
<SelectTabGroup
activeButton={data[group.key]} //this is supposed to be a number
activeButton={data[group.key]}
buttons={group.options}
onSelect={(value) => onSelectTab(group, value)}
/>
+10 -21
View File
@@ -27,13 +27,6 @@ const productLabels = labels.products.categories
const minutes = ChronoUnit.MINUTES
const getOptionsFromCategories = (categories) => {
return Object.keys(categories).map((key, _) => ({
label: categories[key],
value: key, // or index, depending on what you want to use as the value
}))
}
const isNumber = (value) => typeof value === 'number'
export const shouldShow = (value) => (value !== null ? true : false)
@@ -71,6 +64,7 @@ export const blank = {
softTampon: null,
none: null,
other: null,
note: null,
},
cervix: {
exclude: false,
@@ -151,7 +145,7 @@ export const symtomPage = {
{
key: 'products',
options: productLabels,
title: 'Product',
title: labels.products.explainer,
},
],
},
@@ -263,11 +257,6 @@ export const symtomPage = {
export const save = {
bleeding: (data, date, shouldDeleteData) => {
//const { exclude, value, products } = data
//const isDataEntered = isNumber(value)
//const valuesToSave =
// shouldDeleteData || !isDataEntered ? null : { value, exclude, products }
saveBoxSymptom(data, date, shouldDeleteData, 'bleeding')
},
cervix: (data, date, shouldDeleteData) => {
@@ -348,22 +337,23 @@ const saveBoxSymptom = (data, date, shouldDeleteData, symptom) => {
const label = {
bleeding: (bleeding) => {
bleeding = mapRealmObjToJsObj(bleeding)
console.log(bleeding)
const bleedingLabel = []
if (bleeding && Object.values({ ...bleeding }).some((val) => val)) {
Object.keys(bleeding).forEach((key) => {
if (key == 'value') {
console.log(bleedingLabel)
bleedingLabel.push(bleedingLabels[bleeding[key]])
if (bleeding[key] != null && key === 'value') {
bleedingLabel.push(
bleeding.exclude
? `(${bleedingLabels[bleeding[key]]})`
: bleedingLabels[bleeding[key]]
)
}
if (
bleeding[key] &&
key !== 'other' &&
key !== 'note' &&
key != 'value' &&
key != 'exclude'
key !== 'value' &&
key !== 'exclude'
) {
console.log(bleedingLabel)
bleedingLabel.push(bleedingLabels[key] || productLabels[key])
}
if (key === 'other' && bleeding.other) {
@@ -371,7 +361,6 @@ const label = {
if (bleeding.note) {
label = `${label} (${bleeding.note})`
}
console.log(bleedingLabel)
bleedingLabel.push(label)
}
})