Establishment dashboard
This commit is contained in:
parent
710a290a68
commit
03f47951e8
@ -68,9 +68,6 @@ exports.getEstablishmentDashboard = async (req, res) => {
|
||||
const quarters = getPrevCurrNextQuarter(today);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const submission_history = await Submission.findAll({
|
||||
where: { establishment_id },
|
||||
order: [["created_at", "DESC"]],
|
||||
@ -131,6 +128,40 @@ exports.getEstablishmentDashboard = async (req, res) => {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
let surveyReady = [];
|
||||
|
||||
const activeQuarters = await QuarterlyWindowsConfiguration.findAll({
|
||||
where: { is_active: true },
|
||||
order: [["created_at", "DESC"]],
|
||||
});
|
||||
|
||||
if (activeQuarters?.length > 0) {
|
||||
|
||||
for (const q of activeQuarters) {
|
||||
|
||||
const submissionMatch = await Submission.findOne({
|
||||
where: {
|
||||
year: q.year,
|
||||
quarter: q.quarter,
|
||||
establishment_id: establishment_id
|
||||
}
|
||||
});
|
||||
|
||||
// if not submitted yet → add for start survey
|
||||
if (!submissionMatch) {
|
||||
surveyReady.push({
|
||||
quarterId: q.id,
|
||||
quarter: q.quarter,
|
||||
start_date: q.start_date,
|
||||
end_date: q.end_date,
|
||||
year: q.year,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
res.status(200).json({
|
||||
status: "success",
|
||||
data: {
|
||||
@ -138,6 +169,7 @@ exports.getEstablishmentDashboard = async (req, res) => {
|
||||
submission_status: submissionStatus,
|
||||
next_deadline: nextDeadline,
|
||||
last_submission: lastSubmissionInfo,
|
||||
survey_ready: surveyReady,
|
||||
submission_history,
|
||||
},
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user