Skip to content

Commit 42c94e1

Browse files
committed
Fix: section transformer
1 parent 942b0fb commit 42c94e1

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/store/reducers/editor/index.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ import text from "./text";
88

99
export const locationPlaceholder = "Type your location here";
1010

11+
const noSection = {
12+
id: "0",
13+
name: "No Section",
14+
color: "#ffffff",
15+
stroke: "#ffffff"
16+
};
17+
1118
const initialState = {
1219
cursor: null,
1320
showControls: false,
@@ -39,11 +46,7 @@ const initialState = {
3946
}
4047
],
4148
sections: [
42-
{
43-
id: "0",
44-
name: "No Section",
45-
color: "#ffffff"
46-
},
49+
noSection,
4750
{
4851
id: uuidv4(),
4952
name: "Section 1",
@@ -210,8 +213,9 @@ export const slice = createSlice({
210213
state.selectedPolylineId = action.payload;
211214
},
212215
sync: (state, action) => {
213-
const { name, ...data } = action.payload as ISTKData;
216+
const { name, sections, ...data } = action.payload as ISTKData;
214217
state.location = name ?? state.location;
218+
state.sections = sections ? [noSection, ...sections] : state.sections;
215219
Object.keys(data).forEach((key) => {
216220
state[key] = data[key] ?? state[key];
217221
});

src/utils/transformer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export const stateToJSON = () => {
9191
return {
9292
name: state.location,
9393
categories: state.categories,
94-
sections: state.sections,
94+
sections: state.sections.slice(1),
9595
seats: domSeatsToJSON(),
9696
booths: domBoothsToJSON(),
9797
text: domTextToJSON(),

0 commit comments

Comments
 (0)