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:
parent
c2419cd912
commit
d6b91b93cb
1 changed files with 33 additions and 0 deletions
|
@ -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
|
||||
]
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue