All checks were successful
Build and Push Docker Images / docker (push) Successful in 1m5s
- Remove escaped dollar signs in currency displays - Fix percentage calculations (multiply decimal by 100) - Force white text color on mobile for "Your Impact" header - Add comma formatting to currency values (16343.46 → 16,343.46) - Update portfolioColors.js to properly convert Wren API decimal percentages 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
53 lines
1.4 KiB
JavaScript
53 lines
1.4 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) => {
|
|
// Wren API returns percentage as decimal (0.0025 = 0.25%)
|
|
// Convert to percentage and round to 2 decimal places
|
|
let percentageValue;
|
|
if (project.percentage) {
|
|
percentageValue = (project.percentage * 100).toFixed(2);
|
|
} else {
|
|
percentageValue = ((1 / projects.length) * 100).toFixed(2);
|
|
}
|
|
|
|
return {
|
|
name: project.name || 'Unnamed Project',
|
|
type: project.type || 'Carbon Offset',
|
|
percentage: percentageValue,
|
|
color: getProjectColor(index),
|
|
};
|
|
});
|
|
}
|