mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-24 06:54:03 +03:00
Use helper function.
This commit is contained in:
parent
4c280a5bca
commit
6930075676
@ -199,47 +199,16 @@ 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 ->
|
||||
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 {}
|
||||
)
|
||||
)
|
||||
withUserSession session
|
||||
(\userId ->
|
||||
Data.Todo.setCompleteTo
|
||||
{ userId = userId
|
||||
, itemId = Uuid itemId
|
||||
, newCompleteValue = newCompleteValue
|
||||
}
|
||||
|> Request.Hasura.mutationDataSource
|
||||
|> DataSource.map (\() -> Response.render {})
|
||||
)
|
||||
|
||||
Err _ ->
|
||||
DataSource.succeed
|
||||
|
Loading…
Reference in New Issue
Block a user