From 24633871359ec9fbd63fdfebf79a6351b2792f77 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 6 Sep 2015 00:05:50 +0200 Subject: Can add monthly payments, not visible at the moment though, just the count is printed --- src/client/Main.elm | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/client/Main.elm') diff --git a/src/client/Main.elm b/src/client/Main.elm index 368d930..3174ba6 100644 --- a/src/client/Main.elm +++ b/src/client/Main.elm @@ -57,9 +57,14 @@ port initView = Just msg -> Signal.send actions.address (SignInError msg) Nothing -> - Task.map5 GoLoggedView getUsers whoAmI getPayments getPaymentsCount getPayers - |> flip Task.andThen (Signal.send actions.address) - |> flip Task.onError (\_ -> Signal.send actions.address GoSignInView) + Task.andThen getUsers <| \users -> + Task.andThen whoAmI <| \me -> + Task.andThen getMonthlyPayments <| \monthlyPayments -> + Task.andThen getPayments <| \payments -> + Task.andThen getPaymentsCount <| \paymentsCount -> + Task.andThen getPayers <| \payers -> + Signal.send actions.address (GoLoggedView users me monthlyPayments payments paymentsCount payers) + |> flip Task.onError (\_ -> Signal.send actions.address GoSignInView) getUsers : Task Http.Error Users getUsers = Http.get usersDecoder "/users" @@ -67,6 +72,9 @@ getUsers = Http.get usersDecoder "/users" whoAmI : Task Http.Error UserId whoAmI = Http.get ("id" := userIdDecoder) "/whoAmI" +getMonthlyPayments : Task Http.Error Payments +getMonthlyPayments = Http.get paymentsDecoder "/monthlyPayments" + getPayments : Task Http.Error Payments getPayments = Http.get paymentsDecoder ("/payments?page=1&perPage=" ++ toString perPage) -- cgit v1.2.3