From 634bb6a20932fd60a087dc7f79b6532451312462 Mon Sep 17 00:00:00 2001 From: Patrick Alvin Alcala Date: Wed, 1 Oct 2025 16:18:50 +0800 Subject: [PATCH] Updated main page --- src/pages/MainPage/Main.sass | 4 + src/pages/MainPage/Main.tsx | 165 +++++++++++++++++------------------ 2 files changed, 82 insertions(+), 87 deletions(-) diff --git a/src/pages/MainPage/Main.sass b/src/pages/MainPage/Main.sass index 787c898..e3a9cc8 100644 --- a/src/pages/MainPage/Main.sass +++ b/src/pages/MainPage/Main.sass @@ -116,3 +116,7 @@ h1 &__detail font-size: 1rem + + &__price + font-size: 1.75rem + font-weight: 700 diff --git a/src/pages/MainPage/Main.tsx b/src/pages/MainPage/Main.tsx index f87ef00..49b7943 100644 --- a/src/pages/MainPage/Main.tsx +++ b/src/pages/MainPage/Main.tsx @@ -18,40 +18,43 @@ export default () => { const [client, setClient] = createSignal('') const [location, setLocation] = createSignal('') const [type, setType] = createSignal('') - const [applicationNo, setApplicationNo] = createSignal('') + + const [applicationList, setApplicationList] = createSignal([]) + const [nameList, setNameList] = createSignal([]) const getListForApproval = async () => { try { const response = await ofetch(API + 'get-listopapproval-electrical', { parseResponse: JSON.parse }) - return response.result + setApplicationList(response.result) + setNameList(response.result2) } catch (error) { console.error(error) } } - const getListOfReadyForApprovalFiltered = async (list: number[]) => { - let newList: number[] = [] + // const getListOfReadyForApprovalFiltered = async (list: number[]) => { + // let newList: number[] = [] - for (let i = 0; i < list.length; i++) { - const response = await ofetch(API + 'get-laststatus-electrical/' + list[i], { parseResponse: JSON.parse }) - if (response.result === 'FOR ELECTRICAL ORDER OF PAYMENT APPROVAL') { - newList.push(list[i]) - } - } + // for (let i = 0; i < list.length; i++) { + // const response = await ofetch(API + 'get-laststatus-electrical/' + list[i], { parseResponse: JSON.parse }) + // if (response.result === 'FOR ELECTRICAL ORDER OF PAYMENT APPROVAL') { + // newList.push(list[i]) + // } + // } - return [...newList] - } + // return [...newList] + // } - const getApplicationById = async (list: number[]) => { - let applicationList: string[] = [] + // const getApplicationById = async (list: number[]) => { + // let applicationList: string[] = [] - for (let i = 0; i < list.length; i++) { - const response = await ofetch(API + 'get-applicationbyid-electrical/' + list[i], { parseResponse: JSON.parse }) - applicationList.push(response.result) - } + // for (let i = 0; i < list.length; i++) { + // const response = await ofetch(API + 'get-applicationbyid-electrical/' + list[i], { parseResponse: JSON.parse }) + // applicationList.push(response.result) + // } - setUpdatedList([...applicationList]) - } + // setUpdatedList([...applicationList]) + // } const load = async () => { // const listForApproval = await getListForApproval() @@ -59,12 +62,11 @@ export default () => { // await getApplicationById(listOfReadyForApprovalFiltered) // console.log(listOfReadyForApprovalFiltered) - await getopdetails() + await getListForApproval() } - const getopdetails = async () => { - const op = await ofetch(API + 'get-opdetails-electrical/23512', { parseResponse: JSON.parse }) - setApplicationNo(op.result[0]) + const getopdetails = async (applicationNo: string) => { + const op = await ofetch(API + 'get-opdetails-electrical/' + applicationNo, { parseResponse: JSON.parse }) setAssessor(op.result7[0]) setLocation(op.result5[0]) setType(op.result6[0]) @@ -74,33 +76,10 @@ export default () => { } const calculateTotal = (list: number[]) => { - let total = 0 - for (let i = 0; i < list.length; i++) { - total += parseInt(list[i].toString()) - } + const total = list.map((item) => parseFloat(item.toString())).reduce((acc, curr) => acc + curr, 0) 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) => { let result if (firstname.length > 0) { @@ -174,50 +153,62 @@ export default () => { - - 111 - 11 - - - - - {applicationNo()} - - + {applicationList().map((item, index) => ( + + {item} + {nameList()[index]} - + + { + await getopdetails(item) + }} + > + + + {item} + + - + - + - + - - - - - - - - + + + + + + + + + + + ))}