Skip to content

Commit

Permalink
Merge pull request #917 from akvo/feature/916-remove-question-in-expa…
Browse files Browse the repository at this point in the history
…nded-datapoint-answer

[#916] Remove question in expanded datapoint answer
  • Loading branch information
dedenbangkit authored Jan 15, 2024
2 parents 8e1ec9f + 5a16dcb commit 818f290
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 33 deletions.
24 changes: 13 additions & 11 deletions frontend/src/pages/approvals/ApprovalDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -340,17 +340,19 @@ const ApprovalDetail = ({
const data = questionGroups.map((qg) => {
return {
...qg,
question: qg.question.map((q) => {
const findValue = res.data.find(
(d) => d.question === q.id
)?.value;
return {
...q,
value: findValue || findValue === 0 ? findValue : null,
history:
res.data.find((d) => d.question === q.id)?.history || false,
};
}),
question: qg.question
.filter((item) => !item.displayOnly)
.map((q) => {
const findValue = res.data.find(
(d) => d.question === q.id
)?.value;
return {
...q,
value: findValue || findValue === 0 ? findValue : null,
history:
res.data.find((d) => d.question === q.id)?.history || false,
};
}),
};
});
setRawValues((rv) =>
Expand Down
24 changes: 13 additions & 11 deletions frontend/src/pages/manage-data/DataDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,19 @@ const DataDetail = ({
.get(`data/${id}`)
.then((res) => {
const data = questionGroups.map((qg) => {
const question = qg.question.map((q) => {
const findData = res.data.find((d) => d.question === q.id);
return {
...q,
value:
findData?.value || findData?.value === 0
? findData.value
: null,
history: findData?.history || false,
};
});
const question = qg.question
.filter((item) => !item.displayOnly)
.map((q) => {
const findData = res.data.find((d) => d.question === q.id);
return {
...q,
value:
findData?.value || findData?.value === 0
? findData.value
: null,
history: findData?.history || false,
};
});
return {
...qg,
question: question,
Expand Down
25 changes: 14 additions & 11 deletions frontend/src/pages/submissions/BatchDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,20 @@ const BatchDetail = ({ expanded, setReload, deleting, handleDelete }) => {
const data = questionGroups.map((qg) => {
return {
...qg,
question: qg.question.map((q) => {
const findValue = res.data.find(
(d) => d.question === q.id
)?.value;
return {
...q,
value: findValue || findValue === 0 ? findValue : null,
history:
res.data.find((d) => d.question === q.id)?.history || false,
};
}),
question: qg.question
.filter((item) => !item.displayOnly)
.map((q) => {
const findValue = res.data.find(
(d) => d.question === q.id
)?.value;
return {
...q,
value: findValue || findValue === 0 ? findValue : null,
history:
res.data.find((d) => d.question === q.id)?.history ||
false,
};
}),
};
});
setRawValue({ ...expanded, data, loading: false });
Expand Down

0 comments on commit 818f290

Please sign in to comment.