From b4bac6a9157119a4f234933245944e133c127bd0 Mon Sep 17 00:00:00 2001 From: TheCatLady <52870424+TheCatLady@users.noreply.github.com> Date: Fri, 19 Feb 2021 02:48:06 -0500 Subject: [PATCH] fix(frontend): Update AdvancedRequester to reflect new /user API response (#970) --- .../RequestModal/AdvancedRequester/index.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/RequestModal/AdvancedRequester/index.tsx b/src/components/RequestModal/AdvancedRequester/index.tsx index 39be37bf0..d231c23b2 100644 --- a/src/components/RequestModal/AdvancedRequester/index.tsx +++ b/src/components/RequestModal/AdvancedRequester/index.tsx @@ -10,6 +10,7 @@ import { defineMessages, useIntl } from 'react-intl'; import { formatBytes } from '../../../utils/numberHelpers'; import { Listbox, Transition } from '@headlessui/react'; import { Permission, User, useUser } from '../../../hooks/useUser'; +import type { UserResultsResponse } from '../../../../server/interfaces/api/userInterfaces'; const messages = defineMessages({ advancedoptions: 'Advanced Options', @@ -97,17 +98,17 @@ const AdvancedRequester: React.FC = ({ requestUser ?? null ); - const { data: userData } = useSWR( + const { data: userData } = useSWR( hasPermission([Permission.MANAGE_REQUESTS, Permission.MANAGE_USERS]) - ? '/api/v1/user' + ? '/api/v1/user?take=1000' : null ); useEffect(() => { - if (userData && !requestUser) { - setSelectedUser(userData.find((u) => u.id === user?.id) ?? null); + if (userData?.results && !requestUser) { + setSelectedUser(userData.results.find((u) => u.id === user?.id) ?? null); } - }, [userData]); + }, [userData?.results]); useEffect(() => { let defaultServer = data?.find( @@ -471,7 +472,7 @@ const AdvancedRequester: React.FC = ({ static className="py-1 overflow-auto text-base leading-6 rounded-md shadow-xs max-h-60 focus:outline-none sm:text-sm sm:leading-5" > - {userData?.map((user) => ( + {userData?.results.map((user) => ( {({ selected, active }) => (