diff --git a/components/cycle-day/symptom-box.js b/components/cycle-day/symptom-box.js
index 1d78f02..bc14457 100644
--- a/components/cycle-day/symptom-box.js
+++ b/components/cycle-day/symptom-box.js
@@ -63,11 +63,11 @@ const SymptomBox = ({
/>
{t(symptom)}
- {symptomDataToDisplay && (
+ {symptomDataToDisplay ? (
{symptomDataToDisplay}
- )}
+ ) : null}
>
diff --git a/components/cycle-day/symptom-edit-view.js b/components/cycle-day/symptom-edit-view.js
index 6bb5a6f..b87ae58 100644
--- a/components/cycle-day/symptom-edit-view.js
+++ b/components/cycle-day/symptom-edit-view.js
@@ -136,7 +136,7 @@ const SymptomEditView = ({ date, onClose, symptom, symptomData }) => {
{group.title}
onSelectTab(group, value)}
/>
diff --git a/components/helpers/cycle-day.js b/components/helpers/cycle-day.js
index 571b47f..fb3c261 100644
--- a/components/helpers/cycle-day.js
+++ b/components/helpers/cycle-day.js
@@ -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)
@@ -75,6 +68,7 @@ export const blank = {
softTampon: null,
none: null,
other: null,
+ note: null,
},
cervix: {
exclude: false,
@@ -155,7 +149,7 @@ export const symtomPage = {
{
key: 'products',
options: productLabels,
- title: 'Product',
+ title: labels.products.explainer,
},
],
},
@@ -267,11 +261,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) => {
@@ -352,22 +341,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) {
@@ -375,7 +365,6 @@ const label = {
if (bleeding.note) {
label = `${label} (${bleeding.note})`
}
- console.log(bleedingLabel)
bleedingLabel.push(label)
}
})
diff --git a/db/index.js b/db/index.js
index f6f2fd0..5c838dc 100644
--- a/db/index.js
+++ b/db/index.js
@@ -65,6 +65,7 @@ export function getBleedingDaysSortedByDate() {
return db
.objects('CycleDay')
.filtered('bleeding != null')
+ .filtered('bleeding.value != null')
.sorted('date', true)
}
export function getTemperatureDaysSortedByDate() {
@@ -88,9 +89,8 @@ export function getCycleStartsSortedByDate() {
export function saveSymptom(symptom, date, val) {
let cycleDay = getCycleDay(date)
if (!cycleDay) cycleDay = createCycleDay(date)
-
db.write(() => {
- if (symptom === 'bleeding') {
+ if (symptom === 'bleeding' && val != null && val.value != null) {
const mensesDaysAfter = getMensesDaysRightAfter(cycleDay)
maybeSetNewCycleStart({
val,
diff --git a/db/schemas/5.js b/db/schemas/5.js
index 6d548b8..b645a52 100644
--- a/db/schemas/5.js
+++ b/db/schemas/5.js
@@ -17,7 +17,7 @@ const TemperatureSchema = {
const BleedingSchema = {
name: 'Bleeding',
properties: {
- value: 'int',
+ value: { type: 'int', optional: true },
exclude: 'bool',
pad: { type: 'bool', optional: true },
tampon: { type: 'bool', optional: true },
@@ -26,6 +26,7 @@ const BleedingSchema = {
softTampon: { type: 'bool', optional: true },
none: { type: 'bool', optional: true },
other: { type: 'bool', optional: true },
+ note: { type: 'string', optional: true },
},
}
@@ -174,11 +175,10 @@ export default {
schemaVersion: 5,
migration: (oldRealm, newRealm) => {
if (oldRealm.schemaVersion < 5) {
- const oldObjects = oldRealm.objects('Bleeding')
const newObjects = newRealm.objects('Bleeding')
// loop through all objects and assign a default value for new properties
- for (let i = 0; i < oldObjects.length; i++) {
+ for (let i = 0; i < newObjects.length; i++) {
newObjects[i].pad = false
newObjects[i].tampon = false
newObjects[i].underwear = false
@@ -186,6 +186,7 @@ export default {
newObjects[i].softTampon = false
newObjects[i].none = false
newObjects[i].other = false
+ newObjects[i].note = null
}
}
},