diff --git a/src/components/floor-plan/modal/basic/step/Placement.jsx b/src/components/floor-plan/modal/basic/step/Placement.jsx index 2dced068..95f6fb3e 100644 --- a/src/components/floor-plan/modal/basic/step/Placement.jsx +++ b/src/components/floor-plan/modal/basic/step/Placement.jsx @@ -7,6 +7,7 @@ import { isManualModuleSetupState, moduleRowColArrayState, moduleSetupOptionState, + moduleSetupSurfaceState, toggleManualSetupModeState, } from '@/store/canvasAtom' import { useRecoilState, useRecoilValue, useResetRecoilState, useSetRecoilState } from 'recoil' @@ -42,14 +43,39 @@ const Placement = forwardRef((props, refs) => { const [colspan, setColspan] = useState(1) const moduleRowColArray = useRecoilValue(moduleRowColArrayState) + const moduleSetupSurface = useRecoilValue(moduleSetupSurfaceState) //선택된 배치면 + + // 千鳥可否 는 지붕재별로 다르므로 선택된 배치면 기준으로 재판정한다. + // 일부 지붕재만 선택하면 그 지붕재 기준, 미선택이거나 모든 지붕재가 선택되면 전체 기준으로 + // 하나라도 不可(plvrYn==='N')면 千鳥 불가. + useEffect(() => { + const roofConstructions = moduleSelectionData?.roofConstructions + if (!roofConstructions?.length) return + + const plvrOf = (roofIndex) => roofConstructions.find((c) => Number(c.roofIndex) === Number(roofIndex))?.construction?.plvrYn + const allRoofIndexes = roofConstructions.map((c) => Number(c.roofIndex)) + const selectedRoofIndexes = [...new Set((moduleSetupSurface ?? []).filter((s) => s.roofMaterial?.index != null).map((s) => Number(s.roofMaterial.index)))] + + // 미선택 또는 모든 지붕재가 선택된 경우 = 전체 기준 + const useAll = selectedRoofIndexes.length === 0 || allRoofIndexes.every((roofIndex) => selectedRoofIndexes.includes(roofIndex)) + const targetRoofIndexes = useAll ? allRoofIndexes : selectedRoofIndexes + + const notAble = targetRoofIndexes.some((roofIndex) => plvrOf(roofIndex) === 'N') + setIsChidoriNotAble(notAble) + + // 不可 지붕재가 선택되면 켜져 있던 千鳥 를 자동 해제하고, 진행 중이던 수동배치도 초기화한다. + // (千鳥 오프셋이 바뀌면 기존/신규 모듈 배치가 섞이므로, 千鳥 수동 변경과 동일하게 수동 모드를 끈다) + if (notAble) { + setModuleSetupOption((prev) => (prev.isChidori ? { ...prev, isChidori: false } : prev)) + setIsManualModuleSetup(false) + setIsManualModuleLayoutSetup(false) + setManualSetupMode('off') + } + }, [moduleSetupSurface, moduleSelectionData]) + //모듈 배치면 생성 useEffect(() => { if (moduleSelectionData) { - //1개라도 치도리 불가가 있으면 치도리 불가 - const isChidroriValue = moduleSelectionData.roofConstructions.some((item) => item.construction.plvrYn === 'N') - if (isChidroriValue) { - setIsChidoriNotAble(true) - } makeModuleInitArea(moduleSelectionData) }