Skip to content

Commit

Permalink
Create mapper to answer
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Riabkov committed Apr 4, 2024
1 parent 9a1a9d2 commit 1d2a728
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const RadioGrid = ({ rows, options, onChange, values }: Props) => {
isEven={isEven}
item={{ id: row.id, imageUrl: row.rowImage, text: row.rowName, tooltip: row.tooltip }}
>
{options.map((option, optionI) => {
{options.map((option) => {
const isChecked = option.text === values[rowI];

return (
Expand Down
14 changes: 14 additions & 0 deletions src/widgets/ActivityDetails/model/mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
MultiSelectionRowsItem,
RadioItem,
SelectorItem,
SingleSelectionRowsItem,
SliderItem,
TextItem,
TimeItem,
Expand Down Expand Up @@ -69,6 +70,9 @@ export function mapToAnswers(
case 'multiSelectRows':
return convertToMatrixMultiSelectAnswer(item);

case 'singleSelectRows':
return convertToMatrixSingleSelectAnswer(item);

default:
return null;
}
Expand Down Expand Up @@ -252,6 +256,16 @@ function convertToMatrixMultiSelectAnswer(
};
}

function convertToMatrixSingleSelectAnswer(item: SingleSelectionRowsItem) {
return {
answer: {
value: item.answer,
text: item.additionalText || null,
},
itemId: item.id,
};
}

export function mapAlerts(items: Array<appletModel.ItemRecord>): Array<AlertDTO> {
const alerts = items.map((item) => {
switch (item.responseType) {
Expand Down

0 comments on commit 1d2a728

Please sign in to comment.