Added checking of connection

This commit is contained in:
Patrick Alvin Alcala 2025-10-02 17:54:51 +08:00
parent 060741fcba
commit 58eb2cb472
4 changed files with 54 additions and 2 deletions

View file

@ -5,6 +5,7 @@ import { Tabs } from '@kobalte/core/tabs'
import { ofetch } from 'ofetch'
import { onMount, createSignal } from 'solid-js'
import dayjs from 'dayjs'
import { checkConnection } from '../../utils/functions'
const API = import.meta.env.VITE_BACKEND
const PESO = import.meta.env.VITE_PESO
@ -30,6 +31,9 @@ export default () => {
const [applicationList, setApplicationList] = createSignal<string[]>([])
const [nameList, setNameList] = createSignal<string[]>([])
const [errorMessage, setErrorMessage] = createSignal('')
const [connected, setConnected] = createSignal(true)
const getListForApproval = async () => {
try {
const response = await ofetch(API + 'get-listopapproval-electrical', { parseResponse: JSON.parse })
@ -41,6 +45,12 @@ export default () => {
}
const load = async () => {
setConnected(await checkConnection())
if (connected() === false) {
setErrorMessage('Could not gather list of applicaitons')
return
}
await getListForApproval()
}
@ -86,11 +96,9 @@ export default () => {
signed = await setNewStatus('ELECTRICAL ORDER OF PAYMENT APPROVED AND SIGNED', '170', 'ELECOPAPPROVEDSIGNED')
if (signed) {
console.log('Signed')
forprinting = await setNewStatus('FOR ELECTRICAL ORDER OF PAYMENT PRINTING', '95', 'ELECOPPRINT')
}
if (forprinting) {
console.log('For Printing')
}
}