요소 추가 버튼 시 api 호출 삭제

This commit is contained in:
dohyeons 2025-10-20 10:06:17 +09:00
parent aba6283e3f
commit ab07908f09
2 changed files with 11 additions and 9 deletions

View File

@ -146,18 +146,14 @@ export class YardLayoutController {
}
}
// 야드에 자재 배치 추가
// 야드에 자재 배치 추가 (빈 요소 또는 설정된 요소)
async addMaterialPlacement(req: Request, res: Response) {
try {
const { id } = req.params;
const placementData = req.body;
if (!placementData.external_material_id || !placementData.material_code) {
return res.status(400).json({
success: false,
message: "자재 정보가 필요합니다.",
});
}
// 데이터 바인딩 재설계 후 material_code와 external_material_id는 선택사항
// 빈 요소를 추가할 수 있어야 함
const placement = await YardLayoutService.addMaterialPlacement(
parseInt(id),

View File

@ -70,16 +70,22 @@ export default function YardEditor({ layout, onBack }: YardEditorProps) {
color: "#9ca3af", // 회색 (미설정 상태)
};
console.log("요소 추가 요청:", { layoutId: layout.id, data: newPlacementData });
const response = await yardLayoutApi.addMaterialPlacement(layout.id, newPlacementData);
console.log("요소 추가 응답:", response);
if (response.success) {
const newPlacement = response.data as YardPlacement;
setPlacements((prev) => [...prev, newPlacement]);
setSelectedPlacement(newPlacement);
setShowConfigPanel(true); // 자동으로 설정 패널 표시
} else {
console.error("요소 추가 실패 (응답):", response);
setError(response.message || "요소 추가에 실패했습니다.");
}
} catch (error) {
console.error("요소 추가 실패:", error);
setError("요소 추가에 실패했습니다.");
console.error("요소 추가 실패 (예외):", error);
setError(`요소 추가에 실패했습니다: ${error instanceof Error ? error.message : String(error)}`);
}
};