diff --git a/site/gatsby-site/src/components/users/UsersField.js b/site/gatsby-site/src/components/users/UsersField.js index 5093595c23..3c8f5e3d3d 100644 --- a/site/gatsby-site/src/components/users/UsersField.js +++ b/site/gatsby-site/src/components/users/UsersField.js @@ -2,7 +2,7 @@ import React, { useCallback, useEffect, useState } from 'react'; import { useField } from 'formik'; import { AsyncTypeahead, Token } from 'react-bootstrap-typeahead'; import { useQuery } from '@apollo/client'; -import { FIND_USERS_FIELDS_ONLY } from '../../graphql/users'; +import { FIND_USERS } from '../../graphql/users'; const filterBy = (option, text) => { return ( @@ -15,7 +15,7 @@ const filterBy = (option, text) => { export default function UsersField({ id, name, placeHolder = '' }) { const [{ value }, , { setTouched, setValue }] = useField({ name }); - const { data } = useQuery(FIND_USERS_FIELDS_ONLY); + const { data } = useQuery(FIND_USERS); const [loading, setLoading] = useState(true); @@ -32,7 +32,9 @@ export default function UsersField({ id, name, placeHolder = '' }) { if (data?.users) { setSelected((selected) => selected.map(({ id }) => { - const { userId, first_name, last_name } = data.users.find((user) => user.userId == id); + const user = data.users.find((user) => user.userId == id); + + const { userId, first_name = '', last_name = '' } = user || {}; return { id: userId, first_name, last_name }; }) diff --git a/site/gatsby-site/src/graphql/users.js b/site/gatsby-site/src/graphql/users.js index 1bf63197b0..779ded43db 100644 --- a/site/gatsby-site/src/graphql/users.js +++ b/site/gatsby-site/src/graphql/users.js @@ -2,18 +2,7 @@ import gql from 'graphql-tag'; export const FIND_USERS = gql` query FindUsers { - users { - roles - userId - first_name - last_name - } - } -`; - -export const FIND_USERS_FIELDS_ONLY = gql` - query FindUsers { - users { + users(limit: 9999) { roles userId first_name diff --git a/site/gatsby-site/src/pages/cite/history.js b/site/gatsby-site/src/pages/cite/history.js index c7bf9a26d9..4235ec084c 100644 --- a/site/gatsby-site/src/pages/cite/history.js +++ b/site/gatsby-site/src/pages/cite/history.js @@ -3,7 +3,7 @@ import { Image } from 'utils/cloudinary'; import { fill } from '@cloudinary/base/actions/resize'; import { NumberParam, useQueryParam, withDefault } from 'use-query-params'; import { FIND_REPORT, FIND_REPORT_HISTORY, UPDATE_REPORT } from '../../graphql/reports'; -import { FIND_USERS_FIELDS_ONLY } from '../../graphql/users'; +import { FIND_USERS } from '../../graphql/users'; import { useMutation, useQuery } from '@apollo/client/react/hooks'; import { useTranslation, Trans } from 'react-i18next'; import DefaultSkeleton from 'elements/Skeletons/Default'; @@ -41,7 +41,7 @@ function IncidentHistoryPage() { const [report, setReport] = useState(null); - const { data: usersData, loading: loadingUsers } = useQuery(FIND_USERS_FIELDS_ONLY); + const { data: usersData, loading: loadingUsers } = useQuery(FIND_USERS); const { data: reportData, loading: loadingReport } = useQuery(FIND_REPORT, { fetchPolicy: 'network-only', diff --git a/site/gatsby-site/src/pages/incidents/edit.js b/site/gatsby-site/src/pages/incidents/edit.js index d098c365c4..28f944b62e 100644 --- a/site/gatsby-site/src/pages/incidents/edit.js +++ b/site/gatsby-site/src/pages/incidents/edit.js @@ -152,7 +152,7 @@ function EditCitePage(props) { )} {loading && } - {incident === null && !loading &&
Report not found
} + {incident === null && !loading &&
Incident not found
} {incident && (