diff options
author | Alexander Foremny <aforemny@posteo.de> | 2024-06-06 23:05:41 +0200 |
---|---|---|
committer | Alexander Foremny <aforemny@posteo.de> | 2024-06-06 23:05:41 +0200 |
commit | 378e007141c699945080bbf944aeef4abf67d75c (patch) | |
tree | 0e734b64e6ba2549b5b5fd4df01a33880af7fe62 /frontend/app/Page | |
parent | 3add980b73b1ac75d1ad1dde85f6c782439914be (diff) |
add new collection page
Diffstat (limited to 'frontend/app/Page')
-rw-r--r-- | frontend/app/Page/NewCollection.hs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/frontend/app/Page/NewCollection.hs b/frontend/app/Page/NewCollection.hs new file mode 100644 index 0000000..b105689 --- /dev/null +++ b/frontend/app/Page/NewCollection.hs @@ -0,0 +1,44 @@ +module Page.NewCollection + ( Model, + initialModel, + Action, + updateModel, + viewModel, + ) +where + +import Data.Text qualified as T +import Form qualified as F +import Miso + +data Model = Model + { input :: T.Text + } + deriving (Show, Eq) + +initialModel :: JSM (Either String Model) +initialModel = do + pure (Right (Model {input = ""})) + +data Action + = NoOp + | FormChanged T.Text + | FormSubmitted T.Text + deriving (Eq, Show) + +updateModel :: Action -> Model -> Effect Action Model +updateModel NoOp m = noEff m +updateModel (FormChanged input) m = noEff m {input} +updateModel (FormSubmitted _) m = noEff m + +viewModel :: Model -> View Action +viewModel m = do + div_ [] $ + [ h3_ [] [text "new collection"], + either FormChanged FormSubmitted + <$> F.runForm collectionForm m.input + ] + +collectionForm :: F.Form T.Text T.Text +collectionForm = + F.input "name" |