Updated main page
This commit is contained in:
parent
f67721abff
commit
ab3351679a
2 changed files with 208 additions and 102 deletions
|
|
@ -7,12 +7,14 @@ import { VsRefresh } from 'solid-icons/vs'
|
|||
import { createEffect, createSignal, onMount } from 'solid-js'
|
||||
import { Show } from 'solid-js/web'
|
||||
import { Box, Button, Clickable, Column, Input, Link, Logo, Modal, ModalButton, Padding, Page, Row } from '../../components/'
|
||||
import { checkConnection, deleteApi, getApi, getApiMulti, getDateTime, lockData, postApi, saveNewName, saveNewPassword, securePassword, voidPopsApi } from '../../utils/functions'
|
||||
import { checkConnection, deleteApi, getApi, getApiMulti, getDateTime, lockData, postApi, saveNewName, saveNewPassword, securePassword, voidPopsApi, voidApi, statusPopsApi } from '../../utils/functions'
|
||||
import { AiOutlineLoading3Quarters } from 'solid-icons/ai'
|
||||
import './Main.sass'
|
||||
|
||||
const PESO = import.meta.env.VITE_PESO
|
||||
const ID = sessionStorage.getItem('id')!
|
||||
const PUBLICIP = import.meta.env.VITE_PUBLICIP
|
||||
const BACKEND = import.meta.env.VITE_BACKEND
|
||||
|
||||
export default () => {
|
||||
const navigate = useNavigate()
|
||||
|
|
@ -59,6 +61,7 @@ export default () => {
|
|||
|
||||
const [configNotification, setConfigNotification] = createSignal(false)
|
||||
const [isIncomplete, setIsIncomplete] = createSignal(false)
|
||||
const [isLoading, setIsLoading] = createSignal(false)
|
||||
|
||||
let bldgadditional = false
|
||||
|
||||
|
|
@ -73,15 +76,19 @@ export default () => {
|
|||
}
|
||||
|
||||
const getListForApprovalElectrical = async () => {
|
||||
// setIsLoading(true)
|
||||
const responseE = await getApiMulti('get-listopapproval-electrical')
|
||||
setApplicationListElectrical(responseE.result)
|
||||
setNameListElectrical(responseE.result2)
|
||||
// setIsLoading(false)
|
||||
}
|
||||
|
||||
const getListForApprovalOccupancy = async () => {
|
||||
// setIsLoading(true)
|
||||
const responseO = await getApiMulti('get-listopapproval-occupancy')
|
||||
setApplicationListOccupancy(responseO.result)
|
||||
setNameListOccupancy(responseO.result2)
|
||||
// setIsLoading(false)
|
||||
}
|
||||
|
||||
const load = async (division: string) => {
|
||||
|
|
@ -90,6 +97,7 @@ export default () => {
|
|||
setErrorMessage('Could not gather list of applications')
|
||||
return
|
||||
}
|
||||
setIsLoading(true)
|
||||
|
||||
await getPassword()
|
||||
|
||||
|
|
@ -101,6 +109,7 @@ export default () => {
|
|||
} else {
|
||||
await getListForApproval()
|
||||
}
|
||||
setIsLoading(false)
|
||||
}
|
||||
|
||||
const getopdetails = async (division: string, applicationNo: string) => {
|
||||
|
|
@ -148,6 +157,9 @@ export default () => {
|
|||
let forprinting: boolean = false
|
||||
let updateOrderofpayment: boolean = false
|
||||
|
||||
let popsExist: boolean = false
|
||||
let popsPaid: boolean = false
|
||||
|
||||
setConnected(await checkConnection())
|
||||
if (connected() === false) {
|
||||
setErrorMessage('No Connection on Server')
|
||||
|
|
@ -155,7 +167,35 @@ export default () => {
|
|||
}
|
||||
|
||||
if (division === 'electrical') {
|
||||
await voidPopsOp(application)
|
||||
// const isPaid = BACKEND.includes('localhost') ? await checkStatusPopsLocal(application) : await statusPopsOp(application)
|
||||
// let isPaid
|
||||
|
||||
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) {
|
||||
setPostError(true)
|
||||
setErrorMessage('Application Already Paid')
|
||||
return
|
||||
} else {
|
||||
const voidOP = BACKEND.includes('localhost') ? await voidPopsOpLocal(application) : await voidPopsOp(application)
|
||||
|
||||
if (!voidOP) {
|
||||
setPostError(true)
|
||||
setErrorMessage('POPS Record found but failed to void')
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await postPops(division, application)
|
||||
const popsResult = await checkPops(application)
|
||||
const lockResult = await lockOpData(division, application)
|
||||
|
|
@ -216,6 +256,37 @@ export default () => {
|
|||
}
|
||||
}
|
||||
|
||||
const approveElectrical = async (division: string, application: string) => {
|
||||
let signed: boolean = false
|
||||
let forprinting: boolean = false
|
||||
let updateOrderofpayment: boolean = false
|
||||
|
||||
await postPops(division, application)
|
||||
const popsResult = await checkPops(application)
|
||||
const lockResult = await lockOpData(division, application)
|
||||
|
||||
if (popsResult && lockResult) {
|
||||
signed = await setNewStatus(division, 'ELECTRICAL ORDER OF PAYMENT APPROVED AND SIGNED', '170', 'ELECOPAPPROVEDSIGNED', 1)
|
||||
updateDocflow(division, application, 'FOR ELECTRICAL ORDER OF PAYMENT APPROVAL')
|
||||
if (!signed) return
|
||||
|
||||
forprinting = await setNewStatus(division, 'FOR ELECTRICAL ORDER OF PAYMENT PRINTING', '95', 'ELECOPPRINT', 0)
|
||||
if (!forprinting) return
|
||||
|
||||
updateOrderofpayment = await updateOp(division)
|
||||
|
||||
if (updateOrderofpayment) {
|
||||
postTransaction()
|
||||
setApprovedApplication(application)
|
||||
setApproved(true)
|
||||
}
|
||||
} else {
|
||||
setPostError(true)
|
||||
setErrorMessage('Error on posting on POPS Server, please try again')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
const lockOpData = async (division: string, application: string) => {
|
||||
const dataToLock = await getApi(`get-opdata-${division}`, application)
|
||||
const lockedData = await lockData(dataToLock)
|
||||
|
|
@ -230,6 +301,21 @@ export default () => {
|
|||
return true
|
||||
}
|
||||
|
||||
const voidPopsOpLocal = async (application: string) => {
|
||||
const response = await voidApi('void-op-local', { data: application })
|
||||
return response
|
||||
}
|
||||
|
||||
const checkStatusPopsLocal = async (application: string) => {
|
||||
const response = await getApiMulti('check-statuspops-local', application)
|
||||
return response
|
||||
}
|
||||
|
||||
const statusPopsOp = async (application: string) => {
|
||||
const response = await statusPopsApi(application)
|
||||
return response
|
||||
}
|
||||
|
||||
const returnAssessment = async (division: string, application: string) => {
|
||||
const id = await getApplicationById(division, application)
|
||||
setApplicationId(id)
|
||||
|
|
@ -680,107 +766,117 @@ export default () => {
|
|||
</Padding>
|
||||
|
||||
<Row>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Application Number</th>
|
||||
<th>Name</th>
|
||||
<th style="text-align: center">Show Details</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{applicationListElectrical().map((item: string, index: number) => (
|
||||
<Show when={isLoading()}>
|
||||
<Padding top={2} bottom={0} right={10} left={10}>
|
||||
<Column gap={1}>
|
||||
<AiOutlineLoading3Quarters class="loading-spinner" size={42} opacity={0.8} />
|
||||
<span>Downloading Data</span>
|
||||
</Column>
|
||||
</Padding>
|
||||
</Show>
|
||||
<Show when={!isLoading()}>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>{item}</td>
|
||||
<td>{nameListElectrical()[index]}</td>
|
||||
|
||||
<td>
|
||||
<ModalButton
|
||||
class="modal"
|
||||
label="Show Details"
|
||||
design="bo-link"
|
||||
background="#121e2acc"
|
||||
color="#ffffffec"
|
||||
function={async () => {
|
||||
await getopdetails('electrical', item)
|
||||
}}
|
||||
>
|
||||
<Show when={isIncomplete()}>
|
||||
<Padding top={0} left={2} right={2} bottom={0}>
|
||||
<span class="modal__application-number">{item}</span>
|
||||
|
||||
<Padding top={1} left={0} right={0} bottom={0}>
|
||||
<Column padding="0 0 1rem 0">
|
||||
<Box curved thickness={3} color="#c85656" padding="1rem">
|
||||
<h2 class="incomplete__error">Signing Error</h2>
|
||||
</Box>
|
||||
<h3 class="incomplete__error">Missing Data Detected</h3>
|
||||
</Column>
|
||||
|
||||
<div class="incomplete">
|
||||
<Column>
|
||||
<span class="incomplete__text">Some required information is missing from the application details</span>
|
||||
<span class="incomplete__text">Please return to Assessment to complete the required fields</span>
|
||||
</Column>
|
||||
</div>
|
||||
</Padding>
|
||||
<Column padding="1rem 0 0 0">
|
||||
<Button wide label="Return to Assessment" edges="curved" design="bo-primary" onClick={() => returnAssessment('electrical', item)} />
|
||||
<span class="modal__cancel">Click anywhere to cancel</span>
|
||||
</Column>
|
||||
</Padding>
|
||||
</Show>
|
||||
|
||||
<Show when={!isIncomplete()}>
|
||||
<Padding top={0} left={2} right={2} bottom={0}>
|
||||
<span class="modal__application-number">{item}</span>
|
||||
|
||||
<Padding top={1} left={0} right={0} bottom={0}>
|
||||
<section class="modal__row">
|
||||
<span class="modal__row__label">Name of Applicant:</span>
|
||||
<span class="modal__row__detail">{nameListElectrical()[index]}</span>
|
||||
</section>
|
||||
|
||||
<section class="modal__row">
|
||||
<span class="modal__row__label">Location:</span>
|
||||
<span class="modal__row__detail">{location()}</span>
|
||||
</section>
|
||||
|
||||
<section class="modal__row">
|
||||
<span class="modal__row__label">Type:</span>
|
||||
<span class="modal__row__detail">{type().toUpperCase()}</span>
|
||||
</section>
|
||||
|
||||
<section class="modal__row">
|
||||
<span class="modal__row__label">Assessed By:</span>
|
||||
<span class="modal__row__detail">{assessor()}</span>
|
||||
</section>
|
||||
|
||||
<section class="modal__row">
|
||||
<span class="modal__row__label">Date Assessed:</span>
|
||||
<span class="modal__row__detail">{dateOp().toUpperCase()}</span>
|
||||
</section>
|
||||
|
||||
<section class="modal__row">
|
||||
<span class="modal__row__label">Total Fee:</span>
|
||||
<span class="modal__row__detail__price">
|
||||
{PESO} {totalOp()}
|
||||
</span>
|
||||
</section>
|
||||
</Padding>
|
||||
|
||||
<Column padding="2rem 0 0 0">
|
||||
<Button wide label="Approve" edges="curved" design="bo-primary" onClick={() => approveHandler('electrical', item)} />
|
||||
<span class="modal__cancel">Click anywhere to cancel</span>
|
||||
</Column>
|
||||
</Padding>
|
||||
</Show>
|
||||
</ModalButton>
|
||||
</td>
|
||||
<th>Application Number</th>
|
||||
<th>Name</th>
|
||||
<th style="text-align: center">Show Details</th>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</thead>
|
||||
<tbody>
|
||||
{applicationListElectrical().map((item: string, index: number) => (
|
||||
<tr>
|
||||
<td>{item}</td>
|
||||
<td>{nameListElectrical()[index]}</td>
|
||||
|
||||
<td>
|
||||
<ModalButton
|
||||
class="modal"
|
||||
label="Show Details"
|
||||
design="bo-link"
|
||||
background="#121e2acc"
|
||||
color="#ffffffec"
|
||||
function={async () => {
|
||||
await getopdetails('electrical', item)
|
||||
}}
|
||||
>
|
||||
<Show when={isIncomplete()}>
|
||||
<Padding top={0} left={2} right={2} bottom={0}>
|
||||
<span class="modal__application-number">{item}</span>
|
||||
|
||||
<Padding top={1} left={0} right={0} bottom={0}>
|
||||
<Column padding="0 0 1rem 0">
|
||||
<Box curved thickness={3} color="#c85656" padding="1rem">
|
||||
<h2 class="incomplete__error">Signing Error</h2>
|
||||
</Box>
|
||||
<h3 class="incomplete__error">Missing Data Detected</h3>
|
||||
</Column>
|
||||
|
||||
<div class="incomplete">
|
||||
<Column>
|
||||
<span class="incomplete__text">Some required information is missing from the application details</span>
|
||||
<span class="incomplete__text">Please return to Assessment to complete the required fields</span>
|
||||
</Column>
|
||||
</div>
|
||||
</Padding>
|
||||
<Column padding="1rem 0 0 0">
|
||||
<Button wide label="Return to Assessment" edges="curved" design="bo-primary" onClick={() => returnAssessment('electrical', item)} />
|
||||
<span class="modal__cancel">Click anywhere to cancel</span>
|
||||
</Column>
|
||||
</Padding>
|
||||
</Show>
|
||||
|
||||
<Show when={!isIncomplete()}>
|
||||
<Padding top={0} left={2} right={2} bottom={0}>
|
||||
<span class="modal__application-number">{item}</span>
|
||||
|
||||
<Padding top={1} left={0} right={0} bottom={0}>
|
||||
<section class="modal__row">
|
||||
<span class="modal__row__label">Name of Applicant:</span>
|
||||
<span class="modal__row__detail">{nameListElectrical()[index]}</span>
|
||||
</section>
|
||||
|
||||
<section class="modal__row">
|
||||
<span class="modal__row__label">Location:</span>
|
||||
<span class="modal__row__detail">{location()}</span>
|
||||
</section>
|
||||
|
||||
<section class="modal__row">
|
||||
<span class="modal__row__label">Type:</span>
|
||||
<span class="modal__row__detail">{type().toUpperCase()}</span>
|
||||
</section>
|
||||
|
||||
<section class="modal__row">
|
||||
<span class="modal__row__label">Assessed By:</span>
|
||||
<span class="modal__row__detail">{assessor()}</span>
|
||||
</section>
|
||||
|
||||
<section class="modal__row">
|
||||
<span class="modal__row__label">Date Assessed:</span>
|
||||
<span class="modal__row__detail">{dateOp().toUpperCase()}</span>
|
||||
</section>
|
||||
|
||||
<section class="modal__row">
|
||||
<span class="modal__row__label">Total Fee:</span>
|
||||
<span class="modal__row__detail__price">
|
||||
{PESO} {totalOp()}
|
||||
</span>
|
||||
</section>
|
||||
</Padding>
|
||||
|
||||
<Column padding="2rem 0 0 0">
|
||||
<Button wide label="Approve" edges="curved" design="bo-primary" onClick={() => approveHandler('electrical', item)} />
|
||||
<span class="modal__cancel">Click anywhere to cancel</span>
|
||||
</Column>
|
||||
</Padding>
|
||||
</Show>
|
||||
</ModalButton>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</Show>
|
||||
</Row>
|
||||
</Tabs.Content>
|
||||
</Tabs>
|
||||
|
|
@ -921,7 +1017,7 @@ export default () => {
|
|||
<Column>
|
||||
<Row>
|
||||
<Box curved thickness={3} color="#ffebebe6" padding="1rem">
|
||||
<h2>Signing Error</h2>
|
||||
<h2>Approval and Signing Error</h2>
|
||||
</Box>
|
||||
</Row>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue