Skip to content

Commit fa40455

Browse files
committed
Fix: label extraction with airplane mode
1 parent 84225aa commit fa40455

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/utils/transformer.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
import { ElementType } from "@/components/workspace/elements";
22
import { dataAttributes, selectors } from "@/constants";
33
import { store } from "@/store";
4-
import { ISTKData } from "@/types";
4+
import { ISTKData, ISeat } from "@/types";
55
import { rgbToHex } from ".";
66
import { default as d3Extended } from "./d3";
77

8-
export const domSeatsToJSON = () => {
8+
export const domSeatsToJSON = (seats: ISeat[]) => {
99
return d3Extended.selectAll(`[${dataAttributes.elementType}="${ElementType.Seat}"]`).map((seat) => {
10+
const id = seat.attr("id");
1011
const square = (seat.node() as any)?.nodeName === "rect";
12+
const seatFromStore = seats.find((s) => s.id === id);
1113
return {
12-
id: seat.attr("id"),
14+
id,
1315
x: +seat.attr(square ? "x" : "cx"),
1416
y: +seat.attr(square ? "y" : "cy"),
15-
label: document.getElementById(`${seat.attr("id")}-label`)?.textContent,
17+
label: document.getElementById(`${seat.attr("id")}-label`)?.textContent ?? seatFromStore?.label,
1618
status: seat.attr(dataAttributes.status),
1719
category: seat.attr(dataAttributes.category),
1820
square,
@@ -102,7 +104,7 @@ export const stateToJSON = (): ISTKData => {
102104
name: state.location,
103105
categories: state.categories.slice(1),
104106
sections: state.sections.slice(1),
105-
seats: domSeatsToJSON(),
107+
seats: domSeatsToJSON(state.seats),
106108
text: domTextToJSON(),
107109
shapes: domShapesToJSON(),
108110
polylines: domPolylineToJSON(),

0 commit comments

Comments
 (0)