From 9b0adc976101bc4f375b05cc475478187c595714 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Wed, 18 Dec 2024 19:11:03 +0100 Subject: add pagination to rest api --- frontend/app/Page/ListCollection.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'frontend/app/Page') diff --git a/frontend/app/Page/ListCollection.hs b/frontend/app/Page/ListCollection.hs index ff659af..9e3caaa 100644 --- a/frontend/app/Page/ListCollection.hs +++ b/frontend/app/Page/ListCollection.hs @@ -8,26 +8,28 @@ module Page.ListCollection where import ACMS.API.REST.Collection qualified as API.REST.Collection +import ACMS.API.REST.Collection.Paginated (Paginated (..)) +import ACMS.API.REST.Collection.Paginated qualified as API.REST.Collection.Paginated +import Collection import Control.Monad.Catch (SomeException, try) import Data.Aeson qualified as A import Data.Aeson.KeyMap qualified as AM import Effect (Eff) import Miso import Schema -import Collection data Model = Model { collection :: Collection, input :: A.Object, schema :: Schema, - posts :: [A.Object] + posts :: Paginated A.Object } deriving (Show, Eq) initialModel :: Collection -> JSM (Either SomeException Model) initialModel collection = do schema' <- try (API.REST.Collection.schema collection) - posts' <- try (API.REST.Collection.list collection) + posts' <- try (API.REST.Collection.Paginated.list (API.REST.Collection.Paginated.Pagination 10 0) collection) pure do schema <- schema' posts <- posts' -- cgit v1.2.3