@@ -13,7 +13,7 @@ const getEmailTemplate = (content: string) => `
1313<head>
1414 <meta charset="utf-8">
1515 <meta name="viewport" content="width=device-width, initial-scale=1.0">
16- <title>CodeUnia </title>
16+ <title>Codeunia </title>
1717</head>
1818<body style="margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; background-color: #f5f5f5;">
1919 <table width="100%" cellpadding="0" cellspacing="0" style="background-color: #f5f5f5; padding: 20px;">
@@ -23,7 +23,7 @@ const getEmailTemplate = (content: string) => `
2323 <!-- Header -->
2424 <tr>
2525 <td style="background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%); padding: 30px; text-align: center;">
26- <h1 style="margin: 0; color: #ffffff; font-size: 24px; font-weight: bold;">CodeUnia </h1>
26+ <h1 style="margin: 0; color: #ffffff; font-size: 24px; font-weight: bold;">Codeunia </h1>
2727 </td>
2828 </tr>
2929
@@ -228,6 +228,102 @@ export const getNewCompanyRegistrationNotification = (params: {
228228 }
229229}
230230
231+ // Role change notification email
232+ export const getRoleChangeEmail = ( params : {
233+ memberName : string
234+ companyName : string
235+ oldRole : string
236+ newRole : string
237+ changedBy : string
238+ dashboardUrl : string
239+ } ) => {
240+ const rolePermissions : Record < string , string [ ] > = {
241+ owner : [
242+ 'Full control over company settings' ,
243+ 'Manage all team members and roles' ,
244+ 'Create, edit, and delete all events' ,
245+ 'Access billing and subscription' ,
246+ 'View all analytics and reports'
247+ ] ,
248+ admin : [
249+ 'Create, edit, and publish events' ,
250+ 'Manage team members (except owners)' ,
251+ 'View analytics and reports' ,
252+ 'Manage company profile'
253+ ] ,
254+ editor : [
255+ 'Create and edit draft events' ,
256+ 'View published events' ,
257+ 'View basic analytics'
258+ ] ,
259+ viewer : [
260+ 'View company events' ,
261+ 'View basic analytics' ,
262+ 'Read-only access'
263+ ]
264+ }
265+
266+ const permissions = rolePermissions [ params . newRole . toLowerCase ( ) ] || [ ]
267+
268+ const content = `
269+ <h2 style="margin: 0 0 20px 0; color: #111827; font-size: 20px;">
270+ Your Role Has Been Updated
271+ </h2>
272+
273+ <p style="margin: 0 0 15px 0; color: #374151; font-size: 16px; line-height: 1.5;">
274+ Hi ${ params . memberName } ,
275+ </p>
276+
277+ <p style="margin: 0 0 15px 0; color: #374151; font-size: 16px; line-height: 1.5;">
278+ Your role at <strong>${ params . companyName } </strong> has been updated by ${ params . changedBy } .
279+ </p>
280+
281+ <div style="background-color: #eff6ff; border-left: 4px solid #3b82f6; padding: 15px; margin: 20px 0; border-radius: 4px;">
282+ <table width="100%" cellpadding="0" cellspacing="0">
283+ <tr>
284+ <td style="padding: 8px 0; color: #6b7280; font-size: 14px; width: 120px;">
285+ <strong>Previous Role:</strong>
286+ </td>
287+ <td style="padding: 8px 0; color: #111827; font-size: 14px;">
288+ ${ params . oldRole . charAt ( 0 ) . toUpperCase ( ) + params . oldRole . slice ( 1 ) }
289+ </td>
290+ </tr>
291+ <tr>
292+ <td style="padding: 8px 0; color: #6b7280; font-size: 14px;">
293+ <strong>New Role:</strong>
294+ </td>
295+ <td style="padding: 8px 0; color: #111827; font-size: 14px;">
296+ <span style="background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%); color: white; padding: 4px 12px; border-radius: 4px; font-weight: 600;">
297+ ${ params . newRole . charAt ( 0 ) . toUpperCase ( ) + params . newRole . slice ( 1 ) }
298+ </span>
299+ </td>
300+ </tr>
301+ </table>
302+ </div>
303+
304+ <p style="margin: 0 0 10px 0; color: #374151; font-size: 16px; line-height: 1.5;">
305+ <strong>Your new permissions include:</strong>
306+ </p>
307+
308+ <ul style="margin: 0 0 20px 0; padding-left: 20px; color: #374151; font-size: 14px; line-height: 1.8;">
309+ ${ permissions . map ( perm => `<li>${ perm } </li>` ) . join ( '' ) }
310+ </ul>
311+
312+ <a href="${ params . dashboardUrl } " style="display: inline-block; background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%); color: #ffffff; text-decoration: none; padding: 12px 24px; border-radius: 6px; font-weight: 600; margin-top: 10px;">
313+ Go to Dashboard
314+ </a>
315+
316+ <p style="margin: 20px 0 0 0; color: #6b7280; font-size: 14px; line-height: 1.5;">
317+ If you have questions about your new role or permissions, please contact your team administrator.
318+ </p>
319+ `
320+
321+ return {
322+ subject : `Your role at ${ params . companyName } has been updated` ,
323+ html : getEmailTemplate ( content )
324+ }
325+ }
326+
231327// Send email function using Resend
232328export async function sendCompanyEmail ( params : EmailParams ) {
233329 try {
0 commit comments