import WithDraggable from '@/components/common/draggable/WithDraggable' import { useEffect, useState } from 'react' import QSelectBox from '@/components/common/select/QSelectBox' import { useRecoilValue } from 'recoil' import { contextPopupPositionState } from '@/store/popupAtom' import { useMessage } from '@/hooks/useMessage' import { usePopup } from '@/hooks/usePopup' export default function FlowDirectionSetting(props) { const contextPopupPosition = useRecoilValue(contextPopupPositionState) const { id, pos = contextPopupPosition, target } = props const { getMessage } = useMessage() const { closePopup } = usePopup() const [compasDeg, setCompasDeg] = useState(360) const orientations = [ { name: `${getMessage('commons.south')}`, value: 360 }, { name: `${getMessage('commons.south')}${getMessage('commons.east')}`, value: 315 }, { name: `${getMessage('commons.south')}${getMessage('commons.west')}`, value: 45 }, { name: `${getMessage('commons.east')}`, value: 270 }, { name: `${getMessage('commons.west')}`, value: 90 }, { name: `${getMessage('commons.north')}${getMessage('commons.east')}`, value: 225 }, { name: `${getMessage('commons.north')}${getMessage('commons.west')}`, value: 135 }, { name: `${getMessage('commons.north')}`, value: 180 }, ] const [selectedOrientation, setSelectedOrientation] = useState(orientations[0]) const [type, setType] = useState('0') useEffect(() => { if (target?.angle === 0) { setCompasDeg(360) } else { setCompasDeg(target?.angle ?? 360) } }, []) useEffect(() => { if (type === '0') { setCompasDeg(selectedOrientation.value) } }, [selectedOrientation]) useEffect(() => { if (type === '1') { if ([15, 345, 360].includes(compasDeg)) { setSelectedOrientation(orientations[0]) } else if ([30, 45, 60].includes(compasDeg)) { setSelectedOrientation(orientations[2]) } else if ([75, 90, 105].includes(compasDeg)) { setSelectedOrientation(orientations[4]) } else if ([120, 135, 150].includes(compasDeg)) { setSelectedOrientation(orientations[6]) } else if ([165, 180, 195].includes(compasDeg)) { setSelectedOrientation(orientations[7]) } else if ([210, 225, 240].includes(compasDeg)) { setSelectedOrientation(orientations[5]) } else if ([255, 270, 285].includes(compasDeg)) { setSelectedOrientation(orientations[3]) } else if ([300, 315, 330].includes(compasDeg)) { setSelectedOrientation(orientations[1]) } } }, [compasDeg]) return (

{getMessage('modal.shape.flow.direction.setting')}

{getMessage('modal.flow.direction.setting')}
{getMessage('modal.flow.direction.setting.info')}
{getMessage('commons.north')} {getMessage('commons.east')} {getMessage('commons.south')} {getMessage('commons.west')}
{getMessage('modal.module.basic.setting.orientation.setting')}
{getMessage('modal.shape.flow.direction.setting.orientation.setting.info')}
setType(e.target.value)} />
setSelectedOrientation(e)} />
setType(e.target.value)} />
{Array.from({ length: 180 / 15 + 1 }).map((dot, index) => (
setCompasDeg(15 * (12 + index))} > {13 - index}
))} {Array.from({ length: 180 / 15 - 1 }).map((dot, index) => (
setCompasDeg(15 * (index + 1))} > {24 - index}
))}
) }