From 23f19434b45cfa041c1d5882b5961f1481fc6ee8 Mon Sep 17 00:00:00 2001 From: Lavish Date: Sun, 11 Feb 2024 00:19:29 +0530 Subject: [PATCH] Fixed clipping of downvotes to 0 --- src/components/Card/CardWithPicture.jsx | 2 +- src/components/Card/CardWithoutPicture.jsx | 2 +- src/components/TutorialPage/components/Commnets/Comment.jsx | 2 +- src/components/TutorialPage/components/PostDetails.jsx | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/Card/CardWithPicture.jsx b/src/components/Card/CardWithPicture.jsx index e8cd65c2..3505d48a 100644 --- a/src/components/Card/CardWithPicture.jsx +++ b/src/components/Card/CardWithPicture.jsx @@ -83,7 +83,7 @@ export default function CardWithPicture({ tutorial }) { }; const handleDecrement = () => { - setCount(count - 1); + setCount(Math.max(count - 1, 0)); }; const handleAlignment = (event, newAlignment) => { diff --git a/src/components/Card/CardWithoutPicture.jsx b/src/components/Card/CardWithoutPicture.jsx index abc4ecb0..c4a4dbae 100644 --- a/src/components/Card/CardWithoutPicture.jsx +++ b/src/components/Card/CardWithoutPicture.jsx @@ -77,7 +77,7 @@ export default function CardWithoutPicture({ tutorial }) { }; const handleDecrement = () => { - setCount(count - 1); + setCount(Math.max(count - 1, 0)); }; const handleAlignment = (event, newAlignment) => { diff --git a/src/components/TutorialPage/components/Commnets/Comment.jsx b/src/components/TutorialPage/components/Commnets/Comment.jsx index 09e486fc..8f0d8502 100644 --- a/src/components/TutorialPage/components/Commnets/Comment.jsx +++ b/src/components/TutorialPage/components/Commnets/Comment.jsx @@ -89,7 +89,7 @@ const Comment = ({ id }) => { }; const handleDecrement = () => { - setCount(count - 1); + setCount(Math.max(count - 1, 0)); }; const handleAlignment = (event, newAlignment) => { diff --git a/src/components/TutorialPage/components/PostDetails.jsx b/src/components/TutorialPage/components/PostDetails.jsx index 1c46ac63..57f1eb9b 100644 --- a/src/components/TutorialPage/components/PostDetails.jsx +++ b/src/components/TutorialPage/components/PostDetails.jsx @@ -70,7 +70,7 @@ const PostDetails = ({ details }) => { }; const handleDecrement = () => { - setCount(count - 1); + setCount(Math.max(count - 1, 0)); }; const handleAlignment = (event, newAlignment) => {