Changelog – September 30, 2025
Email Communication System Implementation
Overview
Implemented comprehensive email communication system using Mailgun for user management workflows.
New Features
1. User Deletion
- Added “Delete User” button to User Management page
- Confirmation dialog to prevent accidental deletions
- Permanently removes user and all associated data
- Useful for cleaning up test accounts and unactivated users
2. Email Integration with Mailgun
- Integrated Mailgun email service using HTTP API
- Created email service utility (
/src/lib/email.ts) - Implemented three types of automated emails:
Email Types:
- Signup Notification (Admin)
- Sent to admin when new user signs up
- Includes user details and link to user management
- Helps admins quickly respond to new signups
- User Invitation Email
- Sent when admin creates a new user account
- Includes assigned stores and login link
- Professional welcome message with HTML formatting
- Account Approval Email
- Sent when admin activates a user account
- Notifies user they can now access the system
- Includes direct login link
Technical Changes
New Files
src/lib/email.ts– Email service with Mailgun integrationEMAIL_SETUP.md– Comprehensive email setup documentationHEROKU_ENV_SETUP.md– Quick reference for Heroku configuration
Modified Files
src/app/api/auth/signup/route.ts– Added admin notification emailsrc/app/api/admin/users/route.ts– Added invitation email on user creationsrc/app/api/users/route.ts– Added approval email when user activatedsrc/app/dashboard/users/page.tsx– Added delete user functionalitypackage.json– Added mailgun.js and form-data dependencies
New Dependencies
mailgun.js– Official Mailgun API clientform-data– Required for mailgun.js
Environment Variables Required
MAILGUN_API_KEY # Provided by Heroku Mailgun addon
MAILGUN_DOMAIN # Provided by Heroku Mailgun addon
MAILGUN_FROM_EMAIL # Set manually: "Deco Order Manager <noreply@domain.com>"
ADMIN_EMAIL # Set manually: admin email for notifications
Setup Instructions
- Install Dependencies:
npm install
- Configure Environment Variables on Heroku:
heroku config:set ADMIN_EMAIL="your-admin@email.com"
heroku config:set MAILGUN_FROM_EMAIL="Deco Order Manager <noreply@yourdomain.com>"
- Verify Mailgun Config:
heroku config | grep MAILGUN
- Deploy:
git add .
git commit -m "Add email communication and user deletion"
git push heroku main
Testing
- Test Signup Email:
- Visit signup page
- Create a test account
- Admin should receive notification email
- Test Invitation Email:
- Log in as admin
- Create a new user
- Check new user’s email inbox
- Test Approval Email:
- Log in as admin
- Activate a pending user
- Check user’s email inbox
- Test User Deletion:
- Log in as admin
- Go to User Management
- Click “Delete User” on a test account
- Confirm deletion
Important Notes
- Emails are sent asynchronously and won’t block user operations
- Email failures are logged but don’t prevent user operations
- Mailgun sandbox domains require recipient authorization
- For production, verify a custom domain in Mailgun
- All emails include both HTML and plain text versions
Benefits
- Better User Experience:
- Users know when their account is approved
- New users receive proper onboarding
- Clear communication at each step
- Improved Admin Workflow:
- Instant notifications of new signups
- Automated invitation emails save time
- No manual communication needed
- Professional Image:
- Branded email templates
- Timely automated responses
- Consistent communication
Additional Updates (Later in Day)
3. Mailgun Production Upgrade
- Upgraded Mailgun from sandbox to production plan (50k emails/month)
- Fixed email delivery issues by removing sandbox restrictions
- Now supports sending to any email address
4. Password Reset/Set Functionality
- Implemented
/api/auth/reset-passwordendpoint - Created
/set-passwordpage for users to set/reset passwords - Added “Forgot Password” link on login page
- Includes password strength validation (12+ chars, uppercase, special char)
5. User Invitation Workflow Simplification
- Changed from creating accounts to sending invitation emails
- Users now sign up normally with their own password
- Simplified “Add User” dialog – only requires email address
- Users fill in name, password, store name during their own signup
- More secure and less admin overhead
6. UI/UX Improvements
- Fixed table hover states for both light and dark modes
- Updated email branding from “Deco Order Manager” to “Orchard Street Press – Store Manager”
- Improved invitation email content and formatting
- Added proper CSS context awareness for theme switching
7. Bug Fixes
- Fixed syntax error in users table component
- Resolved build failures from missing imports
- Fixed email domain configuration issues
- Corrected table hover visibility in dark mode
Technical Files Updated
src/app/api/auth/reset-password/route.ts– New password reset endpointsrc/app/set-password/page.tsx– New password setting pagesrc/app/page.tsx– Added “Forgot Password” linksrc/app/globals.css– Fixed table hover for both themessrc/lib/email.ts– Updated branding and invitation workflowsrc/app/dashboard/users/page.tsx– Simplified user creation dialog
Current Status
✅ Email system fully functional with production Mailgun
✅ Password reset/set functionality working
✅ User invitation workflow streamlined
✅ UI hover states fixed for all themes
✅ Branding consistent across login and emails
✅ All build errors resolved
Next Steps (Optional Enhancements)
- Store assignment notification emails
- Order status notification emails
- Weekly summary emails for admins
- Email template customization interface
