diff options
Diffstat (limited to 'frontend/app/Page/EditValue.hs')
-rw-r--r-- | frontend/app/Page/EditValue.hs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/frontend/app/Page/EditValue.hs b/frontend/app/Page/EditValue.hs index 294d1c9..d5a87e7 100644 --- a/frontend/app/Page/EditValue.hs +++ b/frontend/app/Page/EditValue.hs @@ -10,6 +10,7 @@ where import Api import Data.Aeson qualified as A import Data.Aeson.KeyMap qualified as AM +import Data.ByteString.Lazy.UTF8 as LB import Data.Maybe import Form qualified as F import Miso @@ -52,7 +53,8 @@ viewModel m = do let input = (fromMaybe (A.Object AM.empty) m.input) div_ [] $ [ viewForm input m.schema, - viewInput input + viewInput input, + viewOutput input m.schema ] viewForm :: A.Value -> Schema -> View Action @@ -64,3 +66,13 @@ viewForm input = viewInput :: A.Value -> View Action viewInput input = pre_ [] [text (toMisoString (A.encode input))] + +viewOutput :: A.Value -> Schema -> View Action +viewOutput input schema = + pre_ [] $ + [ text $ + toMisoString + ( either ("Left " <>) (("Right " <>) . LB.toString) $ + (A.encode <$> ((schemaForm schema).fill input)) + ) + ] |