git.mcksp
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}

module Catalogue
    ( catalogue
    ) where

import Text.Blaze.Html5 as H
import Text.Blaze.Html5.Attributes as A
import Database.SQLite.Simple as SQL
import Control.Monad.IO.Class (liftIO)
import Data.Foldable (for_)
import Models
import Card

catalogue :: SQL.Connection -> IO H.Html 
catalogue conn = do
    (items :: [Item]) <- liftIO $ SQL.query_ conn "select * from items"
    return $ H.div $ do
        H.div "list of all items"
        H.div ! A.class_ "items" $ do
            for_ items card