From 7474e6255b5f9d5a67770b2613d0668056224f2d Mon Sep 17 00:00:00 2001
From: Andrew Lee <alee14498@protonmail.com>
Date: Wed, 7 Feb 2024 18:29:24 -0500
Subject: Fixed pagination

---
 src/components/Guestbook.jsx | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'src/components/Guestbook.jsx')

diff --git a/src/components/Guestbook.jsx b/src/components/Guestbook.jsx
index caa092a..c2df8e2 100644
--- a/src/components/Guestbook.jsx
+++ b/src/components/Guestbook.jsx
@@ -16,9 +16,9 @@ class Guestbook extends Component {
         const start = (page - 1) * perPage;
         const end = start + perPage - 1;
 
-        let { data: messages, error } = await supabase
+        let { data: messages, error, count } = await supabase
             .from('guestbook')
-            .select('*')
+            .select('*', { count: 'exact' })
             .range(start, end)
             .order('created_at', { ascending: false });
         if (error) {
@@ -27,7 +27,7 @@ class Guestbook extends Component {
         } else {
             this.setState({
                 message: messages,
-                totalPages: Math.ceil(messages.length / perPage)
+                totalPages: Math.ceil(count / perPage)
             });
         }
     }
-- 
cgit v1.2.3

