1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-29 07:54:19 +00:00
pds-2021-g2-nest/nest_frontend/routes/PageUsers.js

30 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-05-18 16:50:02 +00:00
import React, { useContext } from "react"
2021-05-12 02:10:36 +00:00
import Style from "./PageUsers.module.css"
2021-05-11 17:42:04 +00:00
import classNames from "classnames"
import BoxHeader from "../components/base/BoxHeader"
2021-05-11 21:27:42 +00:00
import BoxUserCreate from "../components/interactive/BoxUserCreate"
2021-05-12 02:10:36 +00:00
import useBackendViewset from "../hooks/useBackendViewset"
import BoxUserList from "../components/interactive/BoxUserList"
2021-05-18 16:50:02 +00:00
import ContextLanguage from "../contexts/ContextLanguage"
2021-05-24 12:49:59 +00:00
import Alert from "../components/base/Alert"
2021-05-11 17:42:04 +00:00
2021-05-11 21:27:42 +00:00
export default function PageUsers({ children, className, ...props }) {
2021-05-18 16:50:02 +00:00
const { strings } = useContext(ContextLanguage)
2021-05-12 02:10:36 +00:00
const bv = useBackendViewset("/api/v1/users/", "email")
2021-05-11 21:27:42 +00:00
2021-05-11 17:42:04 +00:00
return (
2021-05-12 02:10:36 +00:00
<div className={classNames(Style.PageUsers, className)} {...props}>
2021-05-11 17:42:04 +00:00
<BoxHeader className={Style.Header}>
2021-05-18 16:50:02 +00:00
{strings.manageUsers}
2021-05-11 17:42:04 +00:00
</BoxHeader>
2021-05-12 02:10:36 +00:00
<BoxUserCreate className={Style.CreateUser} createUser={bv.createResource} running={bv.running}/>
<BoxUserList className={Style.UserList} users={bv.resources} destroyUser={bv.destroyResource} running={bv.running}/>
{bv.error ?
2021-05-24 12:49:59 +00:00
<Alert className={Style.Error} color={"red"}>{strings[bv.error?.data?.code ?? "errorUnknownError"]}</Alert>
: null}
2021-05-11 17:42:04 +00:00
</div>
)
}