about summary refs log tree commit diff
path: root/client/src/Manager.elm
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2020-08-02T20·02+0100
committerWilliam Carroll <wpcarro@gmail.com>2020-08-02T20·02+0100
commitd6b91b93cbb42170249eb17eb7d0cb1c1a31f44a (patch)
tree6d99ad7c9dbe312df6c64be8c35908e18fa6b404 /client/src/Manager.elm
parentc2419cd9127c0077561c6f2c4c801998d231cc41 (diff)
Allow managers to delete users
Borrow the allUsers component

TODO: Move many of these CRUD tables into Common and DRY-up usages across User,
Admin, Manager.
Diffstat (limited to 'client/src/Manager.elm')
-rw-r--r--client/src/Manager.elm33
1 files changed, 33 insertions, 0 deletions
diff --git a/client/src/Manager.elm b/client/src/Manager.elm
index 67cf9414374f..cd15c99a34a8 100644
--- a/client/src/Manager.elm
+++ b/client/src/Manager.elm
@@ -12,6 +12,38 @@ import UI
 import Utils
 
 
+allUsers : State.Model -> Html State.Msg
+allUsers model =
+    case model.accounts of
+        RemoteData.NotAsked ->
+            UI.absentData { handleFetch = State.AttemptGetAccounts }
+
+        RemoteData.Loading ->
+            UI.paragraph "Loading..."
+
+        RemoteData.Failure e ->
+            UI.paragraph ("Error: " ++ Utils.explainHttpError e)
+
+        RemoteData.Success xs ->
+            ul []
+                (xs
+                    |> List.map
+                        (\account ->
+                            li []
+                                [ UI.paragraph
+                                    (account.username
+                                        ++ " - "
+                                        ++ State.roleToString account.role
+                                    )
+                                , UI.textButton
+                                    { label = "delete"
+                                    , handleClick = State.AttemptDeleteAccount account.username
+                                    }
+                                ]
+                        )
+                )
+
+
 render : State.Model -> Html State.Msg
 render model =
     Common.withSession model
@@ -31,6 +63,7 @@ render model =
                         { label = "Logout"
                         , handleClick = State.AttemptLogout
                         }
+                    , allUsers model
                     , Common.allErrors model
                     ]
                 ]