diff --git a/modules/opportunities/client/services/OpportunitiesCommonService.ts b/modules/opportunities/client/services/OpportunitiesCommonService.ts index ef2bb1abc..9062c572c 100644 --- a/modules/opportunities/client/services/OpportunitiesCommonService.ts +++ b/modules/opportunities/client/services/OpportunitiesCommonService.ts @@ -99,19 +99,12 @@ class OpportunitiesCommonService implements IOpportunitiesCommonService { return accum; }, []); - if (opportunity.opportunityTypeCd === 'code-with-us') { - fields.cwu.forEach(elem => { - if (!elem[0]) { - errorFields.push(elem[1]); - } - }); - } else { - fields.swu.forEach(elem => { - if (!elem[0]) { - errorFields.push(elem[1]); - } - }); - } + const fieldSource = opportunity.opportunityTypeCd === 'code-with-us' ? fields.cwu : fields.swu; + fieldSource.forEach((elem: any) => { + if (!elem[0]) { + errorFields.push(elem[1]); + } + }); return errorFields; } diff --git a/modules/opportunities/server/controllers/OpportunitiesServerController.ts b/modules/opportunities/server/controllers/OpportunitiesServerController.ts index cf9f79fb7..084f6a7b7 100644 --- a/modules/opportunities/server/controllers/OpportunitiesServerController.ts +++ b/modules/opportunities/server/controllers/OpportunitiesServerController.ts @@ -576,12 +576,7 @@ class OpportunitiesServerController { zip.folder(opportunityName) .folder(proponentName) .file('index.html', content); - files.forEach(file => { - zip.folder(opportunityName) - .folder(proponentName) - .folder('docs') - .file(file.name, fs.readFileSync(file.path), { binary: true }); - }); + this.addFilesToZip(zip, opportunityName, proponentName, files); }); res.setHeader('Content-Type', 'application/zip'); @@ -703,12 +698,7 @@ class OpportunitiesServerController { zip.folder(opportunityName) .folder(proponentName) .file('proposal-summary.html', content); - files.forEach(file => { - zip.folder(opportunityName) - .folder(proponentName) - .folder('docs') - .file(file.name, fs.readFileSync(file.path), { binary: true }); - }); + this.addFilesToZip(zip, opportunityName, proponentName, files); res.setHeader('Content-Type', 'application/zip'); res.setHeader('Content-Type', 'application/octet-stream'); @@ -1078,6 +1068,15 @@ The opportunity closes on ${deadline}.

.populate('addenda.createdBy', 'displayName') .execPopulate(); }; + + private addFilesToZip(zip: JSZip, opportunityName: string, proponentName: string, files: IAttachmentModel[]): void { + files.forEach(file => { + zip.folder(opportunityName) + .folder(proponentName) + .folder('docs') + .file(file.name, fs.readFileSync(file.path), { binary: true }); + }); + } } export default OpportunitiesServerController.getInstance();