From 00e332a7f729d90fc0a0033c0f912844fff5c3a8 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Tue, 17 Oct 2023 10:15:57 -0300 Subject: [PATCH] Fetch editors and admin to enable edit on submissions --- .../components/submissions/SubmissionEdit.js | 2 +- .../submissions/SubmissionEditForm.js | 40 ++++++++++--------- site/gatsby-site/src/graphql/users.js | 4 +- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/site/gatsby-site/src/components/submissions/SubmissionEdit.js b/site/gatsby-site/src/components/submissions/SubmissionEdit.js index b567a01075..d2598d9e70 100644 --- a/site/gatsby-site/src/components/submissions/SubmissionEdit.js +++ b/site/gatsby-site/src/components/submissions/SubmissionEdit.js @@ -28,7 +28,7 @@ const SubmissionEdit = ({ id }) => { const [createEntityMutation] = useMutation(UPSERT_ENTITY); const { data: userData, loading: userLoading } = useQuery(FIND_USERS_BY_ROLE, { - variables: { role: 'editor' }, + variables: { role: ['editor', 'admin'] }, }); const addToast = useToastContext(); diff --git a/site/gatsby-site/src/components/submissions/SubmissionEditForm.js b/site/gatsby-site/src/components/submissions/SubmissionEditForm.js index b97aeab071..3fa9785a8e 100644 --- a/site/gatsby-site/src/components/submissions/SubmissionEditForm.js +++ b/site/gatsby-site/src/components/submissions/SubmissionEditForm.js @@ -391,25 +391,27 @@ const SubmissionEditForm = ({ handleSubmit, saving, setSaving, userLoading, user
{!userLoading && ( - {userData.users.map((user) => { - const isChecked = - selectedOptions.findIndex((editor) => editor.userId === user.userId) > -1; - - return ( - -
- handleSelect(ev.target.checked, user.userId)} - /> - -
-
- ); - })} + {userData.users + .filter((user) => user.first_name || user.last_name) + .map((user) => { + const isChecked = + selectedOptions.findIndex((editor) => editor.userId === user.userId) > -1; + + return ( + +
+ handleSelect(ev.target.checked, user.userId)} + /> + +
+
+ ); + })}
)}
diff --git a/site/gatsby-site/src/graphql/users.js b/site/gatsby-site/src/graphql/users.js index f276fec1a0..1bf63197b0 100644 --- a/site/gatsby-site/src/graphql/users.js +++ b/site/gatsby-site/src/graphql/users.js @@ -40,8 +40,8 @@ export const FIND_USER = gql` `; export const FIND_USERS_BY_ROLE = gql` - query FindUsersByRole($role: String!) { - users(query: { roles_in: [$role] }) { + query FindUsersByRole($role: [String!]) { + users(query: { roles_in: $role }) { roles userId first_name