From d6b91b93cbb42170249eb17eb7d0cb1c1a31f44a Mon Sep 17 00:00:00 2001 From: William Carroll Date: Sun, 2 Aug 2020 21:02:22 +0100 Subject: [PATCH] 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. --- client/src/Manager.elm | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/client/src/Manager.elm b/client/src/Manager.elm index 67cf94143..cd15c99a3 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 ] ]