저장 시 위치가 바뀌는 문제 해결

This commit is contained in:
dohyeons
2025-10-20 10:12:23 +09:00
parent ab07908f09
commit 0217393cb8
2 changed files with 44 additions and 17 deletions

View File

@@ -174,8 +174,31 @@ export default function YardEditor({ layout, onBack }: YardEditorProps) {
const response = await yardLayoutApi.updatePlacement(selectedPlacement.id, updatedData);
if (response.success) {
const updated = response.data as YardPlacement;
setPlacements((prev) => prev.map((p) => (p.id === updated.id ? updated : p)));
setSelectedPlacement(updated);
// 현재 위치 정보를 유지하면서 업데이트
setPlacements((prev) =>
prev.map((p) => {
if (p.id === updated.id) {
// 현재 프론트엔드 상태의 위치를 유지
return {
...updated,
position_x: p.position_x,
position_y: p.position_y,
position_z: p.position_z,
};
}
return p;
}),
);
// 선택된 요소도 동일하게 업데이트
setSelectedPlacement({
...updated,
position_x: selectedPlacement.position_x,
position_y: selectedPlacement.position_y,
position_z: selectedPlacement.position_z,
});
setShowConfigPanel(false);
}
} catch (error) {