diff options
author | Joris Guyonvarch | 2015-07-18 18:29:46 +0200 |
---|---|---|
committer | Joris Guyonvarch | 2015-07-18 18:29:46 +0200 |
commit | 3486644b442a0800f645ec9ae7f3ce8fe2b3c9cd (patch) | |
tree | 07cf31c37b09a2cb8bcb04380b91a640727888df /src/client/View | |
parent | b27a7914993f5a5a87160dc33431a6fa1f4ad323 (diff) |
Showing either the payment table or a forbidden message in the UI
Diffstat (limited to 'src/client/View')
-rw-r--r-- | src/client/View/Page.elm | 62 |
1 files changed, 45 insertions, 17 deletions
diff --git a/src/client/View/Page.elm b/src/client/View/Page.elm index 73afed9..777655c 100644 --- a/src/client/View/Page.elm +++ b/src/client/View/Page.elm @@ -18,31 +18,59 @@ import Model.Payment exposing (Payments, Payment) renderPage : Model -> Html renderPage model = + div + [] + [ renderHeader + , renderMain model + ] + +renderHeader : Html +renderHeader = header [] [ h1 [] [ text "Payments" ] - , table - [] - ([ tr - [] - [ th [] [ text "Utilisateur" ] - , th [] [ text "Nom" ] - , th [] [ text "Prix" ] - , th [] [ text "Date" ] - ] - ] ++ (List.map renderPayment model.payments)) ] -renderPayments : Payments -> List Html -renderPayments = - List.map renderPayment - << List.reverse - << List.sortBy (Date.toTime << .creation) +renderMain : Model -> Html +renderMain model = + if model.forbiddenAccess + then + forbiddenAccess + else + model.payments + |> Maybe.map paymentTable + |> Maybe.withDefault loadingTable + +forbiddenAccess : Html +forbiddenAccess = text "Forbidden access" + +loadingTable : Html +loadingTable = text "" + +paymentTable : Payments -> Html +paymentTable payments = + table + [] + ([ tr + [] + [ th [] [ text "Utilisateur" ] + , th [] [ text "Nom" ] + , th [] [ text "Prix" ] + , th [] [ text "Date" ] + ] + ] ++ (paymentLines payments)) + +paymentLines : Payments -> List Html +paymentLines payments = + payments + |> List.sortBy (Date.toTime << .creation) + |> List.reverse + |> List.map paymentLine -renderPayment : Payment -> Html -renderPayment payment = +paymentLine : Payment -> Html +paymentLine payment = tr [] [ td [] [ text payment.name ] |