diff --git a/src/pages/MainPage/Main.tsx b/src/pages/MainPage/Main.tsx index 0d9c6ca..85f52fb 100644 --- a/src/pages/MainPage/Main.tsx +++ b/src/pages/MainPage/Main.tsx @@ -59,6 +59,7 @@ export default () => { const [postError, setPostError] = createSignal(false) const [configNotification, setConfigNotification] = createSignal(false) + const [isIncomplete, setIsIncomplete] = createSignal(false) let bldgadditional = false @@ -111,17 +112,26 @@ export default () => { op = await getApiMulti('get-opdetails-occupancy', applicationNo) } - setLocation(op.result[0]) - setType(op.result2[0]) - setAssessor(op.result3[0]) - const total = calculateTotal(op.result4) - const formattedTotal = new Intl.NumberFormat('en-US', { - minimumFractionDigits: 2, - maximumFractionDigits: 2, - }).format(total) - setTotalOp(formattedTotal) - setDateOp(dayjs(op.result5[0]).format('MMMM DD, YYYY')) - setApplicationId(op.result6[0]) + if (isDetailsComplete(op.result, op.result2, op.result3, op.result4, op.result5, op.result6)) { + setIsIncomplete(false) + setLocation(op.result[0]) + setType(op.result2[0]) + setAssessor(op.result3[0]) + const total = calculateTotal(op.result4) + const formattedTotal = new Intl.NumberFormat('en-US', { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + }).format(total) + setTotalOp(formattedTotal) + setDateOp(dayjs(op.result5[0]).format('MMMM DD, YYYY')) + setApplicationId(op.result6[0]) + } else { + setIsIncomplete(true) + } + } + + const isDetailsComplete = (result: string[], result2: string[], result3: string[], result4: string[], result5: string[], result6: string[]) => { + return result.length > 0 && result2.length > 0 && result3.length > 0 && result4.length > 0 && result5.length > 0 && result6.length > 0 ? false : false } const calculateTotal = (list: number[]) => { @@ -846,6 +856,32 @@ export default () => { + +