![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/lavocat.ca/public_html/scripts/ |
/**
* GENERATE PROFILE AVATARS SCRIPT
* ===============================
*
* Purpose: Generate placeholder profile avatars with initials for ADW Avocats team
*
* What it does:
* 1. Creates SVG avatars with initials for each team member
* 2. Saves them to the public/uploads/profiles directory
* 3. Updates user profiles with the avatar URLs
*
* Usage:
* node scripts/generate-profile-avatars.js
*
* Dependencies:
* - Prisma client
* - fs (for file operations)
* - path (for file paths)
*
* Created: 2024-01-27
*/
const { PrismaClient } = require('@prisma/client');
const fs = require('fs');
const path = require('path');
const prisma = new PrismaClient();
// ADW Avocats team members
const adwTeamMembers = [
{ email: 'justin.wee@adwavocats.com', name: 'Justin Wee', initials: 'JW' },
{ email: 'alain.arsenault@adwavocats.com', name: 'Alain Arsenault', initials: 'AA' },
{ email: 'virginie.dufresne-lemire@adwavocats.com', name: 'Virginie Dufresne-Lemire', initials: 'VD' },
{ email: 'jerome.aucoin@adwavocats.com', name: 'Jérôme Aucoin', initials: 'JA' },
{ email: 'audrey.labrecque@adwavocats.com', name: 'Audrey Labrecque', initials: 'AL' },
{ email: 'ivan.lazarov@adwavocats.com', name: 'Ivan Lazarov', initials: 'IL' },
{ email: 'yalda.machouf-khadir@adwavocats.com', name: 'Yalda Machouf Khadir', initials: 'YM' },
{ email: 'olivia.malenfant@adwavocats.com', name: 'Olivia Malenfant', initials: 'OM' },
{ email: 'imane.melab@adwavocats.com', name: 'Imane Melab', initials: 'IM' },
{ email: 'justine.monty@adwavocats.com', name: 'Justine Monty', initials: 'JM' },
{ email: 'mmah.nora.toure@adwavocats.com', name: 'M\'Mah Nora Touré', initials: 'MT' }
];
function generateSVGAvatar(initials, name) {
// Generate a consistent color based on the name
const colors = [
'#3B82F6', '#EF4444', '#10B981', '#F59E0B', '#8B5CF6',
'#06B6D4', '#84CC16', '#F97316', '#EC4899', '#6366F1'
];
const colorIndex = name.length % colors.length;
const backgroundColor = colors[colorIndex];
return `<svg width="200" height="200" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
<rect width="200" height="200" fill="${backgroundColor}" rx="100"/>
<text x="100" y="120" font-family="Arial, sans-serif" font-size="60" font-weight="bold"
text-anchor="middle" fill="white">${initials}</text>
</svg>`;
}
async function generateProfileAvatars() {
console.log('🎨 Starting profile avatar generation...\n');
const uploadDir = path.join(__dirname, '../public/uploads/profiles');
// Create directory if it doesn't exist
if (!fs.existsSync(uploadDir)) {
fs.mkdirSync(uploadDir, { recursive: true });
}
try {
for (const member of adwTeamMembers) {
console.log(`🎨 Generating avatar for ${member.name}...`);
try {
// Generate filename
const filename = `${member.email.replace('@', '_').replace(/\./g, '_')}.svg`;
const filepath = path.join(uploadDir, filename);
// Generate SVG avatar
const svgContent = generateSVGAvatar(member.initials, member.name);
// Save SVG file
fs.writeFileSync(filepath, svgContent);
// Update user profile in database
const publicUrl = `/uploads/profiles/${filename}`;
await prisma.user.update({
where: { email: member.email },
data: { profilePicture: publicUrl }
});
console.log(` ✅ Successfully created avatar for ${member.name}: ${publicUrl}`);
} catch (error) {
console.log(` ❌ Failed to process ${member.name}: ${error.message}`);
continue;
}
}
console.log('\n🎉 Profile avatar generation completed!');
// Show summary
const usersWithAvatars = await prisma.user.count({
where: {
email: { in: adwTeamMembers.map(m => m.email) },
profilePicture: { not: null }
}
});
console.log(`📊 Summary: ${usersWithAvatars} users now have profile avatars`);
} catch (error) {
console.error('❌ Error during avatar generation:', error);
} finally {
await prisma.$disconnect();
}
}
// Run the script
generateProfileAvatars().catch(console.error);