123 lines
4.5 KiB
JavaScript
123 lines
4.5 KiB
JavaScript
import WithDraggable from '@/components/common/draggable/WithDraggable'
|
|
import { useMessage } from '@/hooks/useMessage'
|
|
import { usePopup } from '@/hooks/usePopup'
|
|
import { useRecoilValue } from 'recoil'
|
|
import { contextPopupPositionState } from '@/store/popupAtom'
|
|
import { useEffect, useState } from 'react'
|
|
import { currentObjectState } from '@/store/canvasAtom'
|
|
import { useRoofAllocationSetting } from '@/hooks/roofcover/useRoofAllocationSetting'
|
|
import { useSwal } from '@/hooks/useSwal'
|
|
|
|
export default function ActualSizeSetting(props) {
|
|
const contextPopupPosition = useRecoilValue(contextPopupPositionState)
|
|
const { id, pos = contextPopupPosition } = props
|
|
const currentObject = useRecoilValue(currentObjectState)
|
|
const [planeSize, setPlaneSize] = useState(0)
|
|
const [actualSize, setActualSize] = useState(0)
|
|
const { setLineSize, handleAlloc } = useRoofAllocationSetting()
|
|
const { closePopup } = usePopup()
|
|
const { getMessage } = useMessage()
|
|
const { swalFire } = useSwal()
|
|
useEffect(() => {
|
|
if (currentObject && currentObject.attributes) {
|
|
setPlaneSize(currentObject.attributes.planeSize ?? 0)
|
|
setActualSize(currentObject.attributes.actualSize ?? 0)
|
|
}
|
|
}, [currentObject])
|
|
|
|
const handleFinish = () => {
|
|
swalFire({
|
|
text: '완료 하시겠습니까?',
|
|
type: 'confirm',
|
|
confirmFn: () => {
|
|
handleAlloc()
|
|
},
|
|
})
|
|
}
|
|
|
|
const handleClose = () => {
|
|
swalFire({
|
|
text: '완료 하시겠습니까?',
|
|
type: 'confirm',
|
|
confirmFn: () => {
|
|
handleAlloc()
|
|
},
|
|
// denyFn: () => {
|
|
// swalFire({ text: '취소되었습니다.', icon: 'error' })
|
|
// },
|
|
})
|
|
}
|
|
|
|
const handleApply = () => {
|
|
if (!currentObject) {
|
|
swalFire({ type: 'alert', icon: 'error', text: getMessage('modal.actual.size.setting.not.exist.auxiliary.line') })
|
|
return
|
|
}
|
|
if (actualSize !== 0) {
|
|
setLineSize(currentObject?.id, actualSize)
|
|
} else {
|
|
swalFire({ type: 'alert', icon: 'error', text: getMessage('modal.actual.size.setting.not.exist.size') })
|
|
}
|
|
}
|
|
|
|
return (
|
|
<WithDraggable isShow={true} pos={pos}>
|
|
<div className={`modal-pop-wrap ssm mount`}>
|
|
<div className="modal-head">
|
|
<h1 className="title">{getMessage('modal.actual.size.setting')}</h1>
|
|
<button className="modal-close" onClick={() => closePopup(id)}>
|
|
닫기
|
|
</button>
|
|
</div>
|
|
<div className="modal-body">
|
|
<div className="guide">
|
|
<span>{getMessage('modal.actual.size.setting.info')}</span>
|
|
</div>
|
|
<div className="properties-setting-wrap outer">
|
|
<div className="setting-tit">{getMessage('setting')}</div>
|
|
<div className="outline-wrap">
|
|
<div className="eaves-keraba-table">
|
|
<div className="eaves-keraba-item">
|
|
<div className="eaves-keraba-th">{getMessage('modal.actual.size.setting.plane.size.length')}</div>
|
|
<div className="eaves-keraba-td">
|
|
<div className="outline-form">
|
|
<div className="input-grid mr5">
|
|
<input type="text" className="input-origin block" value={planeSize} readOnly={true} />
|
|
</div>
|
|
<span className="thin">mm</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div className="eaves-keraba-item">
|
|
<div className="eaves-keraba-th">{getMessage('modal.actual.size.setting.actual.size.length')}</div>
|
|
<div className="eaves-keraba-td">
|
|
<div className="outline-form">
|
|
<div className="input-grid mr5">
|
|
<input
|
|
type="text"
|
|
className="input-origin block"
|
|
value={actualSize}
|
|
onChange={(e) => setActualSize(Number(e.target.value))}
|
|
/>
|
|
</div>
|
|
<span className="thin">mm</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div className="grid-btn-wrap">
|
|
<button className="btn-frame modal mr5" onClick={handleFinish}>
|
|
{getMessage('common.setting.finish')}
|
|
</button>
|
|
<button className="btn-frame modal act" onClick={handleApply}>
|
|
{getMessage('apply')}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</WithDraggable>
|
|
)
|
|
}
|