diff --git a/app/client/src/features/licences/LicenceDetailsEdit.jsx b/app/client/src/features/licences/LicenceDetailsEdit.jsx index de820f8..089e5d6 100644 --- a/app/client/src/features/licences/LicenceDetailsEdit.jsx +++ b/app/client/src/features/licences/LicenceDetailsEdit.jsx @@ -177,7 +177,7 @@ export default function LicenceDetailsEdit({ }; const editPhone = () => { - // The watch doesnt seem to be updated when adding the initial entry to phone numbers + // The watch doesn't seem to be updated when adding the initial entry to phone numbers // So manually set the key here let selectedKey = watchPhoneKey; if (!selectedKey || selectedKey.length === 0) { diff --git a/app/server/routes/v1/documents.js b/app/server/routes/v1/documents.js index c9bcd8e..84bb8ed 100644 --- a/app/server/routes/v1/documents.js +++ b/app/server/routes/v1/documents.js @@ -291,98 +291,99 @@ async function generateCertificate(documentId) { const template = templateBuffers.find( (x) => x.templateFileName === templateFileName ); - // check if certificate is CARD (3 templates), if so, split into two arrays - if ( - document.document_type === "CARD" && - (document.licence_type === "BULK TANK MILK GRADER" || - document.licence_type === "LIVESTOCK DEALER" || - document.licence_type === "LIVESTOCK DEALER AGENT") - ) { - /** - * The Card templates have a table that is 2 columns by N rows, this function effectively combines - * those two columns into one so that we don't have to deal with bi-directional looping - * (which cdogs doesn't support yet) */ - - function combineEntries(licenceType, documentJson) { - let combinedJson = []; - switch (licenceType) { - case "BULK TANK MILK GRADER": - for (let i = 0; i < documentJson.length; i += 2) { - let combinedEntry = { ...documentJson[i] }; - if (documentJson[i + 1]) { - combinedEntry.LicenceHolderName2 = - documentJson[i + 1].LicenceHolderName; - combinedEntry.LicenceHolderCompany2 = - documentJson[i + 1].LicenceHolderCompany; - combinedEntry.LicenceNumber2 = documentJson[i + 1].LicenceNumber; - combinedEntry.ExpiryDate2 = documentJson[i + 1].ExpiryDate; - combinedEntry.CardLabel2 = documentJson[i + 1].CardLabel; - } else { - combinedEntry.LicenceHolderName2 = null; - combinedEntry.LicenceHolderCompany2 = null; - combinedEntry.LicenceNumber2 = null; - combinedEntry.ExpiryDate2 = null; - combinedEntry.CardLabel2 = null; - } - combinedJson.push(combinedEntry); - } - return combinedJson; - case "LIVESTOCK DEALER AGENT": - for (let i = 0; i < documentJson.length; i += 2) { - let combinedEntry = { ...documentJson[i] }; - if (documentJson[i + 1]) { - combinedEntry.CardType2 = documentJson[i + 1].CardType; - combinedEntry.LicenceHolderName2 = - documentJson[i + 1].LicenceHolderName; - combinedEntry.LastFirstName2 = documentJson[i + 1].LastFirstName; - combinedEntry.AgentFor2 = documentJson[i + 1].AgentFor; - combinedEntry.LicenceNumber2 = documentJson[i + 1].LicenceNumber; - combinedEntry.StartDate2 = documentJson[i + 1].StartDate; - combinedEntry.ExpiryDate2 = documentJson[i + 1].ExpiryDate; - } else { - combinedEntry.CardType2 = null; - combinedEntry.LicenceHolderName2 = null; - combinedEntry.LastFirstName2 = null; - combinedEntry.AgentFor2 = null; - combinedEntry.LicenceNumber2 = null; - combinedEntry.StartDate2 = null; - combinedEntry.ExpiryDate2 = null; - } - combinedJson.push(combinedEntry); - } - return combinedJson; - case "LIVESTOCK DEALER": - for (let i = 0; i < documentJson.length; i += 2) { - let combinedEntry = { ...documentJson[i] }; - if (documentJson[i + 1]) { - combinedEntry.CardType2 = documentJson[i + 1].CardType; - combinedEntry.LicenceHolderCompany2 = - documentJson[i + 1].LicenceHolderCompany; - combinedEntry.LicenceNumber2 = documentJson[i + 1].LicenceNumber; - combinedEntry.StartDate2 = documentJson[i + 1].StartDate; - combinedEntry.ExpiryDate2 = documentJson[i + 1].ExpiryDate; - } else { - combinedEntry.CardType2 = null; - combinedEntry.LicenceHolderCompany2 = null; - combinedEntry.LicenceNumber2 = null; - combinedEntry.StartDate2 = null; - combinedEntry.ExpiryDate2 = null; - } - combinedJson.push(combinedEntry); - } - return combinedJson; - default: - return null; - } - } - - let updatedJson = combineEntries( - document.licence_type, - document.document_json - ); - - document.document_json = updatedJson; - } + // MALS2-6 to re-apply this, uncomment this code and use the 3 updated templates + // // check if certificate is CARD (3 templates), if so, split into two arrays + // if ( + // document.document_type === "CARD" && + // (document.licence_type === "BULK TANK MILK GRADER" || + // document.licence_type === "LIVESTOCK DEALER" || + // document.licence_type === "LIVESTOCK DEALER AGENT") + // ) { + // /** + // * The Card templates have a table that is 2 columns by N rows, this function effectively combines + // * those two columns into one so that we don't have to deal with bi-directional looping + // * (which cdogs doesn't support yet) */ + + // function combineEntries(licenceType, documentJson) { + // let combinedJson = []; + // switch (licenceType) { + // case "BULK TANK MILK GRADER": + // for (let i = 0; i < documentJson.length; i += 2) { + // let combinedEntry = { ...documentJson[i] }; + // if (documentJson[i + 1]) { + // combinedEntry.LicenceHolderName2 = + // documentJson[i + 1].LicenceHolderName; + // combinedEntry.LicenceHolderCompany2 = + // documentJson[i + 1].LicenceHolderCompany; + // combinedEntry.LicenceNumber2 = documentJson[i + 1].LicenceNumber; + // combinedEntry.ExpiryDate2 = documentJson[i + 1].ExpiryDate; + // combinedEntry.CardLabel2 = documentJson[i + 1].CardLabel; + // } else { + // combinedEntry.LicenceHolderName2 = null; + // combinedEntry.LicenceHolderCompany2 = null; + // combinedEntry.LicenceNumber2 = null; + // combinedEntry.ExpiryDate2 = null; + // combinedEntry.CardLabel2 = null; + // } + // combinedJson.push(combinedEntry); + // } + // return combinedJson; + // case "LIVESTOCK DEALER AGENT": + // for (let i = 0; i < documentJson.length; i += 2) { + // let combinedEntry = { ...documentJson[i] }; + // if (documentJson[i + 1]) { + // combinedEntry.CardType2 = documentJson[i + 1].CardType; + // combinedEntry.LicenceHolderName2 = + // documentJson[i + 1].LicenceHolderName; + // combinedEntry.LastFirstName2 = documentJson[i + 1].LastFirstName; + // combinedEntry.AgentFor2 = documentJson[i + 1].AgentFor; + // combinedEntry.LicenceNumber2 = documentJson[i + 1].LicenceNumber; + // combinedEntry.StartDate2 = documentJson[i + 1].StartDate; + // combinedEntry.ExpiryDate2 = documentJson[i + 1].ExpiryDate; + // } else { + // combinedEntry.CardType2 = null; + // combinedEntry.LicenceHolderName2 = null; + // combinedEntry.LastFirstName2 = null; + // combinedEntry.AgentFor2 = null; + // combinedEntry.LicenceNumber2 = null; + // combinedEntry.StartDate2 = null; + // combinedEntry.ExpiryDate2 = null; + // } + // combinedJson.push(combinedEntry); + // } + // return combinedJson; + // case "LIVESTOCK DEALER": + // for (let i = 0; i < documentJson.length; i += 2) { + // let combinedEntry = { ...documentJson[i] }; + // if (documentJson[i + 1]) { + // combinedEntry.CardType2 = documentJson[i + 1].CardType; + // combinedEntry.LicenceHolderCompany2 = + // documentJson[i + 1].LicenceHolderCompany; + // combinedEntry.LicenceNumber2 = documentJson[i + 1].LicenceNumber; + // combinedEntry.StartDate2 = documentJson[i + 1].StartDate; + // combinedEntry.ExpiryDate2 = documentJson[i + 1].ExpiryDate; + // } else { + // combinedEntry.CardType2 = null; + // combinedEntry.LicenceHolderCompany2 = null; + // combinedEntry.LicenceNumber2 = null; + // combinedEntry.StartDate2 = null; + // combinedEntry.ExpiryDate2 = null; + // } + // combinedJson.push(combinedEntry); + // } + // return combinedJson; + // default: + // return null; + // } + // } + + // let updatedJson = combineEntries( + // document.licence_type, + // document.document_json + // ); + + // document.document_json = updatedJson; + // } const generate = async () => { const { data, status } = await cdogs.post( diff --git a/app/server/static/templates/certificates/Bulk-Tank-Milk-Grader-Card.docx b/app/server/static/templates/certificates/Bulk-Tank-Milk-Grader-Card.docx index 3a16c90..cc21831 100644 Binary files a/app/server/static/templates/certificates/Bulk-Tank-Milk-Grader-Card.docx and b/app/server/static/templates/certificates/Bulk-Tank-Milk-Grader-Card.docx differ diff --git a/app/server/static/templates/certificates/Livestock-Dealer-Agent-Card.docx b/app/server/static/templates/certificates/Livestock-Dealer-Agent-Card.docx index dbda3b0..d812fae 100644 Binary files a/app/server/static/templates/certificates/Livestock-Dealer-Agent-Card.docx and b/app/server/static/templates/certificates/Livestock-Dealer-Agent-Card.docx differ diff --git a/app/server/static/templates/certificates/Livestock-Dealer-Card.docx b/app/server/static/templates/certificates/Livestock-Dealer-Card.docx index 78807f8..2782151 100644 Binary files a/app/server/static/templates/certificates/Livestock-Dealer-Card.docx and b/app/server/static/templates/certificates/Livestock-Dealer-Card.docx differ