diff --git a/src/pages/AssessorPage/Assessor.tsx b/src/pages/AssessorPage/Assessor.tsx index 3147bad..a71f696 100644 --- a/src/pages/AssessorPage/Assessor.tsx +++ b/src/pages/AssessorPage/Assessor.tsx @@ -1,12 +1,12 @@ -import { Tabs } from '@kobalte/core/tabs' -import { useNavigate } from '@solidjs/router' -import dayjs from 'dayjs' -import { FaSolidThumbsUp } from 'solid-icons/fa' -import { FiLogOut } from 'solid-icons/fi' -import { VsRefresh } from 'solid-icons/vs' -import { createEffect, createSignal, onMount } from 'solid-js' -import { Show } from 'solid-js/web' -import { Box, Button, Clickable, Column, Combobox, Input, Link, Logo, Modal, ModalButton, Padding, Page, Row } from '../../components' +import { Tabs } from '@kobalte/core/tabs'; +import { useNavigate } from '@solidjs/router'; +import dayjs from 'dayjs'; +import { FaSolidThumbsUp } from 'solid-icons/fa'; +import { FiLogOut } from 'solid-icons/fi'; +import { VsRefresh } from 'solid-icons/vs'; +import { createEffect, createSignal, onMount } from 'solid-js'; +import { Show } from 'solid-js/web'; +import { Box, Button, Clickable, Column, Combobox, Input, Link, Logo, Modal, ModalButton, Padding, Page, Row } from '../../components/index.ts'; import { _additional, _additionalAmountList, @@ -31,9 +31,9 @@ import { _totalUnits, _type, _units, -} from '../../stores/pdfinfo' -import { checkConnection, createPdfElectrical, createPdfOccupancy, getApi, getApiMulti, postApi, voidApi } from '../../utils/functions' -import './Assessor.sass' +} from '../../stores/pdfinfo.ts'; +import { checkConnection, createPdfElectrical, createPdfOccupancy, getApi, getApiMulti, postApi, statusPopsApi, voidPopsApi } from '../../utils/functions/index.ts'; +import './Assessor.sass'; const PESO = import.meta.env.VITE_PESO @@ -71,6 +71,8 @@ export default () => { const listType = ['Print', 'Reprint', 'Reprint and Void'] const [selectedType, setSelectedType] = createSignal('Print') + const [voidError, setVoidError] = createSignal(false) + let bldgadditional = false const checkAccess = async (access: string) => { @@ -334,6 +336,24 @@ export default () => { } if (selectedType().includes("Void")) { + const status = await statusPopsOp(application) + const message = status.message + + if (message.includes('No record')) { + setVoidError(true) + setErrorMessage("No record found on Pops") + return + } else { + const pops_paid = message.pops_paid + const epay_paid = message.epay_paid + + if (pops_paid || epay_paid) { + setVoidError(true) + setErrorMessage("Already Paid") + return + } + } + if (division === 'electrical') { await setNewStatus(division, 'ELECTRICAL ORDER OF PAYMENT REPRINTED', '175', 'ELECOPREPRINTED', 1) await setNewStatus(division, 'ELECTRICAL ORDERPAYMENT RELEASED', '97', 'ELECRELEASED', 1) @@ -346,10 +366,10 @@ export default () => { await updateDocflow(division, application, 'APPROVED FOR PRINTING OF BUREAU OF FIRE AND ORDER OF PAYMENT') } - await voidOp(application) + await voidPopsOp(application) + await postTransaction(application) } - postTransaction(application) setPrintedApplication(application) setPrinted(true) @@ -454,20 +474,25 @@ export default () => { if (isElectrical()) await getListForPrinting('electrical') } - const logout = async () => { + const logout = () => { removeEmployee() navigate('/') } - const gotoProfile = async () => { + const gotoProfile = () => { sessionStorage.setItem('name', employeeName()) navigate('/profile') } - const voidOp = async (application: string) => { - const response = await voidApi(application) - if (response !== null) return true - return false + const voidPopsOp = async (application: string) => { + const response = await voidPopsApi(application) + if (response.includes('Error')) return false + return true + } + + const statusPopsOp = async (application: string) => { + const response = await statusPopsApi(application) + return response } onMount(async () => { @@ -885,6 +910,28 @@ export default () => { + +
setVoidError(false)}> + + + + + +

Invalid Application Void

+
+
+ + +

{errorMessage()}

+
+ + + Click anywhere to close + +
+
+
+
) }