Update post scheduling to correctly handle date conversions

Correctly parse the `scheduledFor` date string into a Date object to resolve a Zod validation error when creating posts.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: ae4037a0-2a6f-4530-9bac-79b543286bda
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/397bca8c-984f-43ff-841a-10897aeb8140/ae4037a0-2a6f-4530-9bac-79b543286bda/sjuGm8z
This commit is contained in:
michaelschal committed 2025-10-02 13:30:56 +00:00
1 parent a987b53de9
commit 02892686a1
3 files changed
+187

No files matched your search

+5
View File
@@ -445,6 +445,11 @@ export async function registerRoutes(app: Express): Promise<Server> {
const userId = user.id;
const { pageIds, postType, mediaId, ...postFields } = req.body;
// Convert scheduledFor string to Date if provided
if (postFields.scheduledFor && typeof postFields.scheduledFor === 'string') {
postFields.scheduledFor = new Date(postFields.scheduledFor);
}
// Create the post
const postData = insertPostSchema.parse({ ...postFields, userId });
const post = await storage.createPost(postData);