diff --git a/src/pages/AssessorPage/Assessor.tsx b/src/pages/AssessorPage/Assessor.tsx index c0491a5..bcd053c 100644 --- a/src/pages/AssessorPage/Assessor.tsx +++ b/src/pages/AssessorPage/Assessor.tsx @@ -9,7 +9,7 @@ import { checkConnection, createPdf } from '../../utils/functions' 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, _signature, _assessorid } from '../../stores/pdfinfo' +import { _applicationNo, _date, _optn, _name, _location, _type, _assessor, _feeList, _codeList, _amountList, _signatureAssessor, _signatureApprover, _assessorid, _approvedDate } from '../../stores/pdfinfo' const API = import.meta.env.VITE_BACKEND const PESO = import.meta.env.VITE_PESO @@ -209,6 +209,7 @@ export default () => { updateOrderofpayment = await updateOp() if (updateOrderofpayment) { + postTransaction(application) setPrintedApplication(application) setPrinted(true) createPdf() @@ -248,13 +249,50 @@ export default () => { try { const response = await ofetch(API + 'get-signatureimage/' + id, { parseResponse: JSON.parse }) const image = response.result - _signature.set(image) + _signatureAssessor.set(image) + + const response2 = await ofetch(API + 'get-signatureimage/' + 276, { parseResponse: JSON.parse }) + const image2 = response2.result + _signatureApprover.set(image2) return true } catch { return false } } + const geteSignId = async () => { + try { + const response = await ofetch(API + 'get-esignid/' + employeeId(), { parseResponse: JSON.parse }) + const result = response.result + return result + } catch { + return 0 + } + } + + const postTransaction = async (application: string) => { + const id = await geteSignId() + 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: application, data3: formatedDate }, + }) + + getApprovedDate(id, application) + } + + const getApprovedDate = async (id: number, application: string) => { + try { + const response = await ofetch(API + `get-signeddate/${id}/${application}`, { parseResponse: JSON.parse }) + const result = response.result + _approvedDate.set(result) + } catch (error) { + _approvedDate.set('') + } + } + const logout = async () => { removeEmployee() navigate('/')