diff options
author | William Carroll <wpcarro@gmail.com> | 2020-08-02T20·02+0100 |
---|---|---|
committer | William Carroll <wpcarro@gmail.com> | 2020-08-02T20·02+0100 |
commit | d6b91b93cbb42170249eb17eb7d0cb1c1a31f44a (patch) | |
tree | 6d99ad7c9dbe312df6c64be8c35908e18fa6b404 /client/src/Manager.elm | |
parent | c2419cd9127c0077561c6f2c4c801998d231cc41 (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.elm | 33 |
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 ] ] |