puffin-app/server/utils/portfolioColors.js
Matt 7bdd462be9
Some checks failed
Build and Push Docker Images / docker (push) Has been cancelled
Implement comprehensive email templates with SMTP integration
- Add beautiful HTML email templates for receipts, admin notifications, and contact forms
- Implement SMTP email service with Nodemailer and Handlebars templating
- Add carbon equivalency calculations with EPA/DEFRA/IMO 2024 conversion factors
- Add portfolio color palette system for project visualization
- Integrate Wren API portfolio fetching in webhook handler
- Add light mode enforcement for email client compatibility
- Include Puffin logo from MinIO S3 in all templates
- Add test email endpoint for template validation

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-31 20:09:31 +01:00

42 lines
1.1 KiB
JavaScript

/**
* Portfolio Color Palette System
* Ported from frontend src/utils/portfolioColors.ts
*/
export const portfolioColorPalette = [
'#3B82F6', // Blue 500
'#06B6D4', // Cyan 500
'#10B981', // Green 500
'#14B8A6', // Teal 500
'#8B5CF6', // Violet 500
'#6366F1', // Indigo 500
'#0EA5E9', // Sky 500
'#22C55E', // Green 400
'#84CC16', // Lime 500
'#F59E0B', // Amber 500
'#EC4899', // Pink 500
'#EF4444', // Red 500
];
export function getProjectColor(index) {
return portfolioColorPalette[index % portfolioColorPalette.length];
}
/**
* Add colors and formatted percentages to portfolio projects
* @param {Array} projects - Portfolio projects from Wren API
* @returns {Array} Projects with color and percentage added
*/
export function formatPortfolioProjects(projects) {
if (!projects || !Array.isArray(projects)) {
return [];
}
return projects.map((project, index) => ({
name: project.name || 'Unnamed Project',
type: project.type || 'Carbon Offset',
percentage: project.percentage || Math.round((1 / projects.length) * 100),
color: getProjectColor(index),
}));
}