'use client' import { useRecoilValue } from 'recoil' import { useMessage } from '@/hooks/useMessage' import WithDraggable from '@/components/common/draggable/WithDraggable' import { usePopup } from '@/hooks/usePopup' import { contextPopupPositionState } from '@/store/popupAtom' import { useEffect, useRef, useState } from 'react' import { useObjectBatch } from '@/hooks/object/useObjectBatch' import { BATCH_TYPE, POLYGON_TYPE } from '@/common/common' import { useSurfaceShapeBatch } from '@/hooks/surface/useSurfaceShapeBatch' import { CalculatorInput } from '@/components/common/input/CalcInput' export default function SizeSetting(props) { const contextPopupPosition = useRecoilValue(contextPopupPositionState) const [settingTarget, setSettingTarget] = useState(props.side || 1) const { id, pos = contextPopupPosition, target } = props const { getMessage } = useMessage() const { closePopup } = usePopup() const { resizeObjectBatch } = useObjectBatch({}) const { resizeSurfaceShapeBatch } = useSurfaceShapeBatch({}) const widthRef = useRef(null) const heightRef = useRef(null) const [width, setWidth] = useState(target?.width ? (target.width * 10).toFixed() : 0) const [height, setHeight] = useState(target?.height ? (target.height * 10) : 0) // const { initEvent } = useEvent() // const { initEvent } = useContext(EventContext) // useEffect(() => { // initEvent() // }, []) useEffect(() => { if (target?.width !== undefined) { setWidth((target.width * 10).toFixed()); } if (target?.height !== undefined) { setHeight((target.height * 10).toFixed()); } }, [target]); const handleReSizeObject = () => { const width = widthRef.current.value const height = heightRef.current.value if (target.name === BATCH_TYPE.OPENING || target.name === BATCH_TYPE.SHADOW) { resizeObjectBatch(settingTarget, target, width, height, id) } else if (target.name === POLYGON_TYPE.ROOF) { resizeSurfaceShapeBatch(settingTarget, target, width, height, id) } } return ( closePopup(id)} />
setWidth(e.target.value)} readOnly={true} /> mm
{/**/} setWidth(value)} options={{ allowNegative: false, allowDecimal: false }} /> mm
setHeight(e.target.value)} readOnly={true} /> mm
{/**/} setHeight(value)} options={{ allowNegative: false, allowDecimal: false }} /> mm
) }