Skip to content

Commit

Permalink
[#549] Fix data detail not showing when doesn't have history
Browse files Browse the repository at this point in the history
  • Loading branch information
wayangalihpratama committed Dec 17, 2024
1 parent 50d7a80 commit 3da4e60
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ const QuestionGroupSetting = ({
name={leadingQuestionField}
rules={[
{
required: true,
required: false,
message: "Please select Leading Question",
},
]}
Expand Down
32 changes: 18 additions & 14 deletions frontend/src/pages/data-cleaning/DataDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,21 +159,25 @@ const DataDetail = ({ record }) => {

// Map into the repeat group with repeat_identifier value
let dataSource = [];
history?.forEach((h) => {
const vHistory = v.map((curr) => {
const findAnswerHistory = h?.answer?.find(
(x) =>
x.question === curr.question &&
x.repeat_identifier === curr.repeat_identifier
);
return {
...curr,
[`value_${h.year}`]: findAnswerHistory?.value || "",
[`comment_${h.year}`]: findAnswerHistory?.comment || "",
};
if (history?.length) {
history?.forEach((h) => {
const vHistory = v.map((curr) => {
const findAnswerHistory = h?.answer?.find(
(x) =>
x.question === curr.question &&
x.repeat_identifier === curr.repeat_identifier
);
return {
...curr,
[`value_${h.year}`]: findAnswerHistory?.value || "",
[`comment_${h.year}`]: findAnswerHistory?.comment || "",
};
});
dataSource = [...dataSource, ...vHistory];
});
dataSource = [...dataSource, ...vHistory];
});
} else {
dataSource = [...v];
}

return (
<Space
Expand Down

0 comments on commit 3da4e60

Please # to comment.