diff --git a/components/webfield/AreaChairConsole.js b/components/webfield/AreaChairConsole.js index 341adc160..209e57807 100644 --- a/components/webfield/AreaChairConsole.js +++ b/components/webfield/AreaChairConsole.js @@ -184,7 +184,7 @@ const AreaChairConsole = ({ appContext }) => { const [activeTabId, setActiveTabId] = useState( decodeURIComponent(window.location.hash) || `#assigned-${pluralizeString(submissionName)}` ) - const [sacLinkText, setSacLinkText] = useState('') + const [sacSecondaryACLinkText, setSacSecondaryACLinkText] = useState('') const edgeBrowserUrl = proposedAssignmentTitle ? edgeBrowserProposedUrl @@ -209,47 +209,55 @@ const AreaChairConsole = ({ appContext }) => { return name ? name.fullname : prettyId(reviewerProfile.id) } - const getSACLinkText = async () => { - if (!acConsoleData.sacProfiles?.length) return - const sacName = prettyField(seniorAreaChairsId?.split('/')?.pop()) - const singluarSACName = sacName.endsWith('s') ? sacName.slice(0, -1) : sacName - const sacText = `Your assigned ${inflect( - acConsoleData.sacProfiles.length, - `${singluarSACName} is`, - `${singluarSACName}s are` + const getRoleLinkText = async (profiles, roleName) => { + if (!profiles?.length) return '' + const singluarRoleName = roleName.endsWith('s') ? roleName.slice(0, -1) : roleName + const text = `Your assigned ${inflect( + profiles.length, + `${singluarRoleName} is`, + `${singluarRoleName}s are` )}` - - let sacEmails = [] + let emails = [] if (preferredEmailInvitationId) { try { - const sacEmailPs = acConsoleData.sacProfiles.map((sacProfile) => + const emailPs = profiles.map((profile) => api .get( '/edges', - { invitation: preferredEmailInvitationId, head: sacProfile.id }, + { invitation: preferredEmailInvitationId, head: profile.id }, { accessToken } ) .then((result) => result.edges[0]?.tail) ) - sacEmails = await Promise.all(sacEmailPs) + emails = await Promise.all(emailPs) } catch (error) { /* empty */ } } - const sacProfileLinks = acConsoleData.sacProfiles.map( - (sacProfile, index) => - `${prettyId(sacProfile.id)}${ - sacEmails[index] ? `(${sacEmails[index]})` : '' + const profileLinks = profiles.map( + (profile, index) => + `${prettyId(profile.id)}${ + emails[index] ? `(${emails[index]})` : '' }` ) - setSacLinkText( - `
${sacText} ${prettyList( - sacProfileLinks, - 'long', - 'conjunction', - false - )}
` + return `${text} ${prettyList( + profileLinks, + 'long', + 'conjunction', + false + )}
` + } + + const getSACSecondaryACLinkText = async () => { + const sacRoleLinkText = await getRoleLinkText( + acConsoleData.sacProfiles, + prettyField(seniorAreaChairsId?.split('/')?.pop()) + ) + const secondaryRoleLinkText = await getRoleLinkText( + acConsoleData.secondaryAreaChairsProfiles, + prettyField(secondaryAreaChairName) ) + setSacSecondaryACLinkText(`${sacRoleLinkText}${secondaryRoleLinkText}`) } const loadData = async () => { @@ -375,6 +383,22 @@ const AreaChairConsole = ({ appContext }) => { : Promise.resolve([]) // #endregion + // #region secondary ACs + const secondaryAreaChairsP = secondaryAreaChairName + ? api + .get( + '/edges', + { + invitation: `${venueId}/${secondaryAreaChairName}/-/Assignment`, + head: user.profile.id, + domain: group.domain, + }, + { accessToken } + ) + .then((result) => result?.edges?.map((edge) => edge.tail) ?? []) + : Promise.resolve([]) + // #endregion + // #region get ithenticate edges const ithenticateEdgesP = ithenticateInvitationId ? api @@ -394,6 +418,7 @@ const AreaChairConsole = ({ appContext }) => { reviewerGroupsP, assignedSACsP, ithenticateEdgesP, + secondaryAreaChairsP, ]) // #region get assigned reviewer , sac and all reviewer group members profiles @@ -572,6 +597,12 @@ const AreaChairConsole = ({ appContext }) => { result[2].includes(p.email) ) + const secondaryAreaChairsProfiles = allProfiles.filter( + (p) => + p.content.names.some((q) => result[4].includes(q.username)) || + result[4].includes(p.email) + ) + const assignedPaperRows = tableRows.filter((p) => areaChairPaperNums.includes(p.note.number) ) @@ -589,6 +620,9 @@ const AreaChairConsole = ({ appContext }) => { sacProfiles: sacProfiles.map((sacProfile) => ({ id: sacProfile.id, })), + secondaryAreaChairsProfiles: secondaryAreaChairsProfiles.map((p) => ({ + id: p.id, + })), }) } catch (error) { promptError(`loading data: ${error.message}`) @@ -786,8 +820,8 @@ const AreaChairConsole = ({ appContext }) => { }, [acConsoleData.notes]) useEffect(() => { - getSACLinkText() - }, [acConsoleData.sacProfiles]) + getSACSecondaryACLinkText() + }, [acConsoleData.sacProfiles, acConsoleData.secondaryAreaChairsProfiles]) useEffect(() => { const validTabIds = [ @@ -832,7 +866,7 @@ const AreaChairConsole = ({ appContext }) => { <>