Skip to content

Commit

Permalink
fix/fixing how singleSelectionPerRow get value
Browse files Browse the repository at this point in the history
  • Loading branch information
Felipe Imperio authored and Felipe Imperio committed Dec 3, 2024
1 parent a8bdeb5 commit ae34bb1
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/features/pass-survey/model/AnswerValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,19 @@ export function AnswerValidator(
return null;
};

const getSelectionRowOptionValue = (rowIndex: number): string | null => {
const answer = currentAnswer?.answer as Maybe<
{ id: string; text: string }[]
>;

if (answer && answer[rowIndex]) {
const optionIds = answer[rowIndex].id;

return optionIds;
}
return null;
};

return {
isCorrect() {
if (!currentPipelineItem?.validationOptions) {
Expand Down Expand Up @@ -164,12 +177,12 @@ export function AnswerValidator(
},

isEqualToRowOption(rowIndex: number, optionValue: string) {
const selectedOption = getRowOptionValues(rowIndex);
const selectedOption = getSelectionRowOptionValue(rowIndex);
return selectedOption !== null && selectedOption.includes(optionValue);
},

isNotEqualToRowOption(rowIndex: number, optionValue: string) {
const selectedOption = getRowOptionValues(rowIndex);
const selectedOption = getSelectionRowOptionValue(rowIndex);
return selectedOption !== null && !selectedOption.includes(optionValue);
},

Expand Down

0 comments on commit ae34bb1

Please sign in to comment.