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.
This commit is contained in:
William Carroll 2020-08-02 21:02:22 +01:00
parent c2419cd912
commit d6b91b93cb

View file

@ -12,6 +12,38 @@ import UI
import Utils 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 : State.Model -> Html State.Msg
render model = render model =
Common.withSession model Common.withSession model
@ -31,6 +63,7 @@ render model =
{ label = "Logout" { label = "Logout"
, handleClick = State.AttemptLogout , handleClick = State.AttemptLogout
} }
, allUsers model
, Common.allErrors model , Common.allErrors model
] ]
] ]