fix: replace template conditionals with simple variable substitution (refs #59)
All checks were successful
Deploy to Staging / Build Images (pull_request) Successful in 3m33s
Deploy to Staging / Deploy to Staging (pull_request) Successful in 39s
Deploy to Staging / Verify Staging (pull_request) Successful in 7s
Deploy to Staging / Notify Staging Ready (pull_request) Successful in 6s
Deploy to Staging / Notify Staging Failure (pull_request) Has been skipped
All checks were successful
Deploy to Staging / Build Images (pull_request) Successful in 3m33s
Deploy to Staging / Deploy to Staging (pull_request) Successful in 39s
Deploy to Staging / Verify Staging (pull_request) Successful in 7s
Deploy to Staging / Notify Staging Ready (pull_request) Successful in 6s
Deploy to Staging / Notify Staging Failure (pull_request) Has been skipped
The TemplateService only supports {{variable}} substitution, not Handlebars-style
conditionals. Changed to use a single {{additionalInfo}} variable that is built
in the service code based on upgrade/downgrade status.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -270,15 +270,22 @@ export class NotificationsService {
|
|||||||
enterprise: 'unlimited',
|
enterprise: 'unlimited',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Build additional info based on change type
|
||||||
|
let additionalInfo = '';
|
||||||
|
if (isDowngrade) {
|
||||||
|
const vehicleLimit = vehicleLimitMap[newTier.toLowerCase()] || '2';
|
||||||
|
additionalInfo = `As a result of this change, you now have access to ${vehicleLimit} vehicles. Any vehicles beyond this limit will be hidden but your data remains safe.`;
|
||||||
|
} else if (isUpgrade) {
|
||||||
|
additionalInfo = `You now have access to all the features included in the ${this.formatTierName(newTier)} tier. Enjoy your enhanced MotoVaultPro experience!`;
|
||||||
|
}
|
||||||
|
|
||||||
const variables = {
|
const variables = {
|
||||||
userName,
|
userName,
|
||||||
changeType,
|
changeType,
|
||||||
previousTier: this.formatTierName(previousTier),
|
previousTier: this.formatTierName(previousTier),
|
||||||
newTier: this.formatTierName(newTier),
|
newTier: this.formatTierName(newTier),
|
||||||
reason: reasonDisplayMap[reason] || reason,
|
reason: reasonDisplayMap[reason] || reason,
|
||||||
isDowngrade: isDowngrade ? 'true' : '',
|
additionalInfo,
|
||||||
isUpgrade: isUpgrade ? 'true' : '',
|
|
||||||
vehicleLimit: vehicleLimitMap[newTier.toLowerCase()] || '2',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const subject = this.templateService.render(template.subject, variables);
|
const subject = this.templateService.render(template.subject, variables);
|
||||||
@@ -436,9 +443,7 @@ export class NotificationsService {
|
|||||||
previousTier: 'Free',
|
previousTier: 'Free',
|
||||||
newTier: 'Pro',
|
newTier: 'Pro',
|
||||||
reason: 'Subscription upgrade',
|
reason: 'Subscription upgrade',
|
||||||
isDowngrade: '',
|
additionalInfo: 'You now have access to all the features included in the Pro tier. Enjoy your enhanced MotoVaultPro experience!',
|
||||||
isUpgrade: 'true',
|
|
||||||
vehicleLimit: '5',
|
|
||||||
};
|
};
|
||||||
default:
|
default:
|
||||||
return baseVariables;
|
return baseVariables;
|
||||||
|
|||||||
@@ -32,19 +32,13 @@ Previous Tier: {{previousTier}}
|
|||||||
New Tier: {{newTier}}
|
New Tier: {{newTier}}
|
||||||
Reason: {{reason}}
|
Reason: {{reason}}
|
||||||
|
|
||||||
{{#if isDowngrade}}
|
{{additionalInfo}}
|
||||||
As a result of this change, you now have access to {{vehicleLimit}} vehicles. Any vehicles beyond this limit will be hidden but your data remains safe.
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{#if isUpgrade}}
|
|
||||||
You now have access to all the features included in the {{newTier}} tier. Enjoy your enhanced MotoVaultPro experience!
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
If you have any questions, please contact support.
|
If you have any questions, please contact support.
|
||||||
|
|
||||||
Best regards,
|
Best regards,
|
||||||
MotoVaultPro Team',
|
MotoVaultPro Team',
|
||||||
'["userName", "changeType", "previousTier", "newTier", "reason", "isDowngrade", "isUpgrade", "vehicleLimit"]',
|
'["userName", "changeType", "previousTier", "newTier", "reason", "additionalInfo"]',
|
||||||
'<!DOCTYPE html>
|
'<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
|||||||
Reference in New Issue
Block a user