aboutsummaryrefslogtreecommitdiffstats
path: root/frontend/app/Page/ListCollection.hs
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2024-10-11 23:30:56 +0200
committerLibravatar Alexander Foremny <aforemny@posteo.de>2024-10-11 23:30:56 +0200
commit80a6150610182eefa0deb1f0932d3b780456ca09 (patch)
tree4471a8ffecfc527d6b9c2a5c48e445e7a4d6a74f /frontend/app/Page/ListCollection.hs
parent2e0cf98254976e443ea7f693961fc105ed6cf563 (diff)
use backend REST library for frontend
Diffstat (limited to 'frontend/app/Page/ListCollection.hs')
-rw-r--r--frontend/app/Page/ListCollection.hs18
1 files changed, 10 insertions, 8 deletions
diff --git a/frontend/app/Page/ListCollection.hs b/frontend/app/Page/ListCollection.hs
index 9acca3c..47a4649 100644
--- a/frontend/app/Page/ListCollection.hs
+++ b/frontend/app/Page/ListCollection.hs
@@ -7,29 +7,31 @@ module Page.ListCollection
)
where
-import Api
+import ACMS.API.REST.Collection qualified as API.REST.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 Miso.String (MisoString)
import Schema
data Model = Model
- { collection :: String,
- input :: A.Value,
+ { collection :: MisoString,
+ input :: A.Object,
schema :: Schema,
- posts :: [A.Value]
+ posts :: [A.Object]
}
deriving (Show, Eq)
-initialModel :: String -> JSM (Either String Model)
+initialModel :: MisoString -> JSM (Either SomeException Model)
initialModel collection = do
- schema' <- fetchSchema
- posts' <- fetchPosts
+ schema' <- try (API.REST.Collection.schema collection)
+ posts' <- try (API.REST.Collection.list collection)
pure do
schema <- schema'
posts <- posts'
- pure $ Model {input = A.Object AM.empty, ..}
+ pure $ Model {input = AM.empty, ..}
newtype Action = Action (Model -> (Effect Action Model, [Eff]))