Skip to content

Implement email notifications for leave requests and status updates #18

@Dark-Developer93

Description

@Dark-Developer93

Description

Implement email notification functionality for leave requests and status updates using the react-email library. This enhancement will improve communication between employees, supervisors, and HR by sending automated emails for leave requests and their status changes.

Features to Implement

  1. Email notification to supervisor when a leave request is submitted.
  2. Email notification to employee when leave status is updated.
  3. CC HR department on leave status update emails.
  4. Contact form email functionality for the landing page.

Technical Tasks

  1. Install and set up react-email library.
  2. Create email templates for different notification types.
  3. Implement email sending functionality.
  4. Integrate email notifications into existing leave request and update processes.
  5. Create an API route for the contact form email.

File Updates

  1. Create new files:
    • emails/LeaveRequestEmail.tsx
    • emails/LeaveStatusEmail.tsx
    • emails/ContactFormEmail.tsx
    • lib/email.ts
  2. Update existing files:
    • app/(portal)/portal/RequestForm.tsx
    • app/(dashboard)/dashboard/leaves/EditLeave.tsx
    • app/api/send/route.ts (new file for contact form API route)
    • app/page.tsx (update contact form to use new API route)

Implementation Details

  1. Create email templates using react-email components.
  2. Implement sendEmail function in lib/email.ts to handle email sending logic.
  3. Update RequestForm to send email notification when a leave request is submitted.
  4. Update EditLeave to send email notification when leave status is updated, including CC to HR.
  5. Create an API route for the contact form and integrate it with the landing page.

Acceptance Criteria

  • Leave request submissions trigger an email notification to the supervisor.
  • Leave status updates trigger an email notification to the employee.
  • HR is CC'd on all leave status update emails.
  • Contact form on the landing page successfully sends emails.
  • All email templates are responsive and display correctly in various email clients.
  • Email sending errors are properly handled and logged.

Additional Considerations

  • Use environment variables for email configuration (SMTP settings, email addresses).
  • Implement email queue system for better performance and reliability.
  • Add unit tests for email sending functionality.
  • Consider implementing email templates preview functionality for easier development and testing.

Please update the mentioned files and create the new email-related files to fully integrate the email notification functionality across the application.

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions