- {[...weights]
- .sort((left, right) => right.recordedOn.localeCompare(left.recordedOn))
- .map((weight) => (
-
- {formatWeight(weight.weightGrams)}
- {formatDate(weight.recordedOn)}
- {weight.notes || 'No notes recorded.'}
-
-
-
-
- ))}
+ {[...weights]
+ .sort((left, right) => right.recordedOn.localeCompare(left.recordedOn))
+ .map((weight) => {
+ const weightCanBeEdited = isWeightEditable(weight);
+
+ return (
+
+ {formatWeight(weight.weightGrams)}
+ {formatDate(weight.recordedOn)}
+ {weight.notes || 'No notes recorded.'}
+ {weightCanBeEdited ? (
+
+
+
+ ) : (
+ Editing available for the last 3 days only.
+ )}
+
+ );
+ })}
{!weights.length ?
No weight entries recorded yet.
: null}