2021-05-18 16:50:02 +00:00
|
|
|
import React, { useContext } from "react"
|
2021-05-11 17:42:04 +00:00
|
|
|
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-25 02:06:14 +00:00
|
|
|
import PageWithHeader from "../components/base/layout/PageWithHeader"
|
|
|
|
import { faUserCog } from "@fortawesome/free-solid-svg-icons"
|
|
|
|
import makeIcon from "../utils/makeIcon"
|
|
|
|
import AlertError from "../components/interactive/AlertError"
|
|
|
|
import BodyHorizontalUpperGrow from "../components/base/layout/BodyHorizontalUpperGrow"
|
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-25 02:06:14 +00:00
|
|
|
const {createResource, running, resources, destroyResource, error} = useBackendViewset("/api/v1/users/", "email")
|
2021-05-11 21:27:42 +00:00
|
|
|
|
2021-05-11 17:42:04 +00:00
|
|
|
return (
|
2021-05-25 02:06:14 +00:00
|
|
|
<PageWithHeader
|
|
|
|
header={
|
|
|
|
<BoxHeader>
|
|
|
|
{makeIcon(faUserCog)} {strings.manageUsers}
|
|
|
|
</BoxHeader>
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<BodyHorizontalUpperGrow
|
|
|
|
upper={
|
|
|
|
<BoxUserList
|
|
|
|
users={resources}
|
|
|
|
destroyUser={destroyResource}
|
|
|
|
running={running}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
lower={
|
|
|
|
<BoxUserCreate
|
|
|
|
createUser={createResource}
|
|
|
|
running={running}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
error={error ? <AlertError error={error}/> : null}
|
|
|
|
/>
|
|
|
|
</PageWithHeader>
|
2021-05-11 17:42:04 +00:00
|
|
|
)
|
|
|
|
}
|