fix(trucks): skip active-site check when PATCH leaves site unchanged

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-15 11:53:32 +08:00
co-authored by Claude Sonnet 5.5
parent 5f1d7a6ed4
commit 17c32ecd04
3 changed files with 24 additions and 1 deletions
+1 -1
View File
@@ -83,7 +83,7 @@ export async function PATCH(request: NextRequest) {
const [before] = await asAdmin(db =>
db.select().from(trucks).where(eq(trucks.id, body.id!)).limit(1)
)
if (set.siteId && !(await activeSiteExists(set.siteId)))
if (set.siteId && set.siteId !== before?.siteId && !(await activeSiteExists(set.siteId)))
return NextResponse.json({ error: 'Site not found or inactive' }, { status: 422 })
try {