+ | {item} |
+ {nameList()[index]} |
+
+
+ {
+ await getopdetails('electrical', item)
+ }}
+ >
+
+ {item}
+
+
+
+ Name of Applicant:
+ {nameList()[index]}
+
+
+
+ Location:
+ {location()}
+
+
+
+ Type:
+ {type().toUpperCase()}
+
+
+
+ Assessed By:
+ {assessor()}
+
+
+
+ Date Assessed:
+ {dateOp().toUpperCase()}
+
+
+
+ Total Fee:
+
+ {PESO} {totalOp().toFixed(2)}
+
+
+
+
+
+
Click anywhere to cancel
diff --git a/src/pages/MainPage/Main.tsx b/src/pages/MainPage/Main.tsx
index 8f2722a..cb55ecf 100644
--- a/src/pages/MainPage/Main.tsx
+++ b/src/pages/MainPage/Main.tsx
@@ -2,7 +2,6 @@ import './Main.sass'
import { Logo, Link, Page, Row, Padding, ModalButton, Box, Button, Modal, Column, Clickable } from '../../components/'
import { FiLogOut } from 'solid-icons/fi'
import { Tabs } from '@kobalte/core/tabs'
-import { ofetch } from 'ofetch'
import { onMount, createSignal } from 'solid-js'
import dayjs from 'dayjs'
import { checkConnection, getApi, getApiMulti, postApi } from '../../utils/functions'
@@ -13,7 +12,6 @@ import { _applicationNo, _date, _optn, _name, _location, _type, _assessor, _feeL
import { VsRefresh } from 'solid-icons/vs'
import { BiRegularErrorAlt } from 'solid-icons/bi'
-const API = import.meta.env.VITE_BACKEND
const PESO = import.meta.env.VITE_PESO
const ID = import.meta.env.VITE_HEADID
// const NAME = import.meta.env.VITE_HEAD
@@ -265,10 +263,7 @@ export default () => {
const formattedDatewithTime = dayjs(today).format('YYYY-MM-DD HH:mm:ss')
for (let i = 0; i < response.result.length; i++) {
- await ofetch(API + 'post-pops', {
- method: 'POST',
- body: { data: application, data2: formattedDate, data3: customerid, data4: customerName, data5: location, data6: codeList[i], data7: amountList[i], data8: assessor(), data9: formattedDatewithTime, data10: lguList[i], data11: dpwhList[i], data12: boList[i], data13: PUBLICIP },
- })
+ await postApi('post-pops', { data: application, data2: formattedDate, data3: customerid, data4: customerName, data5: location, data6: codeList[i], data7: amountList[i], data8: assessor(), data9: formattedDatewithTime, data10: lguList[i], data11: dpwhList[i], data12: boList[i], data13: PUBLICIP })
}
}
@@ -335,10 +330,7 @@ export default () => {
const today = new Date()
const formatedDate = dayjs(today).format('YYYY-MM-DD HH:mm:ss')
- await ofetch(API + 'post-esigntransaction', {
- method: 'POST',
- body: { data: parseInt(id), data2: approvedApplication(), data3: formatedDate },
- })
+ await postApi('post-esigntransaction', { data: parseInt(id), data2: approvedApplication(), data3: formatedDate })
}
const updateDocflow = async (division: string, applicationid: number, status: string) => {
diff --git a/src/utils/functions/getApi.ts b/src/utils/functions/getApi.ts
index c902370..9677087 100644
--- a/src/utils/functions/getApi.ts
+++ b/src/utils/functions/getApi.ts
@@ -1,14 +1,37 @@
+// import { ofetch } from 'ofetch'
+
+// const API = import.meta.env.VITE_BACKEND
+
+// export default async (api: string, value?: any) => {
+// try {
+// let fetch
+// if (!value) {
+// fetch = await ofetch(API + api, { parseResponse: JSON.parse, retry: 3, retryDelay: 500, retryStatusCodes: [400, 404, 405, 500, 502] })
+// } else {
+// fetch = await ofetch(API + `${api}/${value}`, { parseResponse: JSON.parse, retry: 3, retryDelay: 500, retryStatusCodes: [400, 404, 405, 500, 502] })
+// }
+// const result = fetch.result
+// return result
+// } catch {
+// return []
+// }
+// }
+
import { ofetch } from 'ofetch'
const API = import.meta.env.VITE_BACKEND
-export default async (api: string, value?: any) => {
+export default async (api: string, value?: any, value2?: any) => {
try {
let fetch
- if (!value) {
- fetch = await ofetch(API + api, { parseResponse: JSON.parse, retry: 3, retryDelay: 500, retryStatusCodes: [400, 404, 405, 500, 502] })
+ if (!value2) {
+ if (!value) {
+ fetch = await ofetch(API + api, { parseResponse: JSON.parse, retry: 3, retryDelay: 500, retryStatusCodes: [400, 404, 405, 500, 502] })
+ } else {
+ fetch = await ofetch(API + `${api}/${value}/fetch-data`, { parseResponse: JSON.parse, retry: 3, retryDelay: 500, retryStatusCodes: [400, 404, 405, 500, 502] })
+ }
} else {
- fetch = await ofetch(API + `${api}/${value}`, { parseResponse: JSON.parse, retry: 3, retryDelay: 500, retryStatusCodes: [400, 404, 405, 500, 502] })
+ fetch = await ofetch(API + `${api}/${value}/${value2}/fetch-data`, { parseResponse: JSON.parse, retry: 3, retryDelay: 500, retryStatusCodes: [400, 404, 405, 500, 502] })
}
const result = fetch.result
return result
diff --git a/src/utils/functions/getApiMulti.ts b/src/utils/functions/getApiMulti.ts
index c595379..7b9d70e 100644
--- a/src/utils/functions/getApiMulti.ts
+++ b/src/utils/functions/getApiMulti.ts
@@ -8,7 +8,7 @@ export default async (api: string, value?: any) => {
if (!value) {
fetch = await ofetch(API + api, { parseResponse: JSON.parse, retry: 3, retryDelay: 500, retryStatusCodes: [400, 404, 405, 500, 502] })
} else {
- fetch = await ofetch(API + `${api}/${value}`, { parseResponse: JSON.parse, retry: 3, retryDelay: 500, retryStatusCodes: [400, 404, 405, 500, 502] })
+ fetch = await ofetch(API + `${api}/${value}/fetch-data`, { parseResponse: JSON.parse, retry: 3, retryDelay: 500, retryStatusCodes: [400, 404, 405, 500, 502] })
}
return fetch
diff --git a/src/utils/functions/index.ts b/src/utils/functions/index.ts
index d78b458..65794fc 100644
--- a/src/utils/functions/index.ts
+++ b/src/utils/functions/index.ts
@@ -3,4 +3,3 @@ export { default as createPdf } from './createPdf'
export { default as postApi } from './postApi'
export { default as getApi } from './getApi'
export { default as getApiMulti } from './getApiMulti'
-// export { default as generateFavicon } from './generateFavicon'
diff --git a/src/utils/functions/postApi.ts b/src/utils/functions/postApi.ts
index 7195db6..87bb1e2 100644
--- a/src/utils/functions/postApi.ts
+++ b/src/utils/functions/postApi.ts
@@ -1,6 +1,6 @@
import { ofetch } from 'ofetch'
-import encryptAes from './encryptAes'
import dayjs from 'dayjs'
+import encryptRsa from './encryptRsa'
const API = import.meta.env.VITE_BACKEND
@@ -8,9 +8,9 @@ export default async (api: string, body: Object) => {
const today = new Date()
const todayUnix = dayjs(today).unix()
const expiration = todayUnix + 9
- const aes = await encryptAes(`${todayUnix.toString()}-${expiration.toString()}`)
+ const aes = await encryptRsa(`${api.toString()}-${todayUnix.toString()}-${expiration.toString()}`)
- const hash = `ocbo-${aes}-token`
+ const hash = `ocbo=${aes}token`
try {
await ofetch(API + api, {
headers: {
@@ -18,6 +18,9 @@ export default async (api: string, body: Object) => {
'Cache-Control': 'no-cache',
'OCBO-Token': hash,
},
+ retry: 3,
+ retryDelay: 500,
+ retryStatusCodes: [400, 404, 405, 500, 502],
method: 'POST',
body: body,
})
|