feat(wds): add manual sync trigger button with force-run mode
- triggerForceSync() resets error steps, clears lastSessionDate, starts sync immediately - Force mode uses extended night window (22:00-05:00) instead of weekend-only - API action 'trigger' starts sync in background, returns immediately - 'Porneste sync' button in header (hidden when already running) - Respects __parcelSyncRunning guard to prevent concurrent runs Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import { PrismaClient, Prisma } from "@prisma/client";
|
||||
import {
|
||||
isWeekendWindow,
|
||||
getWeekendSyncActivity,
|
||||
triggerForceSync,
|
||||
} from "@/modules/parcel-sync/services/weekend-deep-sync";
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
@@ -151,13 +152,25 @@ export async function GET() {
|
||||
export async function POST(request: Request) {
|
||||
// Auth handled by middleware (route is not excluded)
|
||||
const body = (await request.json()) as {
|
||||
action: "add" | "remove" | "reset" | "reset_all" | "set_priority";
|
||||
action: "add" | "remove" | "reset" | "reset_all" | "set_priority" | "trigger";
|
||||
siruta?: string;
|
||||
name?: string;
|
||||
county?: string;
|
||||
priority?: number;
|
||||
};
|
||||
|
||||
// Trigger is handled separately — starts sync immediately
|
||||
if (body.action === "trigger") {
|
||||
const result = await triggerForceSync();
|
||||
if (!result.started) {
|
||||
return NextResponse.json(
|
||||
{ error: result.reason },
|
||||
{ status: 409 },
|
||||
);
|
||||
}
|
||||
return NextResponse.json({ ok: true, message: "Sincronizare pornita" });
|
||||
}
|
||||
|
||||
const state = await getOrCreateState();
|
||||
|
||||
switch (body.action) {
|
||||
|
||||
Reference in New Issue
Block a user