Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
CourtHive committed Jun 3, 2024
2 parents fde5baa + a6bf829 commit 1cca6a1
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 72 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@
"@types/jest": "29.5.12",
"@types/node": "20.14.0",
"@types/supertest": "6.0.2",
"@typescript-eslint/eslint-plugin": "7.11.0",
"@typescript-eslint/parser": "7.11.0",
"@typescript-eslint/eslint-plugin": "7.12.0",
"@typescript-eslint/parser": "7.12.0",
"@vitest/coverage-v8": "1.6.0",
"@vitest/ui": "1.6.0",
"agadoo": "^3.0.0",
Expand Down
118 changes: 59 additions & 59 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 18 additions & 4 deletions src/mutate/participants/scaleItems/addScaleItems.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { addDrawDefinitionTimeItem } from '@Mutate/drawDefinitions/addDrawDefinitionTimeItem';
import { addEventTimeItem, addTournamentTimeItem } from '@Mutate/timeItems/addTimeItem';
import { participantScaleItem } from '@Query/participant/participantScaleItem';
import { decorateResult } from '@Functions/global/decorateResult';
import { addNotice, getTopics } from '@Global/state/globalState';
import { definedAttributes } from '@Tools/definedAttributes';
import { findEvent } from '@Acquire/findEvent';

// constants and types
import { ADD_SCALE_ITEMS, AUDIT, MODIFY_PARTICIPANTS } from '@Constants/topicConstants';
import { TEAM_PARTICIPANT } from '@Constants/participantConstants';
import { Participant, Tournament } from '@Types/tournamentTypes';
import { ScaleItem, ResultType } from '@Types/factoryTypes';
import { TEAM_EVENT } from '@Constants/eventConstants';
import { SUCCESS } from '@Constants/resultConstants';
import { SCALE } from '@Constants/scaleConstants';
import {
Expand Down Expand Up @@ -38,6 +41,10 @@ export function setParticipantScaleItem(params: SetParticipantScaleItemArgs) {
participant = tournamentRecord.participants.find((participant) => participant.participantId === participantId);

if (participant) {
if (participant.participantType === TEAM_PARTICIPANT && scaleItem?.eventType !== TEAM_EVENT) {
return { error: INVALID_SCALE_ITEM };
}

const result = addParticipantScaleItem({
removePriorValues,
participant,
Expand Down Expand Up @@ -110,16 +117,23 @@ export function setParticipantScaleItems(params: SetParticipantScaleItemsArgs) {
}
}

tournamentRecord.participants.forEach((participant) => {
for (const participant of tournamentRecord.participants) {
const { participantId } = participant || {};
if (Array.isArray(participantScaleItemsMap[participantId])) {
participantScaleItemsMap[participantId].forEach((scaleItem) => {
for (const scaleItem of participantScaleItemsMap[participantId]) {
if (participant.participantType === TEAM_PARTICIPANT && scaleItem?.eventType !== TEAM_EVENT) {
return decorateResult({
context: { participantId, scaleItem, participantType: participant.participantType },
info: 'Invalid participantType for eventType',
result: { error: INVALID_SCALE_ITEM },
});
}
addParticipantScaleItem({ participant, scaleItem, removePriorValues });
modifiedParticipants.push(participant);
modificationsApplied++;
});
}
}
});
}

const info = !modificationsApplied ? NO_MODIFICATIONS_APPLIED : undefined;
const { topics } = getTopics();
Expand Down
Loading

0 comments on commit 1cca6a1

Please sign in to comment.