Overview
The Reschedule feature provides a one-click solution to reschedule all pending messages in the system. This is useful when you need to reset delivery schedules or adjust timing for all messages at once.Key Features
Bulk Operation
Reschedule all messages with a single click
Real-time Feedback
Toast notifications for success or failure
Simple UI
Minimal interface with a single button
Loading States
Button disables during processing
UI Component
The Rescheduler component is a simple form with a submit button:The button displays a Calendar icon and is disabled while the reschedule operation is in progress.
How It Works
User Clicks the Reschedule Button
The button is located in the header or main navigation area of the application. When clicked, it triggers the form submission.
Server Action is Invoked
The
rescheduleAction calls the server-side reschedule function, which communicates with the backend API.Backend Processing
The backend endpoint
/messages/reschedule processes all pending messages and updates their schedules.Server Action
The reschedule functionality is implemented as a Next.js Server Action:Key Implementation Details
State Management
The component uses React’suseActionState hook for managing form state:
- rescheduleState: Contains the response from the server action
- rescheduleAction: The function to call when submitting the form
- rescheduleIsPending: Boolean indicating if the action is in progress
Loading State
The button is disabled during processing to prevent duplicate submissions:Toast Notifications
Notifications are displayed using the Sonner toast library:The
richColors option provides visually enhanced success/error states.Backend API Endpoint
The frontend communicates with the following backend endpoint:| Endpoint | Method | Purpose |
|---|---|---|
/messages/reschedule | GET | Reschedule all pending messages |
Authentication
All requests require Basic Authentication:Error Handling
The reschedule action handles errors gracefully:- Network Errors: Caught in the try-catch block
- HTTP Errors: Checked via
response.ok - Unknown Errors: Returned with a generic error message
Cache Revalidation
After successful rescheduling, the home page cache is revalidated:Usage Example
Wait for Confirmation
The button will be disabled briefly while processing. A toast notification will appear confirming success or reporting an error.
Best Practices
Use Sparingly
Rescheduling affects all messages. Use this feature carefully.
Check Before Rescheduling
Review the message list before performing a bulk reschedule.
Monitor Notifications
Always wait for the toast notification to confirm operation success.
Verify Results
Check individual messages after rescheduling to ensure expected behavior.
Related Features
- Message Scheduling - Create and manage individual messages
- Person Management - Manage message recipients
Troubleshooting
Reschedule Fails
If the reschedule operation fails:- Check Backend Connectivity: Ensure
BACKEND_URLis correct and the backend is running - Verify Credentials: Confirm
USERNAMEandPASSWORDenvironment variables are set - Check Browser Console: Look for network errors or detailed error messages
- Review Backend Logs: Check the backend API logs for error details
No Feedback After Clicking
If nothing happens after clicking the button:- Check Network Tab: Open browser DevTools and inspect the network request
- Verify Button State: Ensure the button isn’t already disabled
- Check Console Errors: Look for JavaScript errors in the console
- Refresh the Page: Try refreshing and clicking again