Skip to content

Commit 6fb1ede

Browse files
committed
fix(condo): DOMA-4507 fix map constructor
1 parent 486c95f commit 6fb1ede

File tree

3 files changed

+20
-27
lines changed

3 files changed

+20
-27
lines changed

apps/condo/domains/property/components/panels/Builder/MapConstructor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ class MapEdit extends MapView {
11201120
this.removeParkingUnit(unit.id, renameNextUnits)
11211121
this.addParkingUnit(unit, renameNextUnits)
11221122
} else {
1123-
this.map.parking[unitIndex.parking].floors[unitIndex.floor].units[unitIndex.unit].name = unit.label
1123+
this.map.parking[unitIndex.parking].floors[unitIndex.floor].units[unitIndex.unit].name = isNaN(Number(unit.label)) ? unit.label : undefined
11241124
this.map.parking[unitIndex.parking].floors[unitIndex.floor].units[unitIndex.unit].label = unit.label
11251125
if (renameNextUnits) this.updateParkingUnitNumbers(unit)
11261126
}
@@ -1142,7 +1142,7 @@ class MapEdit extends MapView {
11421142
this.addUnit(unit, renameNextUnits)
11431143
} else {
11441144
this.map.sections[unitIndex.section].floors[unitIndex.floor].units[unitIndex.unit].unitType = unit.unitType
1145-
this.map.sections[unitIndex.section].floors[unitIndex.floor].units[unitIndex.unit].name = unit.label
1145+
this.map.sections[unitIndex.section].floors[unitIndex.floor].units[unitIndex.unit].name = isNaN(Number(unit.label)) ? unit.label : undefined
11461146
this.map.sections[unitIndex.section].floors[unitIndex.floor].units[unitIndex.unit].label = unit.label
11471147
if (renameNextUnits) this.updateUnitNumbers(unit)
11481148
}

apps/condo/domains/property/components/panels/Builder/forms/ParkingUnitForm.tsx

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,19 +120,16 @@ const ParkingUnitForm: React.FC<IPropertyMapModalForm> = ({ builder, refresh })
120120
}, [floor, section, label, builder, mode])
121121

122122
const applyChanges = useCallback(() => {
123-
setIsValidationErrorVisible(!isUnitUnique)
124-
if (isUnitUnique) {
125-
const mapUnit = builder.getSelectedParkingUnit()
126-
if (mapUnit) {
127-
builder.updateParkingUnit({ ...mapUnit, label, floor, section }, renameNextUnits.current)
128-
} else {
129-
builder.removePreviewParkingUnit()
130-
builder.addParkingUnit({ id: '', label, floor, section }, renameNextUnits.current)
131-
resetForm()
132-
}
133-
refresh()
123+
const mapUnit = builder.getSelectedParkingUnit()
124+
if (mapUnit) {
125+
builder.updateParkingUnit({ ...mapUnit, label, floor, section }, renameNextUnits.current)
126+
} else {
127+
builder.removePreviewParkingUnit()
128+
builder.addParkingUnit({ id: '', label, floor, section }, renameNextUnits.current)
129+
resetForm()
134130
}
135-
}, [builder, refresh, resetForm, label, floor, section, isUnitUnique])
131+
refresh()
132+
}, [builder, refresh, resetForm, label, floor, section])
136133

137134
const deleteUnit = useCallback(() => {
138135
const mapUnit = builder.getSelectedParkingUnit()

apps/condo/domains/property/components/panels/Builder/forms/UnitForm.tsx

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -120,20 +120,16 @@ const UnitForm: React.FC<IPropertyMapModalForm> = ({ builder, refresh }) => {
120120
}, [floor, section, label, unitType, builder, mode])
121121

122122
const applyChanges = useCallback(() => {
123-
setIsValidationErrorVisible(!isUnitUnique)
124-
125-
if (isUnitUnique) {
126-
const mapUnit = builder.getSelectedUnit()
127-
if (mapUnit) {
128-
builder.updateUnit({ ...mapUnit, label, floor, section, unitType }, renameNextUnits.current)
129-
} else {
130-
builder.removePreviewUnit()
131-
builder.addUnit({ id: '', label, floor, section, unitType }, renameNextUnits.current)
132-
resetForm()
133-
}
134-
refresh()
123+
const mapUnit = builder.getSelectedUnit()
124+
if (mapUnit) {
125+
builder.updateUnit({ ...mapUnit, label, floor, section, unitType }, renameNextUnits.current)
126+
} else {
127+
builder.removePreviewUnit()
128+
builder.addUnit({ id: '', label, floor, section, unitType }, renameNextUnits.current)
129+
resetForm()
135130
}
136-
}, [builder, refresh, resetForm, label, floor, section, unitType, isUnitUnique])
131+
refresh()
132+
}, [builder, refresh, resetForm, label, floor, section, unitType])
137133

138134
const onLabelChange = useCallback((e) => {
139135
isValidationErrorVisible && setIsValidationErrorVisible(false)

0 commit comments

Comments
 (0)