From 96ab5314321e307527811d04e6c222ac867ebcff Mon Sep 17 00:00:00 2001 From: Patrick Alvin Alcala Date: Wed, 29 Oct 2025 19:42:40 +0800 Subject: [PATCH] Added filter search (unfinish) --- src/pages/AssessorPage/Assessor.tsx | 72 +++++++++++++++++++---------- 1 file changed, 47 insertions(+), 25 deletions(-) diff --git a/src/pages/AssessorPage/Assessor.tsx b/src/pages/AssessorPage/Assessor.tsx index b047e78..b292998 100644 --- a/src/pages/AssessorPage/Assessor.tsx +++ b/src/pages/AssessorPage/Assessor.tsx @@ -1,5 +1,5 @@ import './Assessor.sass' -import { Logo, Page, Row, Padding, ModalButton, Button, Clickable, Link, Modal, Column, Box } from '../../components' +import { Logo, Page, Row, Padding, ModalButton, Button, Clickable, Link, Modal, Column, Box, Input } from '../../components' import { FiLogOut } from 'solid-icons/fi' import { Tabs } from '@kobalte/core/tabs' import { ofetch } from 'ofetch' @@ -10,6 +10,7 @@ import { FaSolidThumbsUp } from 'solid-icons/fa' import { _employeeName, _employeeId } from '../../stores/employee' import { useNavigate } from '@solidjs/router' import { _applicationNo, _date, _optn, _name, _location, _type, _assessor, _feeList, _codeList, _amountList, _signatureAssessor, _signatureApprover, _assessorid, _approvedDate, _assessedDate } from '../../stores/pdfinfo' +import { VsRefresh } from 'solid-icons/vs' const API = import.meta.env.VITE_BACKEND const PESO = import.meta.env.VITE_PESO @@ -23,15 +24,6 @@ export default () => { const [location, setLocation] = createSignal('') const [type, setType] = createSignal('') const [applicationId, setApplicationId] = createSignal(0) - // const [assessorId, setAssessorId] = createSignal(0) - - // const [gflgu, setGflgu] = createSignal([]) - // const [gfdpwh, setGfdpwh] = createSignal([]) - // const [tfbo, setTfbo] = createSignal([]) - - // const [descriptionList, setDescriptionList] = createSignal([]) - // const [amountList, setAmountList] = createSignal([]) - // const [dateOpList, setDateOpList] = createSignal([]) const [applicationList, setApplicationList] = createSignal([]) const [nameList, setNameList] = createSignal([]) @@ -48,9 +40,9 @@ export default () => { const [employeeId, setEmployeeId] = createSignal(0) const [employeeName, setEmployeeName] = createSignal('') - // const [docApplicationNo, setDocApplicationNo] = createSignal('') - // const [docDate, setDocDate] = createSignal('') - // const [docLocation, setDocLocation] = createSignal('') + const [filter, setFilter] = createSignal('') + const [fullIDList, setFullIDList] = createSignal([]) + const [fullNameList, setFullNameList] = createSignal([]) const checkAccess = async (access: string) => { try { @@ -63,6 +55,19 @@ export default () => { } } + const handleFilterChange = (value: string) => { + // setFilter(value) + if (value.trim() === '') { + setApplicationList(fullIDList()) + setNameList(fullNameList()) + } else { + const filteredApplications = fullIDList().filter((app) => app.toLowerCase().includes(value.toLowerCase())) + const filteredNames = fullNameList().slice(0, filteredApplications.length) + setApplicationList(filteredApplications) + setNameList(filteredNames) + } + } + const getPrintDetails = async (id: number) => { const response = await ofetch(API + 'get-printdetails-electrical/' + id) const applicationno = response.result @@ -159,11 +164,6 @@ export default () => { const assessorId = await getEmployeeId(op.result7[0]) const assessorsignId = await geteSignId(assessorId) getAssessedDate(op.result11[0]) - - console.log('name', op.result7[0]) - console.log('id', assessorId) - console.log('esignid', assessorsignId) - console.log('aaaa', op.result11[0]) } const calculateTotal = (list: number[]) => { @@ -171,11 +171,22 @@ export default () => { return total } - const getListForPrinting = async () => { + const getListForPrinting = async (query?: string) => { try { const response = await ofetch(API + 'get-listopprinting-electrical', { parseResponse: JSON.parse }) - setApplicationList(response.result) - setNameList(response.result2) + const filteredApplications = response.result.filter((item: any) => + item + .toString() + .toLowerCase() + .includes((query ?? '').toLowerCase()) + ) + const filteredNames = response.result2.filter((item: any) => + item.toString().toLowerCase().includes((query ?? '').toLowerCase()) + ) + // setApplicationList(response.result) + // setNameList(response.result2) + setApplicationList(filteredApplications) + setNameList(filteredNames) } catch (error) { console.error(error) } @@ -211,10 +222,10 @@ export default () => { return } - signed = await setNewStatus('ELECTRICAL ORDER OF PAYMENT PRINTED', '171', 'ELECOPPRINTED') + signed = await setNewStatus('ELECTRICAL ORDER OF PAYMENT PRINTED', '171', 'ELECOPPRINTED', 1) if (!signed) return - forprinting = await setNewStatus('FOR ELECTRICAL OFFICIAL RECEIPT VALIDATION', '98', 'ELECORVALIDATE') + forprinting = await setNewStatus('FOR ELECTRICAL OFFICIAL RECEIPT VALIDATION', '98', 'ELECORVALIDATE', 0) if (!forprinting) return updateOrderofpayment = await updateOp() @@ -240,7 +251,7 @@ export default () => { } } - const setNewStatus = async (status: string, tag: string, tagword: string) => { + const setNewStatus = async (status: string, tag: string, tagword: string, approved: number) => { const today = new Date() const formattedDate = dayjs(today).format('YYYY-MM-DD HH:mm:ss') const statusid = parseInt(applicationId().toString()) @@ -248,7 +259,7 @@ export default () => { try { await ofetch(API + 'post-newstatus-electrical', { method: 'POST', - body: { data: statusid, data2: formattedDate, data3: status, data4: tag, data5: tagword, data6: parseInt(employeeId().toString()) }, + body: { data: statusid, data2: formattedDate, data3: status, data4: tag, data5: tagword, data6: parseInt(approved.toString()), data7: parseInt(employeeId().toString()) }, }) return true } catch { @@ -323,6 +334,10 @@ export default () => { } } + const refresh = async () => { + await getListForPrinting() + } + const logout = async () => { removeEmployee() navigate('/') @@ -434,6 +449,13 @@ export default () => { + + + + + + +