mirror of
https://github.com/xtr-dev/payload-mailing.git
synced 2025-12-10 16:23:23 +00:00
Fix scheduledAt type in SendEmailTaskInput and add Date normalization
- Update SendEmailTaskInput.scheduledAt to support string | Date types - Add Date object normalization to ISO strings in sendEmail processing - Ensure consistent database storage format for all timestamp fields - Convert Date objects to ISO strings before database operations Resolves remaining "Type Date is not assignable to type string" error for scheduledAt field in job task input. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -100,6 +100,23 @@ export const sendEmail = async <TEmail extends BaseEmailDocument = BaseEmailDocu
|
||||
emailData.from = validated && validated.length > 0 ? validated[0] : undefined
|
||||
}
|
||||
|
||||
// Normalize Date objects to ISO strings for consistent database storage
|
||||
if (emailData.scheduledAt instanceof Date) {
|
||||
emailData.scheduledAt = emailData.scheduledAt.toISOString()
|
||||
}
|
||||
if (emailData.sentAt instanceof Date) {
|
||||
emailData.sentAt = emailData.sentAt.toISOString()
|
||||
}
|
||||
if (emailData.lastAttemptAt instanceof Date) {
|
||||
emailData.lastAttemptAt = emailData.lastAttemptAt.toISOString()
|
||||
}
|
||||
if (emailData.createdAt instanceof Date) {
|
||||
emailData.createdAt = emailData.createdAt.toISOString()
|
||||
}
|
||||
if (emailData.updatedAt instanceof Date) {
|
||||
emailData.updatedAt = emailData.updatedAt.toISOString()
|
||||
}
|
||||
|
||||
// Create the email in the collection with proper typing
|
||||
const email = await payload.create({
|
||||
collection: collectionSlug,
|
||||
|
||||
Reference in New Issue
Block a user