diff --git a/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx b/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx index 3821821a..b18821f3 100644 --- a/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx +++ b/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx @@ -41,15 +41,30 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set hajebichi: useRef(null), } + //치수 입력방법(복시도입력/실측값입력/육지붕) + const roofSizeSetArray = [ + { id: 'ra01', name: 'roofSizeSet', value: '1', checked: 'ture', message: 'modal.placement.initial.setting.size.roof' }, + { id: 'ra02', name: 'roofSizeSet', value: '2', checked: 'false', message: 'modal.placement.initial.setting.size.actual' }, + { id: 'ra03', name: 'roofSizeSet', value: '3', checked: 'false', message: 'modal.placement.initial.setting.size.none.pitch' }, + ] + + //지붕각도 설정(경사/각도) + const roofAngleSetArray = [ + { id: 'ra04', name: 'roofAngleSet', value: 'slope', checked: 'true', message: 'modal.placement.initial.setting.roof.pitch'}, + { id: 'ra05', name: 'roofAngleSet', value: 'flat', checked: 'false', message: 'modal.placement.initial.setting.roof.angle' }, + ] + // 데이터를 최초 한 번만 조회 useEffect(() => { if (!basicSetting || !currentRoof || Object.keys(currentRoof).length === 0 || Object.keys(basicSetting).length === 0) return const raftCodeList = findCommonCode('203800') setRaftCodes(raftCodeList) - setCurrentRoof({ ...currentRoof, roofSizeSet: basicSetting.roofMaterials.roofSizeSet, roofAngleSet: basicSetting.roofMaterials.roofAngleSet }) + setCurrentRoof({ ...currentRoof, roofSizeSet: basicSetting.roofSizeSet, roofAngleSet: basicSetting.roofAngleSet }) + console.log('🚀 ~ fetchBasicSettings ~ currentRoof 11:', currentRoof) }, []) useEffect(() => { + console.log('🚀 ~ fetchBasicSettings ~ currentRoof 22:', currentRoof) setBasicSettings({ ...basicSetting, roofSizeSet: String(currentRoof.roofSizeSet), @@ -110,10 +125,8 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set } const newAddedRoofs = [...addedRoofs] - if (addedRoofs.length === 1) { - newAddedRoofs[0] = { ...roofInfo } - setAddedRoofs(newAddedRoofs) - } + newAddedRoofs[0] = { ...roofInfo } + setAddedRoofs(newAddedRoofs) console.log('save Info', { ...basicSetting, @@ -178,74 +191,46 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set -
-
- setBasicSettings({ ...basicSetting, roofSizeSet: e.target.value })} // 상태 업데이트 - onClick={() => handleRoofSizeSetChange('1')} - /> - -
-
- setBasicSettings({ ...basicSetting, roofSizeSet: e.target.value })} // 상태 업데이트 - onClick={() => handleRoofSizeSetChange('2')} - /> - -
-
- setBasicSettings({ ...basicSetting, roofSizeSet: e.target.value })} // 상태 업데이트 - onClick={() => handleRoofSizeSetChange('3')} - /> - -
+
+ {currentRoof && + roofSizeSetArray.map((item) => ( +
+ setCurrentRoof({ ...currentRoof, roofSizeSet: e.target.value })} + /> + +
+ )) + }
{getMessage('modal.placement.initial.setting.roof.angle.setting')} -
-
- setBasicSettings({ ...basicSetting, roofAngleSet: e.target.value })} // 상태 업데이트 - onClick={() => handleRoofAngleSetChange('slope')} - /> - -
-
- setBasicSettings({ ...basicSetting, roofAngleSet: e.target.value })} // 상태 업데이트 - onClick={() => handleRoofAngleSetChange('flat')} - /> - -
+
+ {currentRoof && + roofAngleSetArray.map((item) => ( +
+ setCurrentRoof({ ...currentRoof, roofAngleSet: e.target.value })} + /> + +
+ )) + }
@@ -264,7 +249,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set currentRoof?.roofSizeSet === '3' ? getMessage('modal.placement.initial.setting.size.none.pitch') : currentRoof?.roofMatlNm } ref={roofRef.roofCd} - options={roofMaterials.map((roof, index) => { + options={roofMaterials.map((roof) => { return { ...roof, name: globalLocale === 'ko' ? roof.roofMatlNm : roof.roofMatlNmJp } })} value={currentRoof?.roofSizeSet === '3' ? null : currentRoof?.roofMatlCd} diff --git a/src/hooks/option/useCanvasSetting.js b/src/hooks/option/useCanvasSetting.js index 0c15c308..8594bd4e 100644 --- a/src/hooks/option/useCanvasSetting.js +++ b/src/hooks/option/useCanvasSetting.js @@ -326,35 +326,37 @@ export function useCanvasSetting() { ] } - // 데이터 설정 + // 데이터 설정 const addRoofs = [] - roofMaterials?.map((material) => { - if (material.roofMatlCd === roofsArray[0].roofMatlCd) { - addRoofs.push({ - ...material, - selected: true, - index: 0, - width: roofsArray[0].roofWidth, - length: roofsArray[0].roofHeight, - hajebichi: roofsArray[0].roofHajebichi, - raft: roofsArray[0].roofGap, - layout: roofsArray[0].roofLayout, - roofSizeSet: roofsRow[0].roofSizeSet, - roofAngleSet: roofsRow[0].roofAngleSet, - pitch: roofsArray[0].roofPitch, - angle: roofsArray[0].roofAngle, - }) - - setAddedRoofs(addRoofs) - setBasicSettings({ - ...basicSetting, - roofMaterials: addRoofs[0], - roofSizeSet: roofsRow[0].roofSizeSet, - roofAngleSet: roofsRow[0].roofAngleSet, - roofsData: roofsArray, - selectedRoofMaterial: addRoofs[0], - }) - } + for (let i = 0; i < roofsArray.length; i++) { + roofMaterials?.map((material) => { + if (material.roofMatlCd === roofsArray[i].roofMatlCd) { + addRoofs.push({ + ...material, + selected: roofsArray[i].roofApply, + index: i, + width: roofsArray[i].roofWidth, + length: roofsArray[i].roofHeight, + hajebichi: roofsArray[i].roofHajebichi, + raft: roofsArray[i].roofGap, + layout: roofsArray[i].roofLayout, + roofSizeSet: roofsRow[i].roofSizeSet, + roofAngleSet: roofsRow[i].roofAngleSet, + pitch: roofsArray[i].roofPitch, + angle: roofsArray[i].roofAngle, + }) + } + }) + } + console.log('🚀 ~ fetchBasicSettings ~ addRoofs:', addRoofs) + setAddedRoofs(addRoofs) + setBasicSettings({ + ...basicSetting, + roofMaterials: addRoofs[0], + roofSizeSet: roofsRow[0].roofSizeSet, + roofAngleSet: roofsRow[0].roofAngleSet, + roofsData: roofsArray, + selectedRoofMaterial: addRoofs[0], }) }) } catch (error) { diff --git a/src/hooks/roofcover/useRoofAllocationSetting.js b/src/hooks/roofcover/useRoofAllocationSetting.js index 2a46f355..3b956843 100644 --- a/src/hooks/roofcover/useRoofAllocationSetting.js +++ b/src/hooks/roofcover/useRoofAllocationSetting.js @@ -151,10 +151,11 @@ export function useRoofAllocationSetting(id) { pitch: roofsArray[i].roofPitch, angle: roofsArray[i].roofAngle, }) - setCurrentRoofList(selectRoofs) } }) } + + setCurrentRoofList(selectRoofs) setBasicSetting({ ...basicSetting, roofsData: roofsArray }) }) } catch (error) {