import { useEffect, useState, useReducer } from 'react' import { useRecoilValue, useRecoilState } from 'recoil' import { addedRoofsState } from '@/store/settingAtom' import { canvasSettingState, pitchSelector } from '@/store/canvasAtom' import { useMessage } from '@/hooks/useMessage' import QSelectBox from '@/components/common/select/QSelectBox' import { useModuleSelection } from '@/hooks/module/useModuleSelection' import ModuleTabContents from './ModuleTabContents' import { useDebounceCallback, useDebounceValue } from 'usehooks-ts' import { moduleSelectionDataState } from '@/store/selectedModuleOptions' export default function Module({}) { const { getMessage } = useMessage() const addedRoofs = useRecoilValue(addedRoofsState) //지붕재 선택 const [roofTab, setRoofTab] = useState(0) //지붕재 탭 const { moduleSelectionInitParams, selectedModules, raftCodes, roughnessCodes, windSpeedCodes, managementState, moduleList, installHeight, verticalSnowCover, handleChangeModule, handleChangeSurfaceType, handleChangeWindSpeed, handleChangeInstallHeight, handleChangeVerticalSnowCover, } = useModuleSelection({ addedRoofs }) const [inputInstallHeight, setInputInstallHeight] = useState(installHeight) const [inputVerticalSnowCover, setInputVerticalSnowCover] = useState(verticalSnowCover) const [debouncedInstallHeight] = useDebounceValue(inputInstallHeight, 500) const [debouncedVerticalSnowCover] = useDebounceValue(inputVerticalSnowCover, 500) const [moduleSelectionData, setModuleSelectionData] = useRecoilState(moduleSelectionDataState) //다음으로 넘어가는 최종 데이터 const [tempModuleSelectionData, setTempModuleSelectionData] = useReducer((prevState, nextState) => { return { ...prevState, ...nextState } }, moduleSelectionData) useEffect(() => { handleChangeInstallHeight(debouncedInstallHeight) }, [debouncedInstallHeight]) useEffect(() => { handleChangeVerticalSnowCover(debouncedVerticalSnowCover) }, [debouncedVerticalSnowCover]) useEffect(() => { setInputInstallHeight(installHeight) setInputVerticalSnowCover(verticalSnowCover) }, [installHeight, verticalSnowCover]) const moduleData = { header: [ { name: getMessage('module'), width: 150, prop: 'module', type: 'color-box' }, { name: `${getMessage('높이')} (mm)`, prop: 'height', }, { name: `${getMessage('width')} (mm)`, prop: 'width' }, { name: `${getMessage('output')} (W)`, prop: 'output' }, ], rows: [], } useEffect(() => {}, [roofTab]) useEffect(() => { console.log('moduleSelectionData', moduleSelectionData) }, []) const handleRoofTab = (tab) => { setRoofTab(tab) } return ( <>
| {header.name} | ) })}|||
|---|---|---|---|
|
{row.itemNm}
|
{Number(row.shortAxis).toFixed(0)} | {Number(row.longAxis).toFixed(0)} | {Number(row.wpOut).toFixed(0)} |