Skip to content

Commit

Permalink
Merge pull request #589 from bcgov/ccfri-3971-document-upload-bugs
Browse files Browse the repository at this point in the history
CCFRI-3971 - Change Notification Form document upload bug fix
  • Loading branch information
vietle-cgi authored Dec 2, 2024
2 parents 1662fe2 + 9cc5874 commit 51eecf3
Show file tree
Hide file tree
Showing 16 changed files with 463 additions and 450 deletions.
24 changes: 22 additions & 2 deletions backend/src/components/document.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use strict';
const { cloneDeep } = require('lodash');
const { MappableObjectForFront, MappableObjectForBack } = require('../util/mapping/MappableObject');
const { ApplicationDocumentsMappings, DocumentsMappings } = require('../util/mapping/Mappings');
const { postApplicationDocument, getApplicationDocument, deleteDocument, patchOperationWithObjectId } = require('./utils');
const { postApplicationDocument, postChangeActionDocument, getApplicationDocument, deleteDocument, patchOperationWithObjectId } = require('./utils');
const HttpStatus = require('http-status-codes');
const log = require('./logger');

Expand All @@ -20,7 +21,25 @@ async function createApplicationDocuments(req, res) {
}
await postApplicationDocument(payload);
}
return res.sendStatus(HttpStatus.OK);
return res.status(HttpStatus.CREATED).json();
} catch (e) {
log.error(e);
return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json(e.data ? e.data : e?.status);
}
}

async function createChangeActionDocuments(req, res) {
try {
const documents = req.body;
for (let document of documents) {
let documentClone = cloneDeep(document);
if (getFileExtension(documentClone.filename) === 'heic') {
log.verbose(`createChangeActionDocuments :: heic detected for file name ${documentClone.filename} starting conversion`);
documentClone = await convertHeicDocumentToJpg(documentClone);
}
await postChangeActionDocument(documentClone);
}
return res.status(HttpStatus.CREATED).json();
} catch (e) {
log.error(e);
return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json(e.data ? e.data : e?.status);
Expand Down Expand Up @@ -67,6 +86,7 @@ async function deleteDocuments(req, res) {

module.exports = {
createApplicationDocuments,
createChangeActionDocuments,
getApplicationDocuments,
updateDocument,
deleteDocuments,
Expand Down
4 changes: 3 additions & 1 deletion backend/src/routes/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ const router = express.Router();
const auth = require('../components/auth');
const { param, validationResult } = require('express-validator');
const isValidBackendToken = auth.isValidBackendToken();
const { createApplicationDocuments, getApplicationDocuments, deleteDocuments, updateDocument } = require('../components/document');
const { createApplicationDocuments, createChangeActionDocuments, getApplicationDocuments, deleteDocuments, updateDocument } = require('../components/document');

module.exports = router;

router.post('/application/', passport.authenticate('jwt', { session: false }), isValidBackendToken, createApplicationDocuments);

router.post('/change-action/', passport.authenticate('jwt', { session: false }), isValidBackendToken, createChangeActionDocuments);

router.get(
'/application/:applicationId',
passport.authenticate('jwt', { session: false }),
Expand Down
19 changes: 19 additions & 0 deletions frontend/public/styles/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,22 @@ input[type="number"] {
.error-message {
color: #ff5252;
}

.add-file-button {
font-size: 16px;
}

.border-right {
border-right: 0.5px solid lightgray;
}

.border-bottom {
border-bottom: 0.5px solid lightgray;
}

.card-title {
color: #003466;
font-size: 20px;
font-weight: bold;
background-color: #e5e4e4;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="text-h5">
Child Care Operating Funding Program - {{ formattedProgramYear }} Program Confirmation Form
</div>
<div class="text-h5 mt-6"><strong>Approvable Fee Schedule</strong></div>
<div class="text-h5 my-6"><strong>Approvable Fee Schedule</strong></div>
</div>
<FacilityHeader
v-if="currentFacility"
Expand Down
Loading

0 comments on commit 51eecf3

Please sign in to comment.