Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add data to camp specific and waiver csv fields #261

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 21 additions & 19 deletions backend/typescript/services/implementations/campService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1253,20 +1253,27 @@ class CampService implements ICampService {
_id: { $in: camp.formQuestions },
});

const campersWithSpecficQuestions: string[] = [];
campers.forEach((camper) => {
camper.formResponses.forEach((value, key) => {
const campQuestion = formQuestionsData.find(
(item) => item.question === key,
);
if (campQuestion?.category === "CampSpecific") {
campersWithSpecficQuestions.push(camper.id);
}
});
});

return await Promise.all(
campers.map(async (camper) => {
let counter = 1;
let campSpecificQuestionsResponse = "";
camper.formResponses.forEach((value, key) => {
const campQuestion = formQuestionsData.find(
(item) => item.question === key,
);
if (campQuestion?.category === "CampSpecific") {
campSpecificQuestionsResponse += `(${counter}) ${key} ${value} `;
counter += 1;
}
});

counter = 1;
let waiverQuestionsResponse = "";
camper.optionalClauses.forEach((optionalClause) => {
waiverQuestionsResponse += `(${counter}) ${optionalClause.clause}: ${optionalClause.agreed} `;
counter += 1;
});

return {
"Registration Date": camper.registrationDate
.toLocaleDateString("en-CA")
Expand All @@ -1292,13 +1299,8 @@ class CampService implements ICampService {
camper.charges.camp +
camper.charges.earlyDropoff +
camper.charges.latePickup,
"Additional Camp-Specific Q's": campersWithSpecficQuestions.includes(
camper.id,
)
? "Y"
: "N",
"Additional Waiver Clauses":
camper.optionalClauses.length > 0 ? "Y" : "N",
"Additional Camp-Specific Q's": campSpecificQuestionsResponse,
"Additional Waiver Clauses": waiverQuestionsResponse,
};
}),
);
Expand Down