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 { useRecoilValue } from 'recoil' import { contextPopupPositionState } from '@/store/popupAtom' import { useEffect, useState } from 'react' 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 { useRoofShapeSetting } from '@/hooks/roofcover/useRoofShapeSetting' import { currentAngleTypeSelector, pitchTextSelector } from '@/store/canvasAtom' import { getDegreeByChon } from '@/util/canvas-util' import { normalizeDecimalLimit, normalizeDigits } from '@/util/input-utils' export default function RoofAllocationSetting(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, currentRoofList, handleChangeInput, handleChangePitch, } = useRoofAllocationSetting(id) const pitchText = useRecoilValue(pitchTextSelector) const { findCommonCode } = useCommonCode() const [raftCodes, setRaftCodes] = useState([]) const globalLocale = useRecoilValue(globalLocaleStore) const currentAngleType = useRecoilValue(currentAngleTypeSelector) useEffect(() => { const raftCodeList = findCommonCode('203800') setRaftCodes(raftCodeList.map((raft) => ({ ...raft, 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) }} readOnly={roof.widAuth === 'R'} />
)} {roof.lenAuth && (
L
{ e.target.value = normalizeDigits(e.target.value) handleChangeInput(e, 'length', index) }} readOnly={roof.lenAuth === 'R'} />
)} )} {roof.roofPchAuth && (
{getMessage('hajebichi')}
{ e.target.value = normalizeDigits(e.target.value) handleChangeInput(e, 'hajebichi', index) }} value={parseInt(roof.hajebichi)} readOnly={roof.roofPchAuth === 'R'} />
)}
{getMessage('modal.object.setting.offset.slope')}
{ e.target.value = normalizeDecimalLimit(e.target.value, 2) handleChangePitch(e, index) }} value={currentAngleType === 'slope' ? roof.pitch : roof.angle} />
{pitchText}
{/*
*/}
) })}
)}
) }