Added checking of missing data

This commit is contained in:
Patrick Alvin Alcala 2026-02-24 18:48:22 +08:00
parent eb80b12e62
commit 72abd22fee

View file

@ -59,6 +59,7 @@ export default () => {
const [postError, setPostError] = createSignal(false) const [postError, setPostError] = createSignal(false)
const [configNotification, setConfigNotification] = createSignal(false) const [configNotification, setConfigNotification] = createSignal(false)
const [isIncomplete, setIsIncomplete] = createSignal(false)
let bldgadditional = false let bldgadditional = false
@ -111,17 +112,26 @@ export default () => {
op = await getApiMulti('get-opdetails-occupancy', applicationNo) op = await getApiMulti('get-opdetails-occupancy', applicationNo)
} }
setLocation(op.result[0]) if (isDetailsComplete(op.result, op.result2, op.result3, op.result4, op.result5, op.result6)) {
setType(op.result2[0]) setIsIncomplete(false)
setAssessor(op.result3[0]) setLocation(op.result[0])
const total = calculateTotal(op.result4) setType(op.result2[0])
const formattedTotal = new Intl.NumberFormat('en-US', { setAssessor(op.result3[0])
minimumFractionDigits: 2, const total = calculateTotal(op.result4)
maximumFractionDigits: 2, const formattedTotal = new Intl.NumberFormat('en-US', {
}).format(total) minimumFractionDigits: 2,
setTotalOp(formattedTotal) maximumFractionDigits: 2,
setDateOp(dayjs(op.result5[0]).format('MMMM DD, YYYY')) }).format(total)
setApplicationId(op.result6[0]) 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[]) => { const calculateTotal = (list: number[]) => {
@ -846,6 +856,32 @@ export default () => {
</Padding> </Padding>
</Modal> </Modal>
</div> </div>
<div onClick={() => setIsIncomplete(false)}>
<Modal trigger={isIncomplete() === true} background="#562020ff" color="#ffebebe6" opacity={0.8}>
<Padding top={1} bottom={1} left={4} right={4}>
<Column>
<Row>
<Box curved thickness={3} color="#ffebebe6" padding="1rem">
<h2>Incomplete Data</h2>
</Box>
</Row>
<Row>
<h2>Some Data were missing</h2>
</Row>
<Row>
<h4>To avoid further error, application will be automatically pushed back on Assessment for correction</h4>
</Row>
<Row>
<span class="close-text">Click anywhere to close</span>
</Row>
</Column>
</Padding>
</Modal>
</div>
</> </>
) )
} }