-
Notifications
You must be signed in to change notification settings - Fork 2
feat(newsletter): Add comprehensive newsletter management system #255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Implement admin newsletter page with subscriber management - Create API routes for newsletter subscribers and sending - Add unsubscribe page for newsletter management - Implement subscriber statistics and export functionality - Add tabs for subscribers list and newsletter sending - Include error handling and loading states - Enhance footer with newsletter-related components
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. WalkthroughIntroduces a complete newsletter management system comprising public subscription/unsubscription flows, admin pages for subscriber management and newsletter delivery, and API endpoints for handling subscriptions, sending bulk emails, and retrieving subscriber data with Supabase integration and authentication. Changes
Sequence DiagramssequenceDiagram
actor User
participant Footer
participant API as /api/newsletter
participant Supabase
User->>Footer: Enter email & submit
Footer->>Footer: Validate email format
Footer->>API: POST {email}
API->>API: Normalize email
API->>Supabase: Check existing subscriber
alt Subscriber exists & subscribed
Supabase-->>API: Return subscriber
API-->>Footer: 409 Conflict
Footer->>User: Show error
else Subscriber exists & unsubscribed
Supabase-->>API: Return inactive subscriber
API->>Supabase: Update status to "subscribed"
Supabase-->>API: Success
API-->>Footer: 200 OK
Footer->>User: Show success
else New subscriber
Supabase-->>API: No record
API->>Supabase: Insert new subscriber
Supabase-->>API: 201 Created
API-->>Footer: 201 Created
Footer->>User: Show success
end
sequenceDiagram
actor Admin
participant AdminPage as Admin Page
participant API as /api/admin/newsletter/send
participant Supabase
participant Resend as Resend Service
Admin->>AdminPage: Compose newsletter<br/>(subject + content)
Admin->>AdminPage: Click "Send"
AdminPage->>AdminPage: Validate inputs
AdminPage->>AdminPage: Confirm scope
AdminPage->>API: POST {subject, content}
API->>Supabase: Verify admin auth
Supabase-->>API: ✓ Admin confirmed
API->>Supabase: Fetch subscribed users
Supabase-->>API: Return subscriber list
rect rgb(200, 220, 255)
Note over API,Resend: Batch Processing (50 per batch)
loop For each batch
API->>Resend: Send emails (batch)
Resend-->>API: Success/failure per email
API->>API: Log per-email errors
API->>API: Wait 1 second (rate limit)
end
end
API-->>AdminPage: {total, sent} summary
AdminPage->>Admin: Show result & reset form
sequenceDiagram
actor User
participant UnsubPage as Unsubscribe Page
participant API as /api/newsletter/unsubscribe
participant Supabase
User->>UnsubPage: Click unsubscribe link (with token)
UnsubPage->>UnsubPage: Read token from URL
alt Token missing
UnsubPage->>User: Show error state
else Token present
UnsubPage->>UnsubPage: Show loading state
UnsubPage->>API: POST {token}
API->>Supabase: Update status to "unsubscribed"<br/>WHERE unsubscribe_token = token
alt Update successful
Supabase-->>API: Success
API-->>UnsubPage: 200 OK {message}
UnsubPage->>User: Show success state
else Token not found/already unsubscribed
Supabase-->>API: No rows updated
API-->>UnsubPage: 404 Not Found
UnsubPage->>User: Show error state
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Poem
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (7)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Author: @akshay0611
Summary by CodeRabbit