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 }) => { <> diff --git a/unitTests/AreaChairConsole.test.js b/unitTests/AreaChairConsole.test.js index 34f67a4af..8b5535bad 100644 --- a/unitTests/AreaChairConsole.test.js +++ b/unitTests/AreaChairConsole.test.js @@ -251,7 +251,7 @@ describe('AreaChairConsole', () => { }) }) - test('show assigned SACs in header instuction (No preferred email edge)', async () => { + test('show assigned SACs and assigned Secondary Area Chairs in header instuction (No preferred email edge)', async () => { api.getAll = jest.fn((path) => { switch (path) { case '/groups': // all groups @@ -270,6 +270,14 @@ describe('AreaChairConsole', () => { if (!param.domain) { return Promise.resolve({ edges: [] }) // call to get sac emails from edges } + if (param.invitation.includes('Secondary_Senior_Program_Committee')) { + return Promise.resolve({ + edges: [ + { tail: '~Secondary_Senior_Program_Committee1' }, + { tail: 'secondary@seniorprogramcommittee.two' }, + ], + }) + } return Promise.resolve({ edges: [{ tail: '~Senior_AC1' }, { tail: 'senior@AC.two' }], }) @@ -289,6 +297,13 @@ describe('AreaChairConsole', () => { emails: ['senior@AC.one'], }, }, + { + id: '~Secondary_Senior_Program_Committee1', + content: { + names: [{ username: '~Secondary_Senior_Program_Committee1' }], + emails: ['secondary@seniorprogramcommittee.one'], + }, + }, ], } : { @@ -301,6 +316,14 @@ describe('AreaChairConsole', () => { }, email: 'senior@AC.two', }, + { + id: '~Secondary_Senior_Program_Committee2', + content: { + names: [{ username: '~Secondary_Senior_Program_Committee2' }], + emails: ['secondary@seniorprogramcommittee.two'], + }, + email: 'secondary@seniorprogramcommittee.two', + }, ], } ) @@ -353,10 +376,15 @@ describe('AreaChairConsole', () => { 'Your assigned Area Chairs are Senior AC and Senior AC' ) ) + expect(global.marked).toHaveBeenCalledWith( + expect.stringContaining( + 'Your assigned Secondary Senior Program Committees are Secondary Senior Program Committee and Secondary Senior Program Committee' + ) + ) }) }) - test('show assigned SACs in header instuction (With preferred email edge)', async () => { + test('show assigned SACs and assigned Secondary Area Chair in header instuction (With preferred email edge)', async () => { api.getAll = jest.fn((path) => { switch (path) { case '/groups': // all groups @@ -371,7 +399,7 @@ describe('AreaChairConsole', () => { switch (path) { case '/groups': // reviewer groups return Promise.resolve({ groups: [] }) - case '/edges': // sac assignments + case '/edges': // sac and secondary ac assignments if (param.head === '~Senior_AC1') { return Promise.resolve({ edges: [{ head: '~Senior_AC1', tail: 'senior@ac.1' }], @@ -382,6 +410,22 @@ describe('AreaChairConsole', () => { edges: [{ head: '~Senior_AC2', tail: 'senior@ac.2' }], }) // call to get sac emails from edges } + if (param.head === '~Secondary_Senior_Program_Committee1') { + return Promise.resolve({ + edges: [ + { + head: '~Secondary_Senior_Program_Committee1', + tail: 'secondary@seniorprogramcommittee.one', + }, + ], + }) // call to get sac emails from edges + } + if (param.invitation.includes('Secondary_Senior_Program_Committee')) { + // secondary ac assignments + return Promise.resolve({ + edges: [{ tail: '~Secondary_Senior_Program_Committee1' }], + }) + } return Promise.resolve({ edges: [{ tail: '~Senior_AC1' }, { tail: 'senior@AC.two' }], }) @@ -401,6 +445,13 @@ describe('AreaChairConsole', () => { emails: ['senior@AC.one'], }, }, + { + id: '~Secondary_Senior_Program_Committee1', + content: { + names: [{ username: '~Secondary_Senior_Program_Committee1' }], + emails: ['secondary@seniorprogramcommittee.one'], + }, + }, ], } : { @@ -466,6 +517,11 @@ describe('AreaChairConsole', () => { 'Your assigned Area Chairs are Senior AC(senior@ac.1) and Senior AC(senior@ac.2)' ) ) + expect(global.marked).toHaveBeenCalledWith( + expect.stringContaining( + 'Your assigned Secondary Senior Program Committee is Secondary Senior Program Committee(secondary@seniorprogramcommittee.one)' + ) + ) }) })