ServersContainer: cleanup api code

This commit is contained in:
Matthew Penner 2021-01-06 09:52:22 -07:00
parent b4ec1fb45d
commit e7021dfc39
2 changed files with 3 additions and 4 deletions

View file

@ -49,11 +49,11 @@ interface ctx {
export const Context = createContext<ctx>({ page: 1, setPage: () => 1 });
export default () => {
export default (include: string[] = []) => {
const { page } = useContext(Context);
return useSWR<PaginatedResult<Server>>([ 'servers', page ], async () => {
const { data } = await http.get('/api/application/servers', { params: { include: 'node,user', page } });
const { data } = await http.get('/api/application/servers', { params: { include: include.join(','), page } });
return ({
items: (data.data || []).map(rawDataToServerObject),

View file

@ -36,7 +36,7 @@ const UsersContainer = () => {
const { page, setPage } = useContext(ServersContext);
const { clearFlashes, clearAndAddHttpError } = useFlash();
const { data: servers, error, isValidating } = getServers();
const { data: servers, error, isValidating } = getServers([ 'node', 'user' ]);
useEffect(() => {
if (!error) {
@ -122,7 +122,6 @@ const UsersContainer = () => {
{/* TODO: Have permission check for displaying user information. */}
<td css={tw`px-6 text-sm text-left whitespace-nowrap`}>
<NavLink to={`/admin/users/${server.relations.user?.id}`} css={tw`text-primary-400 hover:text-primary-300`}>
<div css={tw`text-sm text-neutral-200`}>
{server.relations.user?.firstName} {server.relations.user?.lastName}
</div>