fetching error: TypeError: Cannot read properties of undefined (reading 'planNo')
at eval (useRoofAllocationSetting.js:179:26)
at async fetchBasicSettings (useRoofAllocationSetting.js:112:7)
This commit is contained in:
parent
d37b191139
commit
f912a8474e
@ -86,7 +86,7 @@ export default function ContextRoofAllocationSetting(props) {
|
|||||||
return (
|
return (
|
||||||
<div className="grid-option-box" key={index}>
|
<div className="grid-option-box" key={index}>
|
||||||
<div className="d-check-radio pop no-text">
|
<div className="d-check-radio pop no-text">
|
||||||
<input type="radio" name="radio01" checked={roof.selected && 'checked'} readOnly={true} />
|
<input type="radio" name="radio01" checked={!!roof.selected} readOnly={true} />
|
||||||
<label
|
<label
|
||||||
htmlFor="ra01"
|
htmlFor="ra01"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
@ -189,7 +189,7 @@ export default function ContextRoofAllocationSetting(props) {
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
className="input-origin block"
|
className="input-origin block"
|
||||||
value={roof.hajebichi === '' ? '0' : roof.hajebichi}
|
value={roof.hajebichi ?? ''}
|
||||||
readOnly={roof.roofPchAuth === 'R'}
|
readOnly={roof.roofPchAuth === 'R'}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
e.target.value = normalizeDigits(e.target.value)
|
e.target.value = normalizeDigits(e.target.value)
|
||||||
@ -211,8 +211,7 @@ export default function ContextRoofAllocationSetting(props) {
|
|||||||
e.target.value = normalizeDecimalLimit(e.target.value, 2)
|
e.target.value = normalizeDecimalLimit(e.target.value, 2)
|
||||||
handleChangePitch(e, index)
|
handleChangePitch(e, index)
|
||||||
}}
|
}}
|
||||||
value={currentAngleType === 'slope' ? (roof.pitch || '0') : (roof.angle || '0')}
|
value={currentAngleType === 'slope' ? (roof.pitch ?? '') : (roof.angle ?? '')}
|
||||||
defaultValue={currentAngleType === 'slope' ? (roof.pitch || '0') : (roof.angle || '0')}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<span className="absol">{pitchText}</span>
|
<span className="absol">{pitchText}</span>
|
||||||
|
|||||||
@ -86,7 +86,7 @@ export default function RoofAllocationSetting(props) {
|
|||||||
return (
|
return (
|
||||||
<div className="grid-option-box" key={index}>
|
<div className="grid-option-box" key={index}>
|
||||||
<div className="d-check-radio pop no-text">
|
<div className="d-check-radio pop no-text">
|
||||||
<input type="radio" name="radio01" checked={roof.selected} readOnly />
|
<input type="radio" name="radio01" checked={!!roof.selected} readOnly />
|
||||||
<label
|
<label
|
||||||
htmlFor="ra01"
|
htmlFor="ra01"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
@ -194,7 +194,7 @@ export default function RoofAllocationSetting(props) {
|
|||||||
e.target.value = normalizeDigits(e.target.value)
|
e.target.value = normalizeDigits(e.target.value)
|
||||||
handleChangeInput(e, 'hajebichi', index)
|
handleChangeInput(e, 'hajebichi', index)
|
||||||
}}
|
}}
|
||||||
value={parseInt(roof.hajebichi)}
|
value={roof.hajebichi ?? ''}
|
||||||
readOnly={roof.roofPchAuth === 'R'}
|
readOnly={roof.roofPchAuth === 'R'}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -212,7 +212,7 @@ export default function RoofAllocationSetting(props) {
|
|||||||
e.target.value = normalizeDecimalLimit(e.target.value, 2)
|
e.target.value = normalizeDecimalLimit(e.target.value, 2)
|
||||||
handleChangePitch(e, index)
|
handleChangePitch(e, index)
|
||||||
}}
|
}}
|
||||||
value={currentAngleType === 'slope' ? roof.pitch : roof.angle}
|
value={currentAngleType === 'slope' ? (roof.pitch ?? '') : (roof.angle ?? '')}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<span className="absol">{pitchText}</span>
|
<span className="absol">{pitchText}</span>
|
||||||
|
|||||||
@ -174,22 +174,32 @@ export function useRoofAllocationSetting(id) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const firstRes = Array.isArray(res) && res.length > 0 ? res[0] : null
|
||||||
|
|
||||||
setBasicSetting({
|
setBasicSetting({
|
||||||
...basicSetting,
|
...basicSetting,
|
||||||
planNo: res[0].planNo,
|
planNo: firstRes?.planNo ?? planNo,
|
||||||
roofSizeSet: res[0].roofSizeSet,
|
roofSizeSet: firstRes?.roofSizeSet ?? 0,
|
||||||
roofAngleSet: res[0].roofAngleSet,
|
roofAngleSet: firstRes?.roofAngleSet ?? 0,
|
||||||
roofsData: roofsArray,
|
roofsData: roofsArray,
|
||||||
selectedRoofMaterial: selectRoofs.find((roof) => roof.selected),
|
selectedRoofMaterial: selectRoofs.find((roof) => roof.selected),
|
||||||
})
|
})
|
||||||
|
|
||||||
setBasicInfo({
|
setBasicInfo({
|
||||||
planNo: '' + res[0].planNo,
|
planNo: '' + (firstRes?.planNo ?? planNo),
|
||||||
roofSizeSet: '' + res[0].roofSizeSet,
|
roofSizeSet: '' + (firstRes?.roofSizeSet ?? 0),
|
||||||
roofAngleSet: '' + res[0].roofAngleSet,
|
roofAngleSet: '' + (firstRes?.roofAngleSet ?? 0),
|
||||||
})
|
})
|
||||||
//데이터 동기화
|
// 데이터 동기화: 렌더링용 필드 기본값 보정
|
||||||
setCurrentRoofList(selectRoofs)
|
const normalizedRoofs = selectRoofs.map((roof) => ({
|
||||||
|
...roof,
|
||||||
|
width: roof.width ?? '',
|
||||||
|
length: roof.length ?? '',
|
||||||
|
hajebichi: roof.hajebichi ?? '',
|
||||||
|
pitch: roof.pitch ?? '',
|
||||||
|
angle: roof.angle ?? '',
|
||||||
|
}))
|
||||||
|
setCurrentRoofList(normalizedRoofs)
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Data fetching error:', error)
|
console.error('Data fetching error:', error)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user