Skip to content

Commit

Permalink
Merge pull request #67 from Elizabethhub/fix-bug/modal-edit
Browse files Browse the repository at this point in the history
fix span for identical value condition
  • Loading branch information
Elizabethhub authored Mar 19, 2024
2 parents eba7160 + 56fe9a6 commit e7fe802
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/components/ModalAddWater/ModalAddWater.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ const ModalAddWater = () => {
};

const handleManualValueChange = (e) => {
const value = e.target.value;
let value = e.target.value;
if (
value !== '' &&
(isNaN(value) || parseInt(value) > 5000 || parseInt(value) < 1)
) {
value = '5000';
}
setManualValue(value);
};

Expand Down Expand Up @@ -93,7 +99,7 @@ const ModalAddWater = () => {
>
<SvgMinus size="24" />
</button>
<span>{`${counter}ml`}</span>
<span>{displayValue ? displayValue : `${counter}ml`}</span>
<button type="button" name="increment" onClick={handleUpdate}>
<SvgPlus size="24" />
</button>
Expand Down
10 changes: 8 additions & 2 deletions src/components/ModalEditWater/ModalEditWater.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ const ModalEditWater = () => {
const formattedTime = format(time, 'hh:mm a');

const handleManualValueChange = (e) => {
const value = e.target.value;
let value = e.target.value;
if (
value !== '' &&
(isNaN(value) || parseInt(value) > 5000 || parseInt(value) < 1)
) {
value = '5000';
}
setManualValue(value);
};

Expand Down Expand Up @@ -74,7 +80,7 @@ const ModalEditWater = () => {
>
<SvgMinus size="24" />
</button>
<span>{`${counter}ml`}</span>
<span>{displayValue ? displayValue : `${counter}ml`}</span>
<button type="button" name="increment" onClick={handleUpdate}>
<SvgPlus size="24" />
</button>
Expand Down

0 comments on commit e7fe802

Please sign in to comment.