diff --git a/src/pages/MainPage/Main.sass b/src/pages/MainPage/Main.sass index 17dae12..f6d73d1 100644 --- a/src/pages/MainPage/Main.sass +++ b/src/pages/MainPage/Main.sass @@ -16,8 +16,6 @@ h1 .name font-size: 1.25rem - - .modal font-weight: 500 @@ -69,3 +67,38 @@ h1 font-size: 1.75rem font-weight: 700 padding: 0.5rem 1rem + +.config + display: flex + flex-direction: column + gap: 1rem + + &__row + display: flex + flex-direction: column + gap: 0.5rem + + &__edit + padding: 1rem 0 0 0 + display: flex + flex-direction: column + gap: 0.5rem + + &__title + font-weight: bold + font-size: 1.15rem + + &__info + font-size: 0.75rem + opacity: 0.6 + + &__button + padding: 1rem 0 0 0 + +.required + padding: 0.75rem 1rem + border-radius: 8px + background-color: color.adjust(#0D64E4, $blackness: 20%) + opacity: 0.6 + text-align: center + margin: 1rem 0 0 0 diff --git a/src/pages/MainPage/Main.tsx b/src/pages/MainPage/Main.tsx index 54bc7d0..e802dab 100644 --- a/src/pages/MainPage/Main.tsx +++ b/src/pages/MainPage/Main.tsx @@ -5,9 +5,11 @@ import { BiRegularErrorAlt } from 'solid-icons/bi' import { FaSolidThumbsUp } from 'solid-icons/fa' import { FiLogOut } from 'solid-icons/fi' import { VsRefresh } from 'solid-icons/vs' -import { createSignal, onMount } from 'solid-js' -import { Box, Button, Clickable, Column, Link, Logo, Modal, ModalButton, Padding, Page, Row } from '../../components/' -import { checkConnection, getApi, getApiMulti, postApi } from '../../utils/functions' +import { createSignal, onMount, createEffect } from 'solid-js' +import { Box, Button, Clickable, Column, Link, Logo, Modal, ModalButton, Padding, Page, Row, Input } from '../../components/' +import { checkConnection, getApi, getApiMulti, postApi, securePassword } from '../../utils/functions' +import { FaSolidUserGear } from 'solid-icons/fa' +import { Show } from 'solid-js/web' import './Main.sass' const PESO = import.meta.env.VITE_PESO @@ -48,6 +50,13 @@ export default () => { const [employeeName, setEmployeeName] = createSignal('') const [apology, setApology] = createSignal(false) + const [openConfig, setOpenConfig] = createSignal(false) + const [configEncPassword, setConfigEncPassword] = createSignal('') + const [configNewName, setConfigNewName] = createSignal('') + const [configPassword, setConfigPassword] = createSignal('') + const [configNewPassword, setConfigNewPassword] = createSignal('') + const [configNewEncPassword, setConfigNewEncPassword] = createSignal('') + const [configError, setConfigError] = createSignal('') let bldgadditional = false @@ -76,10 +85,12 @@ export default () => { const load = async (division: string) => { setConnected(await checkConnection()) if (connected() === false) { - setErrorMessage('Could not gather list of applicaitons') + setErrorMessage('Could not gather list of applications') return } + await getPassword() + if (division === 'electrical') { await getListForApprovalElectrical() } @@ -303,11 +314,38 @@ export default () => { return response } + const getPassword = async () => { + const response = await getApi('get-password', ID) + setConfigEncPassword(response) + } + + const checkCurrentPassword = async () => { + const encCurrentPassword = await securePassword(configPassword()) + if (encCurrentPassword === configEncPassword()) { + setConfigError('') + encryptNewPassword() + } else { + setConfigError('Invalid Password') + setConfigNewEncPassword('') + } + } + + const encryptNewPassword = async () => { + const encNewPassword = await securePassword(configNewPassword()) + setConfigNewEncPassword(encNewPassword) + } + + const saveConfig = () => {} + const logout = async () => { removeEmployee() navigate('/') } + const gotoProfile = () => { + navigate('/profile') + } + onMount(async () => { const logged = await checkLogged() @@ -316,6 +354,16 @@ export default () => { } }) + createEffect(() => { + if (configPassword !== '') { + checkCurrentPassword() + } + + if (configNewEncPassword() !== '') { + encryptNewPassword() + } + }) + return ( <> @@ -328,10 +376,16 @@ export default () => { - + - {employeeName()} + {employeeName()} + setOpenConfig(true)}> + + + Config + + @@ -655,6 +709,50 @@ export default () => { + + + +
+
+ Name: + {employeeName()} +
+ +
+ Encrypted Password: + {configEncPassword()} +
+ +
+ Change Displayed Name + + Leave blank to remain unchanged. +
+ +
+ Change Password + + + + + New Encrypted Password: + {configNewEncPassword()} + +
+ + + {configError()} + + + +
+
+
+
+
+
) }