Use helper function.

This commit is contained in:
Dillon Kearns 2022-08-16 15:52:14 -07:00
parent 4c280a5bca
commit 6930075676

View File

@ -199,46 +199,15 @@ action routeParams =
)
Ok (Check ( newCompleteValue, itemId )) ->
okSessionThing
|> Session.get "sessionId"
|> Maybe.map Data.Session.get
|> Maybe.map Request.Hasura.dataSource
|> Maybe.map
(DataSource.andThen
(\maybeUserSession ->
let
bar : Maybe Uuid
bar =
maybeUserSession
|> Maybe.map .id
in
case bar of
Nothing ->
DataSource.succeed
( okSessionThing
, Response.render {}
)
Just userId ->
withUserSession session
(\userId ->
Data.Todo.setCompleteTo
{ userId = userId
, itemId = Uuid itemId
, newCompleteValue = newCompleteValue
}
|> Request.Hasura.mutationDataSource
|> DataSource.map
(\() ->
( okSessionThing
, Response.render {}
)
)
)
)
|> Maybe.withDefault
(DataSource.succeed
( okSessionThing
, Response.render {}
)
|> DataSource.map (\() -> Response.render {})
)
Err _ ->