From 846d495f0e9bcef88b473c2cc1076b1976ed12d0 Mon Sep 17 00:00:00 2001 From: s-orug Date: Sun, 16 Apr 2023 12:12:04 -0400 Subject: [PATCH 1/2] trailing zeros added for the browse --- client/src/components/sort.jsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/src/components/sort.jsx b/client/src/components/sort.jsx index bcac6b330..712822237 100644 --- a/client/src/components/sort.jsx +++ b/client/src/components/sort.jsx @@ -44,6 +44,11 @@ const sort = (books, selection) => { break; } +function round(value, decimals) { + const roundedValue = Math.round(value * 10 ** decimals) / 10 ** decimals; + return roundedValue.toFixed(decimals); +} + return (
{books_changed.map((book) => ( @@ -56,7 +61,7 @@ const sort = (books, selection) => {
{book.title}
by: {book.author}
-
${book.price}
+
${round(book.price, 2)}
))} From 161ee9eb9dc4c6401c69bb5d7bc46667eaff1b6e Mon Sep 17 00:00:00 2001 From: s-orug Date: Sun, 16 Apr 2023 12:16:09 -0400 Subject: [PATCH 2/2] trailing zeros added for the bookspagegenerator --- client/src/views/BooksPageGenerator.jsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/src/views/BooksPageGenerator.jsx b/client/src/views/BooksPageGenerator.jsx index 43edf7491..5b649d120 100644 --- a/client/src/views/BooksPageGenerator.jsx +++ b/client/src/views/BooksPageGenerator.jsx @@ -76,6 +76,11 @@ const BooksPageGenerator = ({ book, user }) => { }); }, []); + function round(value, decimals) { + const roundedValue = Math.round(value * 10 ** decimals) / 10 ** decimals; + return roundedValue.toFixed(decimals); + } + function addOrRemoveFromWishlist() { // don't do anything if not logged-in if (!user || user.length === 0) return; @@ -121,7 +126,7 @@ const BooksPageGenerator = ({ book, user }) => {
-
    ${book.price}
+
    ${round(book.price, 2)}