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

Dev marshal #5304

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
06cfcfe
Formatting for add new button and layout for email button
milosdes Jun 19, 2024
1769ac6
add opic applicant consent extension html
Jun 19, 2024
e917608
add OIPC insert migration file
Jun 20, 2024
80f4986
Merge pull request #5287 from bcgov/dev-marshal-MD-3968-addnewbutton
sumathi-thirumani Jun 20, 2024
2ae5d59
Merge branch 'dev-marshal-ST-3968' of https://github.com/bcgov/foi-fl…
Jun 20, 2024
b921d83
Merge pull request #5288 from bcgov/dev-marshal-ST-3968
sumathi-thirumani Jun 20, 2024
c56275d
Fix addCorrespondence button colors
milosdes Jun 20, 2024
04e9824
Merge pull request #5290 from bcgov/dev-marshal-MD-3968-addnewbutton
sumathi-thirumani Jun 20, 2024
a955de5
Merge branch 'dev-marshal-ST-3968' of https://github.com/bcgov/foi-fl…
JieunSon96 Jun 20, 2024
e711e8d
Merge pull request #5291 from bcgov/dev-marshal-ST-3968
sumathi-thirumani Jun 21, 2024
84a59ef
Merge branch 'dev-marshal-ST-3968' of https://github.com/bcgov/foi-fl…
JieunSon96 Jun 21, 2024
b338acc
convert template to html
Jun 21, 2024
69c3185
add template name
Jun 21, 2024
7e58161
add migration file
Jun 21, 2024
c648864
fixed alembic revision issue
Jun 21, 2024
eb2c7f5
Merge pull request #5295 from bcgov/dev-marshal-ST-3968
sumathi-thirumani Jun 24, 2024
1ad2b57
changed consent extension file
Jun 25, 2024
25eddf3
Merge branch 'dev-marshal-ST-3968' of https://github.com/bcgov/foi-fl…
Jun 25, 2024
272ec84
Merge branch 'dev-marshal-ST-3968' into origin/dev-marshal-SS-3968
Jun 25, 2024
722b3b0
Merge pull request #5296 from bcgov/dev-marshal-ST-3968
sumathi-thirumani Jun 25, 2024
5b0fa97
Merge pull request #5299 from bcgov/dev-marshal-ST-3968
sumathi-thirumani Jun 26, 2024
dd92402
added functions to fetch template variables
JieunSon96 Jun 27, 2024
9807879
quick changes of the function
JieunSon96 Jun 27, 2024
4044dbe
remove unused revision file
JieunSon96 Jun 27, 2024
04e60a1
change down_revision to recent version
JieunSon96 Jun 27, 2024
8d04058
Merge pull request #5300 from bcgov/origin/dev-marshal-SS-3968
JieunSon96 Jun 27, 2024
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
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
.addCorrespondence {
color: #FFFFFF !important;
color: white !important;
background-color: #38598A !important;
width: 100%;
max-width: 200px;
margin: 0;
font-family: BCSans-Bold, sans-serif !important;
background-color: #38598A !important;
background: linear-gradient(to right, #38598A 80%, white 20%);
.MuiFormLabel-root {
color: #FFFFFF !important;
}
}
.MuiOutlinedInput-root .MuiOutlinedInput-notchedOutline {
border-color: #38598A !important;
}

.previewEmail {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ export const ContactApplicant = ({
</button>
</ConditionalComponent> */}
</Grid>
<Grid item xs={3}>
<Grid container xs={3} direction="row" justifyContent='flex-end'>
<TextField
className="btn addCorrespondence"
color="primary"
Expand Down Expand Up @@ -833,11 +833,10 @@ export const ContactApplicant = ({
<Grid
container
direction="row"
justify="flex-start"
alignItems="flex-start"
justifyContent="flex-end"
spacing={1}
>
<Grid item xs={7}>
<Grid item xs={'auto'}>
</Grid>
<Grid item xs={3}>
<TextField
Expand Down Expand Up @@ -866,7 +865,7 @@ export const ContactApplicant = ({
))}
</TextField>
</Grid>
<Grid item xs={2}>
<Grid item xs={'auto'}>
<CorrespondenceEmail
ministryId={ministryId}
selectedEmails={selectedEmails}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { any } from "prop-types";

export const renderTemplate = (template: string, content: string, params: Array<any>) => {
let newTemplate = template.replace("{{content}}", content);
return applyVariables(newTemplate, params);
Expand All @@ -18,15 +20,20 @@ export const getExtensiondetails = (requestExtensions:any, type: string) => {
if (recentExtension["extensiontype"] === "Public Body" && recentExtension["extensionstatus"] == "Approved") {
return [recentExtension["extendedduedays"], recentExtension["extendedduedate"], recentExtension["extensionreson"]]
} else if (recentExtension["extensiontype"] === "OIPC" && recentExtension["extensionstatus"] == "Approved") {
return [recentExtension["approvednoofdays"], recentExtension["extendedduedate"], recentExtension["extensionreson"]]
return [recentExtension["approvednoofdays"], recentExtension["extendedduedate"], recentExtension["extensionreson"], recentExtension["created_at"], recentExtension["extensionreasonid"], recentExtension["decisiondate"]
]
}
}
return ["","",""]
return ["","","","","",""]
}

export const getTemplateVariables = (requestDetails: any, requestExtensions: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);

return [
{name: "{{axisRequestId}}", value: requestDetails.axisRequestId},
{name: "{{title}}", value: templateInfo?.label || ""},
Expand All @@ -43,6 +50,18 @@ export const getTemplateVariables = (requestDetails: any, requestExtensions:any,
{name: "{{pbExtensionDueDate}}", value: pbExtension[1]},
{name: "{{pbExtensionReason}}", value: pbExtension[2]},
{name: "{{pbExtensionBody}}", value: "public body"},
{name: "{{oipcExtensionDueDays}}", value: oipcExtension[0]},
{name: "{{oipcExtensionDueDates}}", value: oipcExtension[1]},
{name: "{{oipcExtensionReason}}", value: oipcExtension[2]},
{name: "{{oipcExtensionNotiDate}}", value: oipcExtension[5]},
{name: "{{oipcOriginalReceivedDate}}", value: requestDetails.receivedDate},
{name: "{{oipcOriginalDueDate}}", value: requestDetails.originalDueDate},
{name: "{{sectionID}}", value: mapSectionWithExtensionReasonId(oipcExtension[4])},
{name: "{{takenExtensionStatus}}", value: isAlreadyTakenTimeExtension(filteredOutLatestExtensions)},
{name: "{{filteredExtensionDate}}", value: filteredOutLatestExtensions ? filteredOutLatestExtensions.extendedduedate : ""},
{name: "{{filteredExtensionDueDays}}", value: filteredOutLatestExtensions ? filteredOutLatestExtensions.extendedduedays : ""},
{name: "{{oipcComplaintStatus}}", value: oipcComplaintCheck(requestDetails.oipcdetails)},

];

}
Expand All @@ -55,3 +74,44 @@ export const isTemplateDisabled = (currentCFRForm: any, template: any) => {
}
return false
}

// Function to map extension reason id to its textual representation
const mapSectionWithExtensionReasonId = (extensionReasonId: number) => {
switch (extensionReasonId) {
case 6:
return "10(1)(d)"; // 10(1)(d) = Applicant Consent
case 7:
return "10(1)(c)"; // 10(1)(c) = Consultation
case 8:
return "10(1)(a)"; // 10(1)(a) = Further detail from applicant required
case 9:
return "10(1)(b)"; // 10(1)(b) = Large Volume and/or Volume of Search
default:
return "";
}
};

// List of reasons to check already taken a time extension under section 10(1)
const reasonsToCheck = [
"OIPC - Applicant Consent",
"OIPC - Consultation",
"OIPC - Further Detail from Applicant Required",
"OIPC - Large Volume and/or Volume of Search"
];

// Find the record that matches the criteria for already taken a time extension under section 10(1), excluding the most recent record.
const findLatestMatchingTimeExtension = (requestExtensions: any[], reasonsToCheck: string[]): any | null => {
const foundObject = requestExtensions
.filter(extension => extension.extensiontype === "OIPC" && reasonsToCheck.includes(extension.extensionreson) && extension !== requestExtensions[0])
.find(extension => reasonsToCheck.includes(extension.extensionreson)) || null;

return foundObject;
};

// Function to check and return "Yes" or "No"
const isAlreadyTakenTimeExtension = (result: any | null): string => {
return result === null ? "No" : "Yes";
};

// Check if there are any OIPC details.
const oipcComplaintCheck = (oipcdetails: any): string => oipcdetails && oipcdetails.length > 0 ? "Yes" : "No";
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
"""empty message

Revision ID: 8487688c2e35
Revises: c3e447d3d94d
Create Date: 2024-06-20 17:16:09.447577

"""
from alembic import op
from datetime import datetime
import sqlalchemy as sa
from sqlalchemy.sql import column, table
from sqlalchemy.sql.sqltypes import Boolean, String,Text,Integer,DateTime


# revision identifiers, used by Alembic.
revision = '8487688c2e35'
down_revision = 'c3e447d3d94d'
branch_labels = None
depends_on = None


def upgrade():
applicant_correspondence_templates = table('ApplicantCorrespondenceTemplates',
column('name',String),
column('documenturipath',Text),
column('description',String),
column('active',Boolean),
column('display',Boolean),
column('version',Integer),
column('created_at',DateTime),
column('createdby',String),
)
op.bulk_insert(
applicant_correspondence_templates,
[{'name': 'OIPCAPPLICANTCONSENTEXTENSION',
'description': 'OIPC Applicant Consent Time Extension',
'active': True,
'display': True,
'version': 1,
'documenturipath': '/TEMPLATES/EMAILS/oipc_applicant_consent_time_extension.html',
'created_at': datetime.now(),
'createdby': 'system'},
{'name': 'OIPCFIRSTTIMEEXTENSION',
'description': 'OIPC Applicant First Time Extension',
'active': True,
'display': True,
'version': 1,
'documenturipath': '/TEMPLATES/EMAILS/oipc_first_time_extension.html',
'created_at': datetime.now(),
'createdby': 'system'},
{'name': 'OIPCSUBSEQUENTTIMEEXTENSION',
'description': 'OIPC Subsequent Time Extension',
'active': True,
'display': True,
'version': 1,
'documenturipath': '/TEMPLATES/EMAILS/oipc_subsequent_time_extension.html',
'created_at': datetime.now(),
'createdby': 'system'}]
)


def downgrade():
op.execute(
"""
DELETE FROM "ApplicantCorrespondenceTemplates"
WHERE name IN ('OIPCAPPLICANTCONSENTEXTENSION', 'OIPCFIRSTTIMEEXTENSION', 'OIPCSUBSEQUENTTIMEEXTENSION')
"""
)
Loading
Loading