[1237] 모듈/가대 목록 - timeout 연장 #354

Merged
ysCha merged 1 commits from dev into prd-deploy 2025-09-24 13:04:16 +09:00

View File

@ -18,6 +18,11 @@ const Trestle = forwardRef((props, ref) => {
const currentAngleType = useRecoilValue(currentAngleTypeSelector) const currentAngleType = useRecoilValue(currentAngleTypeSelector)
const pitchText = useRecoilValue(pitchTextSelector) const pitchText = useRecoilValue(pitchTextSelector)
const [selectedRoof, setSelectedRoof] = useState(null) const [selectedRoof, setSelectedRoof] = useState(null)
const [isAutoSelecting, setIsAutoSelecting] = useState(false) //
const [autoSelectTimeout, setAutoSelectTimeout] = useState(null) //
const autoSelectTimeoutRef = useRef(null)
// ()
const AUTO_SELECT_TIMEOUT = 700 // API
const { const {
trestleState, trestleState,
trestleDetail, trestleDetail,
@ -63,7 +68,7 @@ const Trestle = forwardRef((props, ref) => {
useEffect(() => { useEffect(() => {
if (roofs && !selectedRoof) { if (roofs && roofs.length > 0 && !selectedRoof) {
console.log("roofs:::::", roofs.length) console.log("roofs:::::", roofs.length)
setLengthBase(roofs[0].length); setLengthBase(roofs[0].length);
setSelectedRoof(roofs[0]) setSelectedRoof(roofs[0])
@ -71,12 +76,12 @@ const Trestle = forwardRef((props, ref) => {
if (selectedRoof && selectedRoof.lenAuth === "C") { if (selectedRoof && selectedRoof.lenAuth === "C") {
onChangeLength(selectedRoof.length); onChangeLength(selectedRoof.length);
} }
if (selectedRoof && ["C", "R"].includes(selectedRoof.raftAuth)) { if (selectedRoof && ["C", "R"].includes(selectedRoof.raftAuth) && roofs && roofs.length > 0) {
onChangeRaftBase(roofs[0]); onChangeRaftBase(roofs[0]);
} }
// //
restoreModuleInstArea() restoreModuleInstArea()
}, [roofs]) }, [roofs, selectedRoof]) // selectedRoof
useEffect(() => { useEffect(() => {
if (flag && moduleSelectionData) { if (flag && moduleSelectionData) {
@ -161,7 +166,7 @@ const Trestle = forwardRef((props, ref) => {
useEffect(() => { useEffect(() => {
if (constructionList.length > 0) { if (constructionList.length > 0) {
const existingConstruction = constructionList.find((construction) => construction.constTp === trestleState?.construction?.constTp) const existingConstruction = constructionList.find((construction) => construction.constTp === trestleState.constTp)
if (existingConstruction) { if (existingConstruction) {
setSelectedConstruction(existingConstruction) setSelectedConstruction(existingConstruction)
} else if (autoSelectStep === 'construction') { } else if (autoSelectStep === 'construction') {
@ -252,7 +257,7 @@ const Trestle = forwardRef((props, ref) => {
// () - // () -
setTimeout(() => { setTimeout(() => {
setAutoSelectStep('trestle') setAutoSelectStep('trestle')
}, 500) // API }, AUTO_SELECT_TIMEOUT) // API
} }
const onChangeHajebichi = (e) => { const onChangeHajebichi = (e) => {
@ -282,7 +287,7 @@ const Trestle = forwardRef((props, ref) => {
// () - // () -
setTimeout(() => { setTimeout(() => {
setAutoSelectStep('trestle') setAutoSelectStep('trestle')
}, 500) }, AUTO_SELECT_TIMEOUT)
} }
const onChangeTrestleMaker = (e) => { const onChangeTrestleMaker = (e) => {
@ -305,7 +310,7 @@ const Trestle = forwardRef((props, ref) => {
// API () // API ()
setTimeout(() => { setTimeout(() => {
setAutoSelectStep('constMthd') setAutoSelectStep('constMthd')
}, 300) }, AUTO_SELECT_TIMEOUT)
} }
const onChangeConstMthd = (e) => { const onChangeConstMthd = (e) => {
@ -325,10 +330,21 @@ const Trestle = forwardRef((props, ref) => {
}, },
}) })
//
if (autoSelectTimeoutRef.current) {
clearTimeout(autoSelectTimeoutRef.current)
}
//
setIsAutoSelecting(true)
// API () // API ()
setTimeout(() => { const timeoutId = setTimeout(() => {
setAutoSelectStep('roofBase') setAutoSelectStep('roofBase')
}, 300) setIsAutoSelecting(false)
}, AUTO_SELECT_TIMEOUT)
autoSelectTimeoutRef.current = timeoutId
} }
const onChangeRoofBase = (e) => { const onChangeRoofBase = (e) => {
@ -356,7 +372,7 @@ const Trestle = forwardRef((props, ref) => {
// API (construction) // API (construction)
setTimeout(() => { setTimeout(() => {
setAutoSelectStep('construction') setAutoSelectStep('construction')
}, 300) }, AUTO_SELECT_TIMEOUT)
} }
const handleConstruction = (index) => { const handleConstruction = (index) => {
@ -451,7 +467,7 @@ const Trestle = forwardRef((props, ref) => {
...selectedRoofBase, ...selectedRoofBase,
}, },
construction: { construction: {
...constructionList.find((data) => data.constTp === trestleState.constTp), ...constructionList.find((data) => newAddedRoofs[index].construction.constTp === data.constTp),
cvrYn, cvrYn,
snowGdPossYn, snowGdPossYn,
cvrChecked, cvrChecked,