1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-22 21:14:18 +00:00
pds-2021-g2-nest/nest_frontend/routes/PageUsers.js

45 lines
1.7 KiB
JavaScript

import React, { useContext } from "react"
import BoxHeader from "../components/base/BoxHeader"
import BoxUserCreate from "../components/interactive/BoxUserCreate"
import useBackendViewset from "../hooks/useBackendViewset"
import BoxUserList from "../components/interactive/BoxUserList"
import ContextLanguage from "../contexts/ContextLanguage"
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"
export default function PageUsers({ children, className, ...props }) {
const { strings } = useContext(ContextLanguage)
const {createResource, running, resources, destroyResource, error} = useBackendViewset("/api/v1/users/", "email")
return (
<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>
)
}