Updated main page
This commit is contained in:
parent
7f60d5a347
commit
ca95125188
1 changed files with 49 additions and 63 deletions
|
|
@ -147,11 +147,6 @@ export default () => {
|
|||
return total
|
||||
}
|
||||
|
||||
// const sample = async () => {
|
||||
// const data = await lockData('asdasdsadsad')
|
||||
// console.log(data)
|
||||
// }
|
||||
|
||||
const approveHandler = async (division: string, application: string) => {
|
||||
let signed: boolean = false
|
||||
let forprinting: boolean = false
|
||||
|
|
@ -169,54 +164,55 @@ export default () => {
|
|||
setIsLoading(true)
|
||||
setLoadingText('Checking POPS record')
|
||||
|
||||
if (division === 'electrical') {
|
||||
if (BACKEND.includes('localhost')) {
|
||||
const status = await checkStatusPopsLocal(application)
|
||||
if (status.result > 0) popsExist = true
|
||||
if (status.result2 > 0) popsPaid = true
|
||||
if (BACKEND.includes('localhost')) {
|
||||
const status = await checkStatusPopsLocal(application)
|
||||
if (status.result > 0) popsExist = 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 {
|
||||
const status = await await statusPopsOp(application)
|
||||
if (status.message === 'Success') popsExist = true
|
||||
if (status.pops_paid === true) popsPaid = true
|
||||
}
|
||||
if (BACKEND.includes('localhost')) {
|
||||
setLoadingText('Clearing unpaid POPS record')
|
||||
const voidOP = await voidPopsOpLocal(application)
|
||||
|
||||
if (popsExist) {
|
||||
if (popsPaid) {
|
||||
setIsLoading(false)
|
||||
setPostError(true)
|
||||
setErrorMessage('Application Already Paid')
|
||||
return
|
||||
if (!voidOP) {
|
||||
setIsLoading(false)
|
||||
setPostError(true)
|
||||
setErrorMessage('POPS Record found but failed to void')
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if (BACKEND.includes('localhost')) {
|
||||
const voidOP = await voidPopsOpLocal(application)
|
||||
setLoadingText('Clearing unpaid POPS record')
|
||||
const voidOP = await voidPopsOp(application)
|
||||
|
||||
if (!voidOP) {
|
||||
setIsLoading(false)
|
||||
setPostError(true)
|
||||
setErrorMessage('POPS Record found but failed to void')
|
||||
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
|
||||
}
|
||||
if (voidOP.toUpper().includes('ERROR')) {
|
||||
setIsLoading(false)
|
||||
setPostError(true)
|
||||
setErrorMessage('POPS Record found but failed to void')
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setLoadingText('Posting new record to POPS')
|
||||
await postPops(division, application)
|
||||
// const popsResult = await checkPops(application)
|
||||
setLoadingText(`Approving ${application}`)
|
||||
const dataLocked = await lockOpData(division, application)
|
||||
setLoadingText('Posting new record to POPS')
|
||||
await postPops(division, application)
|
||||
|
||||
if (dataLocked) {
|
||||
setLoadingText(`Approving ${application}`)
|
||||
const dataLocked = await lockOpData(division, application)
|
||||
|
||||
if (dataLocked) {
|
||||
if (division === 'electrical') {
|
||||
setLoadingText(`Pushing ${application} for printing`)
|
||||
signed = await setNewStatus(division, 'ELECTRICAL ORDER OF PAYMENT APPROVED AND SIGNED', '170', 'ELECOPAPPROVEDSIGNED', 1)
|
||||
updateDocflow(division, application, 'FOR ELECTRICAL ORDER OF PAYMENT APPROVAL')
|
||||
|
|
@ -232,22 +228,11 @@ export default () => {
|
|||
setApprovedApplication(application)
|
||||
setApproved(true)
|
||||
}
|
||||
} else {
|
||||
setIsLoading(false)
|
||||
setPostError(true)
|
||||
setErrorMessage('Error on posting on POPS Server, please try again')
|
||||
return
|
||||
}
|
||||
} else if (division === 'occupancy') {
|
||||
const additionalResult = await getApi('check-bldgadditional-approval', application)
|
||||
bldgadditional = additionalResult > 0
|
||||
} else if (division === 'occupancy') {
|
||||
setLoadingText('Checking for Building Additional')
|
||||
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)
|
||||
updateDocflow(division, application, 'FOR OCCUPANCY RECOMMENDING APPROVAL')
|
||||
if (bldgadditional) {
|
||||
|
|
@ -266,13 +251,14 @@ export default () => {
|
|||
setApprovedApplication(application)
|
||||
setApproved(true)
|
||||
}
|
||||
} else {
|
||||
setPostError(true)
|
||||
setErrorMessage('Error on posting on POPS Server, please try again')
|
||||
return
|
||||
}
|
||||
} else {
|
||||
setIsLoading(false)
|
||||
setPostError(true)
|
||||
setErrorMessage('Error on posting on POPS Server, please try again')
|
||||
return
|
||||
}
|
||||
setIsLoading(false)
|
||||
}
|
||||
|
||||
// const approveElectrical = async (division: string, application: string) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue