From 1bbd653d34aafa7cb6af8d8bbd5cac9797ff9cf7 Mon Sep 17 00:00:00 2001 From: Agent Zero Date: Wed, 26 Aug 2026 13:14:34 +0200 Subject: [PATCH] task(B1): unique row/block ids for seating (fixes BUG-1) --- frontend/src/services/seatingService.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/frontend/src/services/seatingService.ts b/frontend/src/services/seatingService.ts index 49fa6bb..7519985 100644 --- a/frontend/src/services/seatingService.ts +++ b/frontend/src/services/seatingService.ts @@ -159,6 +159,13 @@ export const SEATING_TEMPLATES: SeatingTemplate[] = [ }, ]; +let seqCounter = 0; +/** Eindeutige, kollisionsfreie ID mit Präfix (Zeit + Sequenz + Zufall). */ +function nextUid(prefix: string): string { + seqCounter += 1; + return `${prefix}_${Date.now().toString(36)}_${seqCounter.toString(36)}_${Math.random().toString(36).slice(2, 8)}`; +} + export class SeatingService { private generateId(): string { return `el_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`; @@ -189,6 +196,7 @@ export class SeatingService { createSeatingRow(x: number, y: number, layerId: string, config: Partial = {}): CADElement[] { const cfg = { ...DEFAULT_ROW, ...config }; const elements: CADElement[] = []; + const rowId = nextUid('row'); const totalWidth = (cfg.count - 1) * cfg.spacing + cfg.chairWidth; const startX = x - totalWidth / 2 + cfg.chairWidth / 2; @@ -217,7 +225,7 @@ export class SeatingService { outlineColor: '#2a5a99', seatType: 'standard', rowIndex: i, - rowId: `row_${Date.now()}`, + rowId, }, }); } @@ -233,9 +241,10 @@ export class SeatingService { const startX = x - totalW / 2 + cfg.chairWidth / 2; const startY = y - totalH / 2 + cfg.chairHeight / 2; const rot = cfg.rotation * Math.PI / 180; - const blockId = `block_${Date.now()}`; + const blockId = nextUid('block'); for (let row = 0; row < cfg.rows; row++) { + const rowId = nextUid('row'); const offset = cfg.rowOffset * (row % 2); for (let col = 0; col < cfg.cols; col++) { const lx = startX + col * cfg.colSpacing + offset; @@ -263,6 +272,7 @@ export class SeatingService { rowIndex: row, colIndex: col, blockId, + rowId, }, }); }