Updated main page

This commit is contained in:
Patrick Alvin Alcala 2025-10-01 16:18:50 +08:00
parent 3022a084be
commit 634bb6a209
2 changed files with 82 additions and 87 deletions

View file

@ -116,3 +116,7 @@ h1
&__detail &__detail
font-size: 1rem font-size: 1rem
&__price
font-size: 1.75rem
font-weight: 700

View file

@ -18,40 +18,43 @@ export default () => {
const [client, setClient] = createSignal('') const [client, setClient] = createSignal('')
const [location, setLocation] = createSignal('') const [location, setLocation] = createSignal('')
const [type, setType] = createSignal('') const [type, setType] = createSignal('')
const [applicationNo, setApplicationNo] = createSignal('')
const [applicationList, setApplicationList] = createSignal<string[]>([])
const [nameList, setNameList] = createSignal<string[]>([])
const getListForApproval = async () => { const getListForApproval = async () => {
try { try {
const response = await ofetch(API + 'get-listopapproval-electrical', { parseResponse: JSON.parse }) const response = await ofetch(API + 'get-listopapproval-electrical', { parseResponse: JSON.parse })
return response.result setApplicationList(response.result)
setNameList(response.result2)
} catch (error) { } catch (error) {
console.error(error) console.error(error)
} }
} }
const getListOfReadyForApprovalFiltered = async (list: number[]) => { // const getListOfReadyForApprovalFiltered = async (list: number[]) => {
let newList: number[] = [] // let newList: number[] = []
for (let i = 0; i < list.length; i++) { // for (let i = 0; i < list.length; i++) {
const response = await ofetch(API + 'get-laststatus-electrical/' + list[i], { parseResponse: JSON.parse }) // const response = await ofetch(API + 'get-laststatus-electrical/' + list[i], { parseResponse: JSON.parse })
if (response.result === 'FOR ELECTRICAL ORDER OF PAYMENT APPROVAL') { // if (response.result === 'FOR ELECTRICAL ORDER OF PAYMENT APPROVAL') {
newList.push(list[i]) // newList.push(list[i])
} // }
} // }
return [...newList] // return [...newList]
} // }
const getApplicationById = async (list: number[]) => { // const getApplicationById = async (list: number[]) => {
let applicationList: string[] = [] // let applicationList: string[] = []
for (let i = 0; i < list.length; i++) { // for (let i = 0; i < list.length; i++) {
const response = await ofetch(API + 'get-applicationbyid-electrical/' + list[i], { parseResponse: JSON.parse }) // const response = await ofetch(API + 'get-applicationbyid-electrical/' + list[i], { parseResponse: JSON.parse })
applicationList.push(response.result) // applicationList.push(response.result)
} // }
setUpdatedList([...applicationList]) // setUpdatedList([...applicationList])
} // }
const load = async () => { const load = async () => {
// const listForApproval = await getListForApproval() // const listForApproval = await getListForApproval()
@ -59,12 +62,11 @@ export default () => {
// await getApplicationById(listOfReadyForApprovalFiltered) // await getApplicationById(listOfReadyForApprovalFiltered)
// console.log(listOfReadyForApprovalFiltered) // console.log(listOfReadyForApprovalFiltered)
await getopdetails() await getListForApproval()
} }
const getopdetails = async () => { const getopdetails = async (applicationNo: string) => {
const op = await ofetch(API + 'get-opdetails-electrical/23512', { parseResponse: JSON.parse }) const op = await ofetch(API + 'get-opdetails-electrical/' + applicationNo, { parseResponse: JSON.parse })
setApplicationNo(op.result[0])
setAssessor(op.result7[0]) setAssessor(op.result7[0])
setLocation(op.result5[0]) setLocation(op.result5[0])
setType(op.result6[0]) setType(op.result6[0])
@ -74,33 +76,10 @@ export default () => {
} }
const calculateTotal = (list: number[]) => { const calculateTotal = (list: number[]) => {
let total = 0 const total = list.map((item) => parseFloat(item.toString())).reduce((acc, curr) => acc + curr, 0)
for (let i = 0; i < list.length; i++) {
total += parseInt(list[i].toString())
}
return total return total
} }
const getEmployeeName = async (id: string) => {
try {
const response = await ofetch(API + 'get-employeename/' + id, { parseResponse: JSON.parse })
const result = response.result
return result
} catch {
return ''
}
}
const getPaymentName = async (id: string) => {
try {
const response = await ofetch(API + 'get-paymentname/' + id, { parseResponse: JSON.parse })
const result = response.result
return result
} catch {
return ''
}
}
const displayFullname = (firstname: string, middleinitial: string, lastname: string) => { const displayFullname = (firstname: string, middleinitial: string, lastname: string) => {
let result let result
if (firstname.length > 0) { if (firstname.length > 0) {
@ -174,50 +153,62 @@ export default () => {
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> {applicationList().map((item, index) => (
<td>111</td> <tr>
<td>11</td> <td>{item}</td>
<td> <td>{nameList()[index]}</td>
<ModalButton class="modal" label="Show Details" design="bo-link" background="#121e2acc" color="#ffffffec">
<Padding top={0} left={2} right={2} bottom={0}>
<Box curved thickness={1} padding="1rem">
<span class="modal__application-number">{applicationNo()}</span>
</Box>
<section class="modal__row">
<span class="modal__row__label">Name of Applicant:</span>
<span class="modal__row__detail">{client()}</span>
</section>
<section class="modal__row"> <td>
<span class="modal__row__label">Location:</span> <ModalButton
<span class="modal__row__detail">{location()}</span> class="modal"
</section> label="Show Details"
design="bo-link"
background="#121e2acc"
color="#ffffffec"
function={async () => {
await getopdetails(item)
}}
>
<Padding top={0} left={2} right={2} bottom={0}>
<Box curved thickness={1} padding="1rem">
<span class="modal__application-number">{item}</span>
</Box>
<section class="modal__row">
<span class="modal__row__label">Name of Applicant:</span>
<span class="modal__row__detail">{nameList()[index]}</span>
</section>
<section class="modal__row"> <section class="modal__row">
<span class="modal__row__label">Type:</span> <span class="modal__row__label">Location:</span>
<span class="modal__row__detail">{type().toUpperCase()}</span> <span class="modal__row__detail">{location()}</span>
</section> </section>
<section class="modal__row"> <section class="modal__row">
<span class="modal__row__label">Assessed By:</span> <span class="modal__row__label">Type:</span>
<span class="modal__row__detail">{assessor()}</span> <span class="modal__row__detail">{type().toUpperCase()}</span>
</section> </section>
<section class="modal__row"> <section class="modal__row">
<span class="modal__row__label">Total Fee:</span> <span class="modal__row__label">Assessed By:</span>
<span class="modal__row__detail"> <span class="modal__row__detail">{assessor()}</span>
{PESO} {totalOp().toFixed(2)} </section>
</span>
</section>
<Row gap={1} padding="1rem 0 0 0"> <section class="modal__row">
<Button label="Disapprove" edges="curved" design="bo-danger"></Button> <span class="modal__row__label">Total Fee:</span>
<Button label="Approve" edges="curved" design="bo-primary"></Button> <span class="modal__row__detail__price">
</Row> {PESO} {totalOp().toFixed(2)}
</Padding> </span>
</ModalButton> </section>
</td>
</tr> <Row gap={12} padding="2rem 0 0 0">
<Button label="Disapprove" edges="curved" design="bo-danger"></Button>
<Button label="Approve" edges="curved" design="bo-primary"></Button>
</Row>
</Padding>
</ModalButton>
</td>
</tr>
))}
</tbody> </tbody>
</table> </table>
</Tabs.Content> </Tabs.Content>