import { useMessage } from '@/hooks/useMessage' 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 { 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' import { globalLocaleStore } from '@/store/localeAtom' import { currentAngleTypeSelector, pitchTextSelector } from '@/store/canvasAtom' import { normalizeDecimalLimit, normalizeDigits } from '@/util/input-utils' export default function ContextRoofAllocationSetting(props) { const contextPopupPosition = useRecoilValue(contextPopupPositionState) const { id, pos = contextPopupPosition } = props const { getMessage } = useMessage() const { closePopup } = usePopup() const { handleSave, onAddRoofMaterial, onDeleteRoofMaterial, roofMaterials, currentRoofMaterial, setCurrentRoofMaterial, roofList, handleDefaultRoofMaterial, handleChangeRoofMaterial, handleChangeRaft, handleChangeLayout, handleSaveContext, currentRoofList, handleChangeInput, handleChangePitch, } = useRoofAllocationSetting(id) const { findCommonCode } = useCommonCode() const pitchText = useRecoilValue(pitchTextSelector) const globalLocale = useRecoilValue(globalLocaleStore) const currentAngleType = useRecoilValue(currentAngleTypeSelector) const [raftCodes, setRaftCodes] = useState([]) useEffect(() => { const raftCodeList = findCommonCode('203800') setRaftCodes(raftCodeList.map((raft) => ({ ...raft, value: raft.clCode, name: raft.clCodeNm }))) }, []) return ( closePopup(id)} /> {currentRoofList && (
{getMessage('modal.roof.alloc.info')}
{/* {getMessage('modal.roof.alloc.select.roof.material')}
{ return { ...roof, name: globalLocale === 'ko' ? roof.roofMatlNm : roof.roofMatlNmJp } })} value={currentRoofMaterial} onChange={(e) => { // const selected = roofMaterials.find((roofMaterial) => roofMaterial.roofMatlCd === e.id) setCurrentRoofMaterial(e) }} showKey="name" sourceKey={'roofMatlCd'} targetKey={'roofMatlCd'} />
*/}
{currentRoofList.map((roof, index) => { return (
{ return { ...roof2, name: globalLocale === 'ko' ? roof2.roofMatlNm : roof2.roofMatlNmJp } })} value={roof} //showKey={'roofMatlNm'} showKey="name" sourceKey={'roofMatlCd'} targetKey={'roofMatlCd'} onChange={(e) => handleChangeRoofMaterial(e, index)} />
{index === 0 && {getMessage('modal.roof.alloc.default.roof.material')}} {index !== 0 && ( )}
{roof.raftAuth && (
{getMessage('modal.placement.initial.setting.rafter')} {raftCodes.length > 0 && (
handleChangeRaft(e, index)} />
)}
)} {(roof.widAuth || roof.lenAuth) && ( <> {roof.widAuth && (
W
{ e.target.value = normalizeDigits(e.target.value) handleChangeInput(e, 'width', index) }} />
)} {roof.lenAuth && (
L
{ e.target.value = normalizeDigits(e.target.value) handleChangeInput(e, 'length', index) }} />
)} )} {roof.roofPchAuth && (
{getMessage('hajebichi')}
{ e.target.value = normalizeDigits(e.target.value) handleChangeInput(e, 'hajebichi', index) }} />
)}
{getMessage('modal.object.setting.offset.slope')}
{ e.target.value = normalizeDecimalLimit(e.target.value, 2) handleChangePitch(e, index) }} value={currentAngleType === 'slope' ? (roof.pitch || '0') : (roof.angle || '0')} defaultValue={currentAngleType === 'slope' ? (roof.pitch || '0') : (roof.angle || '0')} />
{pitchText}
) })}
)}
) }