Use helper function.

This commit is contained in:
Dillon Kearns 2022-08-16 15:51:39 -07:00
parent 725675a94f
commit 4c280a5bca

View File

@ -188,45 +188,14 @@ action routeParams =
) )
Ok (Delete itemId) -> Ok (Delete itemId) ->
okSessionThing withUserSession session
|> Session.get "sessionId" (\userId ->
|> 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 ->
Data.Todo.delete Data.Todo.delete
{ userId = userId { userId = userId
, itemId = Uuid itemId , itemId = Uuid itemId
} }
|> Request.Hasura.mutationDataSource |> Request.Hasura.mutationDataSource
|> DataSource.map |> DataSource.map (\() -> Response.render {})
(\() ->
( okSessionThing
, Response.render {}
)
)
)
)
|> Maybe.withDefault
(DataSource.succeed
( okSessionThing
, Response.render {}
)
) )
Ok (Check ( newCompleteValue, itemId )) -> Ok (Check ( newCompleteValue, itemId )) ->