diff --git a/frontend/src/components/projectEdit/teamSelect.js b/frontend/src/components/projectEdit/teamSelect.js
index c1ac578e0b..bdecc6affd 100644
--- a/frontend/src/components/projectEdit/teamSelect.js
+++ b/frontend/src/components/projectEdit/teamSelect.js
@@ -84,22 +84,17 @@ export const TeamSelect = () => {
});
};
- // Get only ids.
- const teamsIds = projectInfo.teams.map((t) => {
- return t.teamId;
- });
-
- let filteredTeams = teamsData?.teams?.filter((t) => !teamsIds.includes(t.teamId));
+ let teamList = teamsData?.teams;
if (org !== null) {
- filteredTeams = [
+ teamList = [
{
label: org.name,
- options: filteredTeams?.filter((t) => t.organisationId === org.organisationId),
+ options: teamList?.filter((t) => t.organisationId === org.organisationId),
},
{
label: 'Others',
- options: filteredTeams?.filter((t) => t.organisationId !== org.organisationId),
+ options: teamList?.filter((t) => t.organisationId !== org.organisationId),
},
];
}
@@ -153,7 +148,7 @@ export const TeamSelect = () => {
classNamePrefix="react-select"
getOptionLabel={(option) => option.name}
getOptionValue={(option) => option.teamId}
- options={isTeamsLoading ? [] : filteredTeams}
+ options={isTeamsLoading ? [] : teamList}
onChange={(value) => handleSelect(value, 'team')}
className="w-40 fl pr2 z-3"
value={teamSelect.team.name !== null ? teamSelect.team : null}
diff --git a/frontend/src/views/messages.js b/frontend/src/views/messages.js
index a5c8333912..ffb54d7aae 100644
--- a/frontend/src/views/messages.js
+++ b/frontend/src/views/messages.js
@@ -794,6 +794,10 @@ export default defineMessages({
defaultMessage:
'{mapping, select, true {Mapping} other {{validation, select, true {Validation} other {}}}} {mapping, select, true {{validation, select, true {and validation} other {}}} other {}} permissions have been set only to team members but no team has been added.',
},
+ duplicateTeamsAssigned: {
+ id: 'pages.edit_project.actions.duplicate_teams_assigned',
+ defaultMessage: 'Same team assigned multiple times for same role',
+ },
projectEditSection_description: {
id: 'pages.edit_project.sections.description',
defaultMessage: 'Description',
diff --git a/frontend/src/views/projectEdit.js b/frontend/src/views/projectEdit.js
index cf81790302..5c3bd599c9 100644
--- a/frontend/src/views/projectEdit.js
+++ b/frontend/src/views/projectEdit.js
@@ -55,14 +55,20 @@ export const handleCheckButton = (event, arrayElement) => {
const doesMappingTeamNotExist = (teams, mappingPermission) =>
['TEAMS', 'TEAMS_LEVEL'].includes(mappingPermission) &&
- teams.filter((team) => team.role === 'MAPPER').length === 0 &&
- teams.filter((team) => team.role === 'VALIDATOR').length === 0 &&
- teams.filter((team) => team.role === 'PROJECT_MANAGER').length === 0;
+ teams.filter((team) => team.role === 'MAPPER').length === 0;
const doesValidationTeamNotExist = (teams, validationPermission) =>
['TEAMS', 'TEAMS_LEVEL'].includes(validationPermission) &&
- teams.filter((team) => team.role === 'VALIDATOR').length === 0 &&
- teams.filter((team) => team.role === 'PROJECT_MANAGER').length === 0;
+ teams.filter((team) => team.role === 'VALIDATOR').length === 0;
+
+const doesSameTeamAndRoleExists = (teams) => {
+ const visited = {};
+ return teams?.some((team) => {
+ if (visited[team.teamId] === team.role) return true;
+ visited[team.teamId] = team.role;
+ return false;
+ });
+};
export function ProjectEdit() {
const { id } = useParams();
@@ -164,6 +170,9 @@ export function ProjectEdit() {
) {
missingFields.push({ type: 'noTeamsAssigned' });
}
+ if (doesSameTeamAndRoleExists(teams)) {
+ missingFields.push({ type: 'duplicateTeamsAssigned' });
+ }
// validate name
if (!missingFields?.[0]?.fields?.includes('name')) {
const projectName = defaultLocaleInfo.name;
@@ -368,6 +377,9 @@ const ErrorTitle = ({ locale, numberOfMissingFields, type, projectInfo }) => {
/>
);
}
+ if (type === 'duplicateTeamsAssigned') {
+ return ;
+ }
if (type === 'nameValidationError') {
return (