aboutsummaryrefslogtreecommitdiff
path: root/src/client/View
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/View')
-rw-r--r--src/client/View/Page.elm62
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 ]