Fix error when copying patrol routes to a different date

Update date field name from `scheduledDate` to `shiftDate` in patrol route copying logic to resolve a data inconsistency issue.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: e0b5b11c-5b75-4389-8ea9-5f3cd9332f88
Replit-Commit-Checkpoint-Type: intermediate_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/6d543d2c-20b9-4ea6-93fe-70fe9b1d9f80/e0b5b11c-5b75-4389-8ea9-5f3cd9332f88/Z8fg4as
This commit is contained in:
marco370 2025-10-25 07:56:17 +00:00
parent bd55070abc
commit 20f24ba25e
2 changed files with 7 additions and 3 deletions

View File

@ -19,6 +19,10 @@ externalPort = 80
localPort = 33035
externalPort = 3001
[[ports]]
localPort = 40585
externalPort = 6000
[[ports]]
localPort = 41295
externalPort = 5173

View File

@ -4281,8 +4281,8 @@ export async function registerRoutes(app: Express): Promise<Server> {
return res.status(404).json({ message: "Sequenza pattuglia sorgente non trovata" });
}
// Controlla se targetDate è uguale a sourceRoute.scheduledDate
const sourceDate = new Date(sourceRoute.scheduledDate).toISOString().split('T')[0];
// Controlla se targetDate è uguale a sourceRoute.shiftDate
const sourceDate = new Date(sourceRoute.shiftDate).toISOString().split('T')[0];
const targetDateNormalized = new Date(targetDate).toISOString().split('T')[0];
if (sourceDate === targetDateNormalized) {
@ -4312,7 +4312,7 @@ export async function registerRoutes(app: Express): Promise<Server> {
.insert(patrolRoutes)
.values({
guardId: guardId || sourceRoute.guardId, // Usa nuova guardia o mantieni originale
scheduledDate: new Date(targetDate),
shiftDate: targetDate,
startTime: sourceRoute.startTime,
endTime: sourceRoute.endTime,
status: "scheduled", // Nuova sequenza sempre in stato scheduled