import React, { useEffect, useState } from 'react'; import { useDeepMemoize } from '@/plugins/useDeepMemoize'; import { AdminContext } from '@/state/admin'; import { httpErrorToHuman } from '@/api/http'; import NewRoleButton from '@/components/admin/roles/NewRoleButton'; import FlashMessageRender from '@/components/FlashMessageRender'; import useFlash from '@/plugins/useFlash'; import { NavLink, useRouteMatch } from 'react-router-dom'; import tw from 'twin.macro'; import AdminContentBlock from '@/components/admin/AdminContentBlock'; import Spinner from '@/components/elements/Spinner'; import getRoles from '@/api/admin/roles/getRoles'; export default () => { const match = useRouteMatch(); const { addError, clearFlashes } = useFlash(); const [ loading, setLoading ] = useState(true); const roles = useDeepMemoize(AdminContext.useStoreState(state => state.roles.data)); const setRoles = AdminContext.useStoreActions(state => state.roles.setRoles); useEffect(() => { setLoading(!roles.length); clearFlashes('roles'); getRoles() .then(roles => setRoles(roles)) .catch(error => { console.error(error); addError({ message: httpErrorToHuman(error), key: 'roles' }); }) .then(() => setLoading(false)); }, []); return (

Roles

Soon™

{ loading ?
: roles.length < 1 ?
{'No

No items could be found, it's almost like they are hiding.

:
{ roles.map(role => ( )) }
ID Name Description
{role.id} {role.name} {role.description}
}
); };