Trestle 데이터 추가 수정

This commit is contained in:
김민식 2025-04-02 16:54:04 +09:00
parent ebbf010e6e
commit 648c2e208a
2 changed files with 17 additions and 1 deletions

View File

@ -18,6 +18,7 @@ const Trestle = forwardRef((props, ref) => {
const [selectedRoof, setSelectedRoof] = useState() const [selectedRoof, setSelectedRoof] = useState()
const { const {
trestleState, trestleState,
trestleDetail,
dispatch, dispatch,
raftBaseList, raftBaseList,
trestleList, trestleList,
@ -171,6 +172,7 @@ const Trestle = forwardRef((props, ref) => {
snowGdPossYn, snowGdPossYn,
cvrChecked, cvrChecked,
snowGdChecked, snowGdChecked,
trestleDetail,
} }
} }
return { ...roof } return { ...roof }
@ -224,6 +226,7 @@ const Trestle = forwardRef((props, ref) => {
snowGdPossYn, snowGdPossYn,
cvrChecked, cvrChecked,
snowGdChecked, snowGdChecked,
trestleDetail,
} }
} }
return { ...roof } return { ...roof }
@ -258,16 +261,22 @@ const Trestle = forwardRef((props, ref) => {
setRoofs(newAddedRoofs) setRoofs(newAddedRoofs)
setModuleSelectionData({ setModuleSelectionData({
...moduleSelectionData, ...moduleSelectionData,
roofConstructions: newAddedRoofs.map((roof) => { roofConstructions: newAddedRoofs.map((roof, index) => {
return { return {
addRoof: { addRoof: {
...roof.addRoof, ...roof.addRoof,
...moduleSelectionData.roofConstructions[index].addRoof,
}, },
trestle: { trestle: {
...roof.trestle, ...roof.trestle,
...moduleSelectionData.roofConstructions[index].trestle,
}, },
construction: { construction: {
...roof.construction, ...roof.construction,
...moduleSelectionData.roofConstructions[index].construction,
},
trestleDetail: {
...roof.trestleDetail,
}, },
} }
}), }),

View File

@ -64,6 +64,7 @@ export function useModuleTrestle(props) {
const [ridgeMargin, setRidgeMargin] = useState(0) const [ridgeMargin, setRidgeMargin] = useState(0)
const [kerabaMargin, setKerabaMargin] = useState(0) const [kerabaMargin, setKerabaMargin] = useState(0)
const [trestleState, dispatch] = useReducer(trestleReducer, null) const [trestleState, dispatch] = useReducer(trestleReducer, null)
const [trestleDetail, setTrestleDetail] = useState(null)
useEffect(() => { useEffect(() => {
const raftCodeList = findCommonCode(RAFT_BASE_CODE) const raftCodeList = findCommonCode(RAFT_BASE_CODE)
@ -90,6 +91,7 @@ export function useModuleTrestle(props) {
setConstMthdList([]) setConstMthdList([])
setRoofBaseList([]) setRoofBaseList([])
setConstructionList([]) setConstructionList([])
setTrestleDetail(null)
return return
} }
@ -97,17 +99,20 @@ export function useModuleTrestle(props) {
if (!trestleState.constMthdCd) { if (!trestleState.constMthdCd) {
setRoofBaseList([]) setRoofBaseList([])
setConstructionList([]) setConstructionList([])
setTrestleDetail(null)
return return
} }
handleSetRoofBaseList() handleSetRoofBaseList()
if (!trestleState.roofBaseCd) { if (!trestleState.roofBaseCd) {
setConstructionList([]) setConstructionList([])
setTrestleDetail(null)
return return
} }
handleSetConstructionList() handleSetConstructionList()
if (!trestleState.constTp) { if (!trestleState.constTp) {
setTrestleDetail(null)
return return
} }
@ -193,6 +198,7 @@ export function useModuleTrestle(props) {
setEavesMargin(res[0].data.eaveIntvl) setEavesMargin(res[0].data.eaveIntvl)
setRidgeMargin(res[0].data.ridgeIntvl) setRidgeMargin(res[0].data.ridgeIntvl)
setKerabaMargin(res[0].data.kerabaIntvl) setKerabaMargin(res[0].data.kerabaIntvl)
setTrestleDetail(res[0].data)
// dispatch({ // dispatch({
// type: 'SET_TRESTLE_DETAIL', // type: 'SET_TRESTLE_DETAIL',
// roof: { // roof: {
@ -208,6 +214,7 @@ export function useModuleTrestle(props) {
return { return {
trestleState, trestleState,
trestleDetail,
dispatch, dispatch,
raftBaseList, raftBaseList,
trestleList, trestleList,