File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -6,15 +6,18 @@ import { rgbToHex } from ".";
66import { default as d3Extended } from "./d3" ;
77
88const domSeatsToJSON = ( seats : ISeat [ ] ) => {
9+ const seatsFromStore : Record < string , ISeat > = seats . reduce ( ( acc , seat ) => {
10+ acc [ seat . id ] = seat ;
11+ return acc ;
12+ } , { } ) ;
913 return d3Extended . selectAll ( `[${ dataAttributes . elementType } ="${ ElementType . Seat } "]` ) . map ( ( seat ) => {
1014 const id = seat . attr ( "id" ) ;
1115 const square = ( seat . node ( ) as any ) ?. nodeName === "rect" ;
12- const seatFromStore = seats . find ( ( s ) => s . id === id ) ;
1316 return {
1417 id,
1518 x : + seat . attr ( square ? "x" : "cx" ) ,
1619 y : + seat . attr ( square ? "y" : "cy" ) ,
17- label : document . getElementById ( `${ seat . attr ( "id" ) } -label` ) ?. textContent ?? seatFromStore ?. label ,
20+ label : document . getElementById ( `${ seat . attr ( "id" ) } -label` ) ?. textContent ?. trim ( ) || seatsFromStore [ id ] ?. label ,
1821 status : seat . attr ( dataAttributes . status ) ,
1922 category : seat . attr ( dataAttributes . category ) ,
2023 square,
You can’t perform that action at this time.
0 commit comments