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 { currentAngleTypeSelector, pitchTextSelector } from '@/store/canvasAtom' 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, setCurrentRoofMaterial, roofList, handleDefaultRoofMaterial, handleChangeRoofMaterial, handleChangeRaft, handleChangeLayout, handleSaveContext, currentRoofList, handleChangeInput, } = useRoofAllocationSetting(id) const { findCommonCode } = useCommonCode() const pitchText = useRecoilValue(pitchTextSelector) 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 (

{getMessage('plan.menu.estimate.roof.alloc')}

{getMessage('modal.roof.alloc.info')}
{getMessage('modal.roof.alloc.select.roof.material')}
{ // const selected = roofMaterials.find((roofMaterial) => roofMaterial.roofMatlCd === e.id) setCurrentRoofMaterial(e) }} showKey={'roofMatlNm'} sourceKey={'roofMatlCd'} targetKey={'roofMatlCd'} />
{currentRoofList.length > 0 && currentRoofList.map((roof, index) => { return (
handleChangeRoofMaterial(e, index)} />
{index === 0 && {getMessage('modal.roof.alloc.default.roof.material')}} {index !== 0 && }
{getMessage('slope')}
{ handleChangeInput(e, currentAngleType === 'slope' ? 'pitch' : 'angle', index) }} defaultValue={currentAngleType === 'slope' ? roof.pitch : roof.angle} />
{pitchText}
{(roof.widAuth || roof.lenAuth) && (
{roof.widAuth && (
W
)} {roof.lenAuth && (
L
)}
)} {(roof.raftAuth || roof.roofPchAuth) && (
{roof.raftAuth && (
{getMessage('modal.placement.initial.setting.rafter')} {raftCodes.length > 0 && (
)}
)} {roof.roofPchAuth && (
{getMessage('hajebichi')}
)}
)}
) })}
) }