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

[FOIMOD-2479] Updated Template Display Based on Latest Extension #5317

Merged
merged 6 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,4 @@ datamigrations/FOIMOD.CFD.ConsoleApp.DocMigration/FOIMOD.CFD.DocMigration.OCR/bi
datamigrations/FOIMOD.CFD.ConsoleApp.DocMigration/FOIMOD.CFD.DocMigration.OCR.Tests/obj/*
datamigrations/FOIMOD.CFD.ConsoleApp.DocMigration/FOIMOD.CFD.DocMigration.OCR.Tests/bin/*
/datamigrations/FOIMOD.CFD.ConsoleApp.DocMigration/FOIMOD.CFD.DocMigration.Utils.UnitTests/appsettings.dev.json

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export const PreviewModal = React.memo(({
//gets the request detail from the store
const requestDetails: any = useSelector((state: any) => state.foiRequests.foiRequestDetail);
const requestExtensions: any = useSelector((state: any) => state.foiRequests.foiRequestExtesions);

const responsePackagePdfStitchStatus = useSelector((state: any) => state.foiRequests.foiPDFStitchStatusForResponsePackage);
const cfrFeeData = useSelector((state: any) => state.foiRequests.foiRequestCFRFormHistory);

//get template
const rootpath = OSS_S3_BUCKET_FULL_PATH
const templatePath = "/TEMPLATES/EMAILS/header_footer_template.html";
Expand All @@ -53,7 +55,7 @@ export const PreviewModal = React.memo(({
});
}, []);
requestDetails["ffaurl"] = FOI_FFA_URL;
const templateVariables = getTemplateVariables(requestDetails, requestExtensions, templateInfo);
const templateVariables = getTemplateVariables(requestDetails, requestExtensions, responsePackagePdfStitchStatus, cfrFeeData, templateInfo);
const handleSend = () => {
handleSave( applyVariables(innerhtml, templateVariables) );
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ export const ContactApplicant = ({
const dispatch = useDispatch();
const currentCFRForm: any = useSelector((state: any) => state.foiRequests.foiRequestCFRForm);
const isLoading: boolean = useSelector((state: any) => state.foiRequests.isCorrespondenceLoading);
const responsePackagePdfStitchStatus = useSelector((state: any) => state.foiRequests.foiPDFStitchStatusForResponsePackage);
const check: any = useSelector((state: any) => state.foiRequests);
const cfrFeeData = useSelector((state: any) => state.foiRequests.foiRequestCFRFormHistory);
const fullNameList = getFullnameList()

const getFullname = (userid: string) => {
Expand Down Expand Up @@ -271,15 +274,15 @@ export const ContactApplicant = ({

const handleTemplateChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setCurrentTemplate(+e.target.value)
const templateVariables = getTemplateVariables(requestDetails, requestExtensions, templates[+e.target.value]);
const templateVariables = getTemplateVariables(requestDetails, requestExtensions, responsePackagePdfStitchStatus, cfrFeeData, templates[+e.target.value]);
const finalTemplate = applyVariables(templates[+e.target.value].text || "", templateVariables);
setEditorValue(finalTemplate)
}

//When templates are selected from list
const handleTemplateSelection = (index: number) => {
setCurrentTemplate(index);
const templateVariables = getTemplateVariables(requestDetails,requestExtensions, templates[index]);
const templateVariables = getTemplateVariables(requestDetails,requestExtensions, responsePackagePdfStitchStatus, cfrFeeData, templates[index]);
const finalTemplate = applyVariables(templates[index].text || "", templateVariables);
setEditorValue(finalTemplate);
changeCorrespondenceFilter("log");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,29 @@ export const getExtensiondetails = (requestExtensions:any, type: string) => {
}

export const getExtensionType = (requestExtensions: any) => {
let oipcExtension = getExtensiondetails(requestExtensions, "OIPC");
let pbExtension = getExtensiondetails(requestExtensions, "Public Body");
return pbExtension[0] ? "PB" : oipcExtension[0] ? "OIPC" : "NA";
if (!requestExtensions || requestExtensions.length === 0) {
return "NA";
}

// Get the type of the latest extension
let latestExtension = requestExtensions[0];
return latestExtension["extensiontype"] === "Public Body" ? "PB" : "OIPC";
}

export const getTemplateVariables = (requestDetails: any, requestExtensions:any, templateInfo: any) => {
export const getTemplateVariables = (requestDetails: any, requestExtensions:any, responsePackagePdfStitchStatus:any, cfrFeeData:any, templateInfo: any) => {
let oipcExtension = getExtensiondetails(requestExtensions, "OIPC");
let pbExtension = getExtensiondetails(requestExtensions, "Public Body");

// Find the record that matches the criteria for already taken a time extension under section 10(1), excluding the most recent record
const filteredOutLatestExtensions = findLatestMatchingTimeExtension(requestExtensions, reasonsToCheck);

const checkFinalPackage = checkRecordReleased(responsePackagePdfStitchStatus)

const [feeEstimateStatus, feeEstimateDate] = getFeeEstimateInfo(cfrFeeData);
const fullFeePaidDate = getFullFeePaidDate(cfrFeeData);

const feeWaiverDecisionDate = getFeeWaiverDecisionDate(cfrFeeData);

return [
{name: "{{axisRequestId}}", value: requestDetails.axisRequestId},
{name: "{{title}}", value: templateInfo?.label || ""},
Expand Down Expand Up @@ -72,6 +83,11 @@ export const getTemplateVariables = (requestDetails: any, requestExtensions:any,
{name: "{{filteredExtensionDate}}", value: filteredOutLatestExtensions ? filteredOutLatestExtensions.extendedduedate : ""},
{name: "{{filteredExtensionDueDays}}", value: filteredOutLatestExtensions ? filteredOutLatestExtensions.extendedduedays : ""},
{name: "{{oipcComplaintStatus}}", value: oipcComplaintCheck(requestDetails.oipcdetails)},
{name: "{{finalPackageStatus}}", value: checkFinalPackage},
{name: "{{feeEstimateStatus}}", value: feeEstimateStatus},
{name: "{{feeEstimateDate}}", value: feeEstimateDate},
{name: "{{fullFeePaidDate}}", value: getFullFeePaidDate(cfrFeeData)},
{name: "{{feeWaiverDecisionDate}}", value: getFeeWaiverDecisionDate(cfrFeeData)},
];

}
Expand Down Expand Up @@ -153,3 +169,41 @@ const isAlreadyTakenTimeExtension = (result: any | null): string => {
// Check if there are any OIPC details.
const oipcComplaintCheck = (oipcdetails: any): string => oipcdetails && oipcdetails.length > 0 ? "Yes" : "No";


// Function to check record release status
const checkRecordReleased = (status: string): string => { return status === "completed" ? "Yes" : "No"; };

// Function to check fee estimate and get the created_at date for a specific condition
const getFeeEstimateInfo = (data: any[]): [string, string] => {
const result = data.find(
item => item["cfrfeestatus.description"] === "Approved" && item.feedata.estimatedtotaldue > 0
);

const status = result ? "Yes" : "No";
const date = result ? result.created_at : "";

return [status, date];
};

// Function to get the created_at date when the full fee is paid
const getFullFeePaidDate = (data: any[]): string => {
const result = data.find(
item =>
item["cfrfeestatus.description"] === "Approved" &&
item.feedata.balanceremaining <= 0 &&
item.feedata.actualtotaldue <= 0
);

return result ? result.created_at : "";
};

// Function to get the created_at date when feewaiveramount is greater than 0 and status is Approved
const getFeeWaiverDecisionDate = (data: any[]): string => {
const result = data.find(
item =>
item["cfrfeestatus.description"] === "Approved" &&
item.feedata.feewaiveramount > 0
);

return result ? result.created_at : "";
};

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
<p class="Paragraph SCXW30742554 BCX0" style="-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text; overflow-wrap: break-word; white-space: pre-wrap; font-weight: normal; font-style: normal; vertical-align: baseline; font-kerning: none; background-color: transparent; color: windowtext; text-align: left; text-indent: 0px;"><span class="EOP SCXW30742554 BCX0" data-ccp-props='{"201341983":0,"335559739":0,"335559740":240}' style='-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text; font-size: 10pt; line-height: 18px; font-family: "BC Sans", "BC Sans_EmbeddedFont", "BC Sans_MSFontService", sans-serif;'>&nbsp;</span></p>
</div>
<div class="OutlineElement Ltr SCXW30742554 BCX0" style='-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text; clear: both; cursor: text; overflow: visible; position: relative; direction: ltr; color: rgb(0, 0, 0); font-family: "Segoe UI", "Segoe UI Web", Arial, Verdana, sans-serif; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;'>
<p class="Paragraph SCXW30742554 BCX0" style="-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text; overflow-wrap: break-word; white-space: pre-wrap; font-weight: normal; font-style: normal; vertical-align: baseline; font-kerning: none; background-color: transparent; color: windowtext; text-align: left; text-indent: 0px;"><span data-contrast="auto" lang="EN-CA" class="TextRun SCXW30742554 BCX0" style='-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text; font-variant-ligatures: none !important; font-size: 10pt; line-height: 18px; font-family: "BC Sans", "BC Sans_EmbeddedFont", "BC Sans_MSFontService", sans-serif;'><span class="NormalTextRun SCXW30742554 BCX0" style="-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text;">Have any records been released to the applicant</span><span class="NormalTextRun SCXW30742554 BCX0" style="-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text;">? &nbsp;</span></span><span class="ContentControl SCXW30742554 BCX0" aria-label="Check box content control" style="-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text;"><span data-contrast="auto" lang="EN-CA" class="TextRun SCXW30742554 BCX0" style='-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text; font-variant-ligatures: none !important; font-size: 10pt; line-height: 18px; font-family: "Segoe UI Symbol", "Segoe UI Symbol_EmbeddedFont", "Segoe UI Symbol_MSFontService", sans-serif;'><span class="NormalTextRun SCXW30742554 BCX0" style="-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text;">No</span></span></span><span data-contrast="auto" lang="EN-CA" class="TextRun SCXW30742554 BCX0" style='-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text; font-variant-ligatures: none !important; font-size: 10pt; line-height: 18px; font-family: "BC Sans", "BC Sans_EmbeddedFont", "BC Sans_MSFontService", sans-serif;'><span class="NormalTextRun SCXW30742554 BCX0" style="-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text;"> &nbsp;&nbsp;</span></span><span class="ContentControl SCXW30742554 BCX0" aria-label="Check box content control" style="-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text;"><span data-contrast="auto" lang="EN-CA" class="TextRun SCXW30742554 BCX0" style='-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text; font-variant-ligatures: none !important; font-size: 10pt; line-height: 18px; font-family: "Segoe UI Symbol", "Segoe UI Symbol_EmbeddedFont", "Segoe UI Symbol_MSFontService", sans-serif;'><span class="NormalTextRun SCXW30742554 BCX0" style="-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text;"></span></span></span><span data-contrast="auto" lang="EN-CA" class="TextRun SCXW30742554 BCX0" style='-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text; font-variant-ligatures: none !important; font-size: 10pt; line-height: 18px; font-family: "BC Sans", "BC Sans_EmbeddedFont", "BC Sans_MSFontService", sans-serif;'><span class="NormalTextRun SCXW30742554 BCX0" style="-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text;"></span></span><span class="EOP SCXW30742554 BCX0" data-ccp-props='{"201341983":0,"335559739":0,"335559740":240}' style='-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text; font-size: 10pt; line-height: 18px; font-family: "BC Sans", "BC Sans_EmbeddedFont", "BC Sans_MSFontService", sans-serif;'>&nbsp;</span></p>
<p class="Paragraph SCXW30742554 BCX0" style="-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text; overflow-wrap: break-word; white-space: pre-wrap; font-weight: normal; font-style: normal; vertical-align: baseline; font-kerning: none; background-color: transparent; color: windowtext; text-align: left; text-indent: 0px;"><span data-contrast="auto" lang="EN-CA" class="TextRun SCXW30742554 BCX0" style='-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text; font-variant-ligatures: none !important; font-size: 10pt; line-height: 18px; font-family: "BC Sans", "BC Sans_EmbeddedFont", "BC Sans_MSFontService", sans-serif;'><span class="NormalTextRun SCXW30742554 BCX0" style="-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text;">Have any records been released to the applicant</span><span class="NormalTextRun SCXW30742554 BCX0" style="-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text;">? &nbsp;</span></span><span class="ContentControl SCXW30742554 BCX0" aria-label="Check box content control" style="-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text;"><span data-contrast="auto" lang="EN-CA" class="TextRun SCXW30742554 BCX0" style='-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text; font-variant-ligatures: none !important; font-size: 10pt; line-height: 18px; font-family: "Segoe UI Symbol", "Segoe UI Symbol_EmbeddedFont", "Segoe UI Symbol_MSFontService", sans-serif;'><span class="NormalTextRun SCXW30742554 BCX0" style="-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text;">{{finalPackageStatus}}</span></span></span><span data-contrast="auto" lang="EN-CA" class="TextRun SCXW30742554 BCX0" style='-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text; font-variant-ligatures: none !important; font-size: 10pt; line-height: 18px; font-family: "BC Sans", "BC Sans_EmbeddedFont", "BC Sans_MSFontService", sans-serif;'><span class="NormalTextRun SCXW30742554 BCX0" style="-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text;"> &nbsp;&nbsp;</span></span><span class="ContentControl SCXW30742554 BCX0" aria-label="Check box content control" style="-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text;"><span data-contrast="auto" lang="EN-CA" class="TextRun SCXW30742554 BCX0" style='-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text; font-variant-ligatures: none !important; font-size: 10pt; line-height: 18px; font-family: "Segoe UI Symbol", "Segoe UI Symbol_EmbeddedFont", "Segoe UI Symbol_MSFontService", sans-serif;'><span class="NormalTextRun SCXW30742554 BCX0" style="-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text;"></span></span></span><span data-contrast="auto" lang="EN-CA" class="TextRun SCXW30742554 BCX0" style='-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text; font-variant-ligatures: none !important; font-size: 10pt; line-height: 18px; font-family: "BC Sans", "BC Sans_EmbeddedFont", "BC Sans_MSFontService", sans-serif;'><span class="NormalTextRun SCXW30742554 BCX0" style="-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text;"></span></span><span class="EOP SCXW30742554 BCX0" data-ccp-props='{"201341983":0,"335559739":0,"335559740":240}' style='-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text; font-size: 10pt; line-height: 18px; font-family: "BC Sans", "BC Sans_EmbeddedFont", "BC Sans_MSFontService", sans-serif;'>&nbsp;</span></p>
</div>
<div class="OutlineElement Ltr SCXW30742554 BCX0" style='-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text; clear: both; cursor: text; overflow: visible; position: relative; direction: ltr; color: rgb(0, 0, 0); font-family: "Segoe UI", "Segoe UI Web", Arial, Verdana, sans-serif; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;'>
<p class="Paragraph SCXW30742554 BCX0" style="-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text; overflow-wrap: break-word; white-space: pre-wrap; font-weight: normal; font-style: normal; vertical-align: baseline; font-kerning: none; background-color: transparent; color: windowtext; text-align: left; text-indent: 0px;"><span class="EOP SCXW30742554 BCX0" data-ccp-props='{"201341983":0,"335559739":0,"335559740":240}' style='-webkit-user-drag: none; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 0px; user-select: text; font-size: 10pt; line-height: 18px; font-family: "BC Sans", "BC Sans_EmbeddedFont", "BC Sans_MSFontService", sans-serif;'>&nbsp;</span></p>
Expand Down
Loading