diff --git a/package.json b/package.json index 1f272ce1..1677b398 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "ag-grid-react": "^32.0.2", "axios": "^1.7.8", "chart.js": "^4.4.6", + "dayjs": "^1.11.13", "fabric": "^5.3.0", "framer-motion": "^11.2.13", "fs": "^0.0.1-security", @@ -32,12 +33,12 @@ "react-icons": "^5.3.0", "react-loading-skeleton": "^3.5.0", "react-responsive-modal": "^6.4.2", + "react-select": "^5.8.1", "recoil": "^0.7.7", "sweetalert2": "^11.14.1", "sweetalert2-react-content": "^5.0.7", - "uuid": "^10.0.0", - "dayjs": "^1.11.13", - "react-select": "^5.8.1" + "usehooks-ts": "^3.1.0", + "uuid": "^10.0.0" }, "devDependencies": { "@turf/turf": "^7.0.0", diff --git a/src/components/common/select/QSelectBox.jsx b/src/components/common/select/QSelectBox.jsx index 3da9f30b..b2381c00 100644 --- a/src/components/common/select/QSelectBox.jsx +++ b/src/components/common/select/QSelectBox.jsx @@ -1,21 +1,29 @@ 'use client' -import { useEffect, useState } from 'react' +import { useEffect, useRef, useState } from 'react' +import { useOnClickOutside } from 'usehooks-ts' export default function QSelectBox({ title = '', options, onChange, value, disabled = false, params = {} }) { const [openSelect, setOpenSelect] = useState(false) const [selected, setSelected] = useState(title === '' ? options[0].name : title) + const ref = useRef(null) const handleClickSelectOption = (option) => { setSelected(option.name) onChange?.(option, params) } + const handleClose = () => { + setOpenSelect(false) + } + useEffect(() => { value && handleClickSelectOption(value) }, [value]) + useOnClickOutside(ref, handleClose) + return ( -
{} : () => setOpenSelect(!openSelect)}> +
{} : () => setOpenSelect(!openSelect)}>

{selected}

-
- -
+ {addedRoofs.length > 0 && ( +
+ { roof.selected)} options={addedRoofs} onChange={changeSelectedRoofMaterial} />} +
+ )}
+ +
+
-
diff --git a/src/components/floor-plan/modal/roofAllocation/RoofAllocationSetting.jsx b/src/components/floor-plan/modal/roofAllocation/RoofAllocationSetting.jsx index f6f1e6f1..17201bda 100644 --- a/src/components/floor-plan/modal/roofAllocation/RoofAllocationSetting.jsx +++ b/src/components/floor-plan/modal/roofAllocation/RoofAllocationSetting.jsx @@ -3,17 +3,38 @@ import WithDraggable from '@/components/common/draggable/WithDraggable' import QSelectBox from '@/components/common/select/QSelectBox' import { useRoofAllocationSetting } from '@/hooks/roofcover/useRoofAllocationSetting' import { usePopup } from '@/hooks/usePopup' -import { useRecoilValue } from 'recoil' +import { useRecoilState, useRecoilValue } from 'recoil' import { contextPopupPositionState } from '@/store/popupAtom' +import { useEffect, useState } from 'react' +import { basicSettingState } from '@/store/settingAtom' +import { ROOF_MATERIAL_LAYOUT } from '@/components/floor-plan/modal/placementShape/PlacementShapeSetting' +import { useCanvasSetting } from '@/hooks/option/useCanvasSetting' +import { useCommonCode } from '@/hooks/common/useCommonCode' export default function RoofAllocationSetting(props) { const contextPopupPosition = useRecoilValue(contextPopupPositionState) const { id, pos = contextPopupPosition } = props const { getMessage } = useMessage() const { closePopup } = usePopup() - const { handleSave, onAddRoofMaterial, onDeleteRoofMaterial, values, roofMaterials, selectedRoofMaterial, setSelectedRoofMaterial } = - useRoofAllocationSetting(id) - + const { + handleSave, + onAddRoofMaterial, + onDeleteRoofMaterial, + roofMaterials, + setCurrentRoofMaterial, + roofList, + handleDefaultRoofMaterial, + handleChangeRoofMaterial, + } = useRoofAllocationSetting(id) + const { fetchBasicSettings } = useCanvasSetting() + const { findCommonCode } = useCommonCode() + const [raftCodes, setRaftCodes] = useState([]) + useEffect(() => { + fetchBasicSettings() + const raftCodeList = findCommonCode('203800') + console.log('🚀 ~ useEffect ~ raftCodeList:', raftCodeList) + setRaftCodes(raftCodeList) + }, []) return (
@@ -28,7 +49,13 @@ export default function RoofAllocationSetting(props) {
{getMessage('modal.roof.alloc.select.roof.material')}
- setSelectedRoofMaterial(e)} /> + { + const selected = roofMaterials.find((roofMaterial) => roofMaterial.roofMatlCd === e.id) + setCurrentRoofMaterial(selected) + }} + />
- {values.map((value, index) => ( -
-
- - -
-
-
-
-
- -
- {index === 0 && 基本屋根材} - {index !== 0 && } -
+ {roofList.map((roof, index) => { + return ( +
+
+ +
-
- {value.type === 'A' ? ( - <> +
+
+
+
+ r.id === roof.id)} + onChange={(e) => handleChangeRoofMaterial(e, index)} + /> +
+ {index === 0 && 基本屋根材} + {index !== 0 && } +
+
+
+ {roof.widAuth && (
W -
+
+ +
+ {/*
-
+
*/}
+ )} + {roof.lenAuth && (
L -
+
+ +
+ {/*
-
+
*/}
+ )} + {roof.raftAuth && (
{getMessage('modal.placement.initial.setting.rafter')} -
- +
+ ({ name: raft.clCodeNm, value: raft.clCode }))} + value={raftCodes.find((r) => r.id === roof.id)} + /> + {/* */}
- - ) : value.type === 'B' ? ( - <> + )} + {roof.roofPchAuth && (
{getMessage('hajebichi')} -
+
+ +
+ {/*
-
+
*/}
-
- {getMessage('modal.placement.initial.setting.rafter')} -
- -
-
- - ) : value.type === 'C' ? ( - <> -
- {getMessage('hajebichi')} -
- -
-
- - ) : value.type === 'D' ? ( - <> -
- L -
- -
-
-
- {getMessage('modal.placement.initial.setting.rafter')} -
- -
-
- - ) : ( - '' - )} -
-
-
- - + )} +
+
+
+ + +
-
- ))} + ) + })}