mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-26 13:21:42 +03:00
Use helper function.
This commit is contained in:
parent
725675a94f
commit
4c280a5bca
@ -188,46 +188,15 @@ action routeParams =
|
|||||||
)
|
)
|
||||||
|
|
||||||
Ok (Delete itemId) ->
|
Ok (Delete itemId) ->
|
||||||
okSessionThing
|
withUserSession session
|
||||||
|> Session.get "sessionId"
|
(\userId ->
|
||||||
|> Maybe.map Data.Session.get
|
Data.Todo.delete
|
||||||
|> Maybe.map Request.Hasura.dataSource
|
{ userId = userId
|
||||||
|> Maybe.map
|
, itemId = Uuid itemId
|
||||||
(DataSource.andThen
|
}
|
||||||
(\maybeUserSession ->
|
|> Request.Hasura.mutationDataSource
|
||||||
let
|
|> DataSource.map (\() -> Response.render {})
|
||||||
bar : Maybe Uuid
|
)
|
||||||
bar =
|
|
||||||
maybeUserSession
|
|
||||||
|> Maybe.map .id
|
|
||||||
in
|
|
||||||
case bar of
|
|
||||||
Nothing ->
|
|
||||||
DataSource.succeed
|
|
||||||
( okSessionThing
|
|
||||||
, Response.render {}
|
|
||||||
)
|
|
||||||
|
|
||||||
Just userId ->
|
|
||||||
Data.Todo.delete
|
|
||||||
{ userId = userId
|
|
||||||
, itemId = Uuid itemId
|
|
||||||
}
|
|
||||||
|> Request.Hasura.mutationDataSource
|
|
||||||
|> DataSource.map
|
|
||||||
(\() ->
|
|
||||||
( okSessionThing
|
|
||||||
, Response.render {}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|> Maybe.withDefault
|
|
||||||
(DataSource.succeed
|
|
||||||
( okSessionThing
|
|
||||||
, Response.render {}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
Ok (Check ( newCompleteValue, itemId )) ->
|
Ok (Check ( newCompleteValue, itemId )) ->
|
||||||
okSessionThing
|
okSessionThing
|
||||||
|
Loading…
Reference in New Issue
Block a user