Updated main page

This commit is contained in:
Patrick Alvin Alcala 2026-03-07 15:51:12 +08:00
parent 7f60d5a347
commit ca95125188

View file

@ -147,11 +147,6 @@ export default () => {
return total return total
} }
// const sample = async () => {
// const data = await lockData('asdasdsadsad')
// console.log(data)
// }
const approveHandler = async (division: string, application: string) => { const approveHandler = async (division: string, application: string) => {
let signed: boolean = false let signed: boolean = false
let forprinting: boolean = false let forprinting: boolean = false
@ -169,54 +164,55 @@ export default () => {
setIsLoading(true) setIsLoading(true)
setLoadingText('Checking POPS record') setLoadingText('Checking POPS record')
if (division === 'electrical') { if (BACKEND.includes('localhost')) {
if (BACKEND.includes('localhost')) { const status = await checkStatusPopsLocal(application)
const status = await checkStatusPopsLocal(application) if (status.result > 0) popsExist = true
if (status.result > 0) popsExist = true if (status.result2 > 0) popsPaid = true
if (status.result2 > 0) popsPaid = true } else {
const status = await await statusPopsOp(application)
if (status.message === 'Success') popsExist = true
if (status.pops_paid === true) popsPaid = true
}
if (popsExist) {
if (popsPaid) {
setIsLoading(false)
setPostError(true)
setErrorMessage('Application Already Paid')
return
} else { } else {
const status = await await statusPopsOp(application) if (BACKEND.includes('localhost')) {
if (status.message === 'Success') popsExist = true setLoadingText('Clearing unpaid POPS record')
if (status.pops_paid === true) popsPaid = true const voidOP = await voidPopsOpLocal(application)
}
if (popsExist) { if (!voidOP) {
if (popsPaid) { setIsLoading(false)
setIsLoading(false) setPostError(true)
setPostError(true) setErrorMessage('POPS Record found but failed to void')
setErrorMessage('Application Already Paid') return
return }
} else { } else {
if (BACKEND.includes('localhost')) { setLoadingText('Clearing unpaid POPS record')
const voidOP = await voidPopsOpLocal(application) const voidOP = await voidPopsOp(application)
if (!voidOP) { if (voidOP.toUpper().includes('ERROR')) {
setIsLoading(false) setIsLoading(false)
setPostError(true) setPostError(true)
setErrorMessage('POPS Record found but failed to void') setErrorMessage('POPS Record found but failed to void')
return return
}
} else {
setLoadingText('Clearing unpaid POPS record')
const voidOP = await voidPopsOp(application)
if (voidOP.toUpper().includes('ERROR')) {
setIsLoading(false)
setPostError(true)
setErrorMessage('POPS Record found but failed to void')
return
}
} }
} }
} }
}
setLoadingText('Posting new record to POPS') setLoadingText('Posting new record to POPS')
await postPops(division, application) await postPops(division, application)
// const popsResult = await checkPops(application)
setLoadingText(`Approving ${application}`)
const dataLocked = await lockOpData(division, application)
if (dataLocked) { setLoadingText(`Approving ${application}`)
const dataLocked = await lockOpData(division, application)
if (dataLocked) {
if (division === 'electrical') {
setLoadingText(`Pushing ${application} for printing`) setLoadingText(`Pushing ${application} for printing`)
signed = await setNewStatus(division, 'ELECTRICAL ORDER OF PAYMENT APPROVED AND SIGNED', '170', 'ELECOPAPPROVEDSIGNED', 1) signed = await setNewStatus(division, 'ELECTRICAL ORDER OF PAYMENT APPROVED AND SIGNED', '170', 'ELECOPAPPROVEDSIGNED', 1)
updateDocflow(division, application, 'FOR ELECTRICAL ORDER OF PAYMENT APPROVAL') updateDocflow(division, application, 'FOR ELECTRICAL ORDER OF PAYMENT APPROVAL')
@ -232,22 +228,11 @@ export default () => {
setApprovedApplication(application) setApprovedApplication(application)
setApproved(true) setApproved(true)
} }
} else { } else if (division === 'occupancy') {
setIsLoading(false) setLoadingText('Checking for Building Additional')
setPostError(true) const additionalResult = await getApi('check-bldgadditional-approval', application)
setErrorMessage('Error on posting on POPS Server, please try again') bldgadditional = additionalResult > 0
return
}
} else if (division === 'occupancy') {
const additionalResult = await getApi('check-bldgadditional-approval', application)
bldgadditional = additionalResult > 0
await voidPopsOp(application)
await postPops(division, application)
const popsResult = await checkPops(application)
const lockResult = await lockOpData(division, application)
if (popsResult && lockResult) {
signed = await setNewStatus(division, 'OCCUPANCY ORDER OF PAYMENT APPROVED AND SIGNED', '172', 'OCCOPAPPROVEDSIGNED', 1) signed = await setNewStatus(division, 'OCCUPANCY ORDER OF PAYMENT APPROVED AND SIGNED', '172', 'OCCOPAPPROVEDSIGNED', 1)
updateDocflow(division, application, 'FOR OCCUPANCY RECOMMENDING APPROVAL') updateDocflow(division, application, 'FOR OCCUPANCY RECOMMENDING APPROVAL')
if (bldgadditional) { if (bldgadditional) {
@ -266,13 +251,14 @@ export default () => {
setApprovedApplication(application) setApprovedApplication(application)
setApproved(true) setApproved(true)
} }
} else {
setPostError(true)
setErrorMessage('Error on posting on POPS Server, please try again')
return
} }
} else {
setIsLoading(false) setIsLoading(false)
setPostError(true)
setErrorMessage('Error on posting on POPS Server, please try again')
return
} }
setIsLoading(false)
} }
// const approveElectrical = async (division: string, application: string) => { // const approveElectrical = async (division: string, application: string) => {