From 2850fa7c276bbb8d807c726570b26a4b5425ffa1 Mon Sep 17 00:00:00 2001 From: Patrick Alvin Alcala Date: Wed, 7 Jan 2026 10:07:42 +0800 Subject: [PATCH] Updated assessor page --- src/pages/AssessorPage/Assessor.tsx | 104 ++++++++++++++++++++++++---- 1 file changed, 89 insertions(+), 15 deletions(-) diff --git a/src/pages/AssessorPage/Assessor.tsx b/src/pages/AssessorPage/Assessor.tsx index 1dcb70e..47bf2bc 100644 --- a/src/pages/AssessorPage/Assessor.tsx +++ b/src/pages/AssessorPage/Assessor.tsx @@ -32,7 +32,7 @@ import { _type, _units, } from '../../stores/pdfinfo.ts'; -import { checkConnection, createPdfElectrical, createPdfOccupancy, getApi, getApiMulti, postApi, statusPopsApi, voidPopsApi, saveNewName, saveNewPassword } from '../../utils/functions/index.ts'; +import { checkConnection, createPdfElectrical, createPdfOccupancy, getApi, getApiMulti, postApi, statusPopsApi, voidPopsApi, saveNewName, saveNewPassword, securePassword } from '../../utils/functions/index.ts'; import './Assessor.sass'; import { FaSolidUserGear } from 'solid-icons/fa' @@ -517,8 +517,50 @@ export default () => { setConfigNotification(true) } + const checkCurrentPassword = async () => { + const encCurrentPasswordV1 = await securePassword(configPassword(), 'v1') + const encCurrentPasswordV2 = await securePassword(configPassword(), 'v2') + + if (encCurrentPasswordV1 === configEncPassword() || encCurrentPasswordV2 === configEncPassword()) { + if (configNewPassword() === '') { + setConfigError('New Password not provided') + setConfigNewEncPassword('') + } else { + setConfigError('') + encryptNewPassword() + } + + } else { + setConfigError('Invalid Password') + setConfigNewEncPassword('') + } + } + + const encryptNewPassword = async () => { + const encNewPassword = await securePassword(configNewPassword(), 'v2') + setConfigNewEncPassword(encNewPassword) + } + + const getPassword = async () => { + const response = await getApi('get-password', employeeId()) + setConfigEncPassword(response) + } + + const closeConfig = () => { + setConfigNotification(false) + setOpenConfig(false) + + setConfigEncPassword('') + setConfigNewName('') + setConfigPassword('') + setConfigNewPassword('') + setConfigNewEncPassword('') + setConfigError('') + } + onMount(async () => { const logged = await checkLogged() + await getPassword() if (logged) { setSelectedType('Print') @@ -542,6 +584,17 @@ export default () => { } }) + createEffect(() => { + if (configPassword() !== '') { + checkCurrentPassword(); + } else checkCurrentPassword(); + + if (configNewPassword() !== '') { + encryptNewPassword() + } else encryptNewPassword() + + }) + return ( <> @@ -554,21 +607,21 @@ export default () => { - + {employeeName()} setOpenConfig(true)}> - - + + Config - - + + Logout @@ -963,7 +1016,8 @@ export default () => { - + +
@@ -971,11 +1025,6 @@ export default () => { {employeeName()}
-
- Encrypted Password: - {configEncPassword()} -
-
Change Displayed Name @@ -984,11 +1033,14 @@ export default () => {
Change Password - - + + - New Encrypted Password: + Current Encrypted Password: + {configEncPassword()} + + New Encrypted Password: {configNewEncPassword()}
@@ -1007,6 +1059,28 @@ export default () => {
+ + {/*
+ + + + + + + Approved + + + +

{approvedApplication()}

+
+ + + Click anywhere to proceed + +
+
+
+
*/} ) }