Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public async Task SeedAsync(DataSeedContext context)
new() { Name = "Applicant ID", Token = "applicant_id", MapTo = "applicant.unityApplicantId" },
new() { Name = "Requested Amount", Token = "requested_amount", MapTo = "requestedAmount" },
new() { Name = "Recommended Amount", Token = "recommended_amount", MapTo = "recommendedAmount" },
new() { Name = "Unity Application ID", Token = "unity_application_id", MapTo = "unityApplicationId" }
new() { Name = "Unity Application ID", Token = "unity_application_id", MapTo = "unityApplicationId" },
new() { Name = "Today's Date", Token = "today_date", MapTo = "" }
};

try
Expand Down Expand Up @@ -74,9 +75,9 @@ await templateVariablesRepository.InsertAsync(

var emailGroups = new List<EmailGroupDto>
{
new() {Name = "FSB-AP", Description = "This group manages the recipients for PO-related payments, which will be sent to FSB-AP to update contracts and initiate payment creation.",Type = "static"},
new() {Name = "Payments", Description = "This group manages the recipients for payment notifications, such as failures or errors",Type = "static"}
};
new() {Name = "FSB-AP", Description = "This group manages the recipients for PO-related payments, which will be sent to FSB-AP to update contracts and initiate payment creation.",Type = "static"},
new() {Name = "Payments", Description = "This group manages the recipients for payment notifications, such as failures or errors",Type = "static"}
};
try
{
var allGroups = await emailGroupsRepository.GetListAsync();
Expand Down Expand Up @@ -111,4 +112,4 @@ internal class EmailTempateVariableDto
public string Token { get; set; } = string.Empty;
public string MapTo { get; set; } = string.Empty;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -613,14 +613,34 @@
return inputString;
}

const buildTodayDateSpan = () => new Handlebars.SafeString(buildTodayDateHtml());

const buildTodayDateHtml = () => {
const formatted = new Intl.DateTimeFormat('en-CA', {
timeZone: 'America/Vancouver',
year: 'numeric',
month: 'long',
day: 'numeric'
}).format(new Date());
return `<span data-token="today_date">${formatted}</span>`;
};

const refreshTodayDateSpans = (html) => {
if (!html) return html;
return html.replaceAll(
/<span[^>]*data-token="today_date"[^>]*>[\s\S]*?<\/span>/gi,
buildTodayDateHtml()
);
};

function extractTemplateData(apiResponse, mappingConfig) {
const templateData = {};

mappingConfig.forEach(mapping => {
const { token, mapTo } = mapping;

if (!mapTo) {
templateData[token] = ""; // handle empty MapTo
templateData[token] = token === 'today_date' ? buildTodayDateSpan() : "";
return;
}

Expand Down Expand Up @@ -690,15 +710,15 @@
handleDraftChange();
});
editorInstance = editor;
editorInstance.setContent(data.body);
editorInstance.setContent(refreshTodayDateSpans(data.body));
}
});
UIElements.inputEmailTo.val(data.toAddress);
UIElements.inputEmailCC.val(data.cc ? data.cc.replace(/,/g, '; ') : '');
UIElements.inputEmailBCC.val(data.bcc ? data.bcc.replace(/,/g, '; ') : '');
UIElements.inputEmailFrom.val(data.fromAddress);
UIElements.inputEmailSubject.val(data.subject);
UIElements.inputEmailBody.val(data.body);
UIElements.inputEmailBody.val(refreshTodayDateSpans(data.body));

const isDraft = data?.status === 'Draft';
if (isDraft) {
Expand Down
Loading