From e7021dfc3961b1ce34580f25b3a1c5fe0a33edf5 Mon Sep 17 00:00:00 2001 From: Matthew Penner Date: Wed, 6 Jan 2021 09:52:22 -0700 Subject: [PATCH] ServersContainer: cleanup api code --- resources/scripts/api/admin/servers/getServers.ts | 4 ++-- .../scripts/components/admin/servers/ServersContainer.tsx | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/resources/scripts/api/admin/servers/getServers.ts b/resources/scripts/api/admin/servers/getServers.ts index daa6f2d8f..15799985a 100644 --- a/resources/scripts/api/admin/servers/getServers.ts +++ b/resources/scripts/api/admin/servers/getServers.ts @@ -49,11 +49,11 @@ interface ctx { export const Context = createContext({ page: 1, setPage: () => 1 }); -export default () => { +export default (include: string[] = []) => { const { page } = useContext(Context); return useSWR>([ '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), diff --git a/resources/scripts/components/admin/servers/ServersContainer.tsx b/resources/scripts/components/admin/servers/ServersContainer.tsx index 27b46680d..20f1d4800 100644 --- a/resources/scripts/components/admin/servers/ServersContainer.tsx +++ b/resources/scripts/components/admin/servers/ServersContainer.tsx @@ -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. */} -
{server.relations.user?.firstName} {server.relations.user?.lastName}