Handle form result in case expression in route generator.

This commit is contained in:
Dillon Kearns 2023-03-04 07:39:10 -08:00
parent 2c3665c70f
commit 154a4ff0b0

View File

@ -134,18 +134,40 @@ createFile { moduleName, fields } =
"response"
"parsedForm"
(\response parsedForm ->
Gen.Debug.toString parsedForm
|> Gen.Pages.Script.call_.log
|> Gen.BackendTask.call_.map
(Elm.fn ( "_", Nothing )
(\_ ->
Response.render
(Elm.record
[ ( "errors", response )
]
Elm.Case.result parsedForm
{ err =
( "error"
, \error ->
Gen.Debug.toString error
|> Gen.Pages.Script.call_.log
|> Gen.BackendTask.call_.map
(Elm.fn ( "_", Nothing )
(\_ ->
Response.render
(Elm.record
[ ( "errors", response )
]
)
)
)
)
)
, ok =
( "okForm"
, \okForm ->
Gen.Debug.toString okForm
|> Gen.Pages.Script.call_.log
|> Gen.BackendTask.call_.map
(Elm.fn ( "_", Nothing )
(\_ ->
Response.render
(Elm.record
[ ( "errors", response )
]
)
)
)
)
}
)
)
)