feat: implement language-based email template selection

Update email worker to select templates based on BillingLocation.tenantEmailLanguage:
- Change default language from 'en' to 'hr' in emailTemplates.ts
- Pass language parameter (location.tenantEmailLanguage || 'hr') to all loadAndRender calls
- Applies to email validation, rent due, and utility bills notifications

Email templates are now automatically selected based on tenant's language preference,
defaulting to Croatian when not specified.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Knee Cola
2025-12-31 11:07:39 +01:00
parent 7bf7f9580f
commit d7abd99448
2 changed files with 5 additions and 5 deletions

View File

@@ -59,7 +59,7 @@ export async function sendVerificationRequests(db: Db, budget: number): Promise<
'ownerName': ownerName,
'location.name': location.name,
'shareId': shareId
});
}, location.tenantEmailLanguage || 'hr');
const success = await sendEmail({
to: location.tenantEmail,
@@ -161,7 +161,7 @@ export async function sendRentDueNotifications(db: Db, budget: number): Promise<
'currency': currency,
'ownerName': ownerName,
'shareId': shareId
});
}, location.tenantEmailLanguage || 'hr');
const success = await sendEmail({
to: location.tenantEmail,
@@ -254,7 +254,7 @@ export async function sendUtilityBillsNotifications(db: Db, budget: number): Pro
'currency': currency,
'ownerName': ownerName,
'shareId': shareId
});
}, location.tenantEmailLanguage || 'hr');
const success = await sendEmail({
to: location.tenantEmail,

View File

@@ -20,7 +20,7 @@ export type TemplateVariables = {
* @param language Language code (default: 'en')
* @returns Template content as string
*/
export function loadTemplate(templateName: string, language: string = 'en'): string {
export function loadTemplate(templateName: string, language: string = 'hr'): string {
const cacheKey = `${templateName}--${language}`;
// Check cache first
@@ -80,7 +80,7 @@ export function renderTemplate(template: string, variables: TemplateVariables):
export function loadAndRender(
templateName: string,
variables: TemplateVariables,
language: string = 'en'
language: string = 'hr'
): string {
const template = loadTemplate(templateName, language);
return renderTemplate(template, variables);