import { useState, useEffect, useContext } from 'react' import { useMessage } from '@/hooks/useMessage' import { useAxios } from '@/hooks/useAxios' import { globalLocaleStore } from '@/store/localeAtom' import { useRecoilValue } from 'recoil' import { isEmptyArray } from '@/util/common-utils' import { useSwal } from '@/hooks/useSwal' import { QcastContext } from '@/app/QcastProvider' export default function WindSelectPop(props) { const globalLocaleState = useRecoilValue(globalLocaleStore) const { promiseGet } = useAxios(globalLocaleState) const [windSpeedList, setWindSpeedList] = useState([]) const [windSpeed, setWindSpeed] = useState(null) const { getMessage } = useMessage() const { swalFire } = useSwal() const { setIsGlobalLoading } = useContext(QcastContext) //선택한 라디오 값 세팅 const handleChangeRadio = (e) => { setWindSpeed(e.target.value) } //적용 const applyWindSpeed = () => { if (windSpeed == null) { swalFire({ text: getMessage('stuff.windSelectPopup.error.message2'), type: 'alert', icon: 'warning' }) } else { props.windSpeedInfo({ windSpeed: windSpeed }) //팝업닫기 props.setShowWindSpeedButtonValid(false) } } useEffect(() => { setIsGlobalLoading(true) if (props.prefName !== '') { promiseGet({ url: `/api/object/windSpeed/${props.prefName}/list` }).then((res) => { if (res.status === 200) { setIsGlobalLoading(false) if (!isEmptyArray(res.data)) { setWindSpeedList(res.data) } } }) } else { setIsGlobalLoading(false) } setIsGlobalLoading(false) }, [props]) return (

{getMessage('stuff.windSelectPopup.title')}

{getMessage('stuff.windSelectPopup.search.address1')}
{windSpeedList.map((row, index) => { return ( ) })}
{getMessage('stuff.windSelectPopup.table.selected')} {getMessage('stuff.windSelectPopup.table.windspeed')} Remarks
{row.standardWindSpeedId.slice(3)} {row.remarks}
) }