Compare commits
6 commits
66ff214024
...
3ed25c9cee
| Author | SHA1 | Date | |
|---|---|---|---|
| 3ed25c9cee | |||
| a8d1c1fdf9 | |||
| 439083a55b | |||
| aa31a79b6d | |||
| b6f8546114 | |||
| 69a64879b6 |
7 changed files with 192 additions and 60 deletions
|
|
@ -158,6 +158,26 @@ func connect() {
|
|||
"result2": array2,
|
||||
})
|
||||
|
||||
case "get-list-registered":
|
||||
array := []string{}
|
||||
|
||||
results, err := db.Query("SELECT IFNULL(employeeid, 0) AS result FROM esign WHERE employeeid <> ?", 276)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
for results.Next() {
|
||||
err = results.Scan(&result)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
array = append(array, result)
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"result": array,
|
||||
})
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -480,6 +500,17 @@ func connect() {
|
|||
c.JSON(http.StatusOK, gin.H{
|
||||
"result": result,
|
||||
})
|
||||
|
||||
case "get-employeename":
|
||||
err := db.QueryRow("SELECT IFNULL(employeename, '') AS result FROM employee WHERE employeeid = ?", data).Scan(&result)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"result": result,
|
||||
})
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -7,11 +7,13 @@ interface Props {
|
|||
color?: string
|
||||
border?: string
|
||||
opacity?: number
|
||||
trigger: boolean
|
||||
}
|
||||
|
||||
export default (props: Props) => {
|
||||
return (
|
||||
<>
|
||||
<Show when={props.trigger}>
|
||||
<div class="modal">
|
||||
<Show when={props.border}>
|
||||
<div class="modal__content" style={`background-color: ${props.background}; color: ${props.color}; border: 2px solid ${props.border}; opacity: ${props.opacity || 1}`}>
|
||||
|
|
@ -25,6 +27,7 @@ export default (props: Props) => {
|
|||
</div>
|
||||
</Show>
|
||||
</div>
|
||||
</Show>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,11 @@
|
|||
z-index: -1
|
||||
opacity: 1
|
||||
|
||||
.close-text
|
||||
padding: 3rem 0 0 0
|
||||
font-size: 0.75rem
|
||||
font-weight: 500
|
||||
|
||||
.inter
|
||||
@extend .body
|
||||
font-family: fonts.$Inter
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
import './Index.sass'
|
||||
import { Button, Page, Padding, Display, Row, Logo, Column, Box } from '../../components'
|
||||
import { Button, Page, Padding, Display, Row, Logo } from '../../components'
|
||||
import { onMount } from 'solid-js'
|
||||
import { ofetch } from 'ofetch'
|
||||
|
||||
const API = import.meta.env.VITE_BACKEND
|
||||
let assessorsNameList: string[]
|
||||
let registeredNameList: string[]
|
||||
|
||||
export default () => {
|
||||
const getAssessors = async () => {
|
||||
|
|
@ -17,8 +18,27 @@ export default () => {
|
|||
sessionStorage.setItem('assessors', JSON.stringify([...assessorsNameList]))
|
||||
}
|
||||
|
||||
const getRegistered = async () => {
|
||||
let nameList: string[] = []
|
||||
|
||||
try {
|
||||
const registered = await ofetch(API + 'get-list-registered', { parseResponse: JSON.parse })
|
||||
|
||||
for (let i = 0; i < registered.result.length; i++) {
|
||||
const name = await ofetch(API + 'get-employeename/' + registered.result[i], { parseResponse: JSON.parse })
|
||||
nameList.push(name.result)
|
||||
}
|
||||
|
||||
registeredNameList = [...nameList]
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
sessionStorage.setItem('registered', JSON.stringify([...registeredNameList]))
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
await getAssessors()
|
||||
await getRegistered()
|
||||
})
|
||||
|
||||
return (
|
||||
|
|
@ -38,24 +58,6 @@ export default () => {
|
|||
</Row>
|
||||
</Row>
|
||||
</Display>
|
||||
|
||||
<Display mobile>
|
||||
<Column content="center">
|
||||
<Logo size={120} />
|
||||
<h1>OCBO e-Sign</h1>
|
||||
|
||||
<Button label="Register" edges="curved" to="/main" />
|
||||
</Column>
|
||||
</Display>
|
||||
|
||||
<Row content="spaced">
|
||||
<Box thickness={1} curved>
|
||||
<h2>Assessor</h2>
|
||||
</Box>
|
||||
<Box thickness={1} curved>
|
||||
<h2>Approver</h2>
|
||||
</Box>
|
||||
</Row>
|
||||
</Padding>
|
||||
</Page>
|
||||
</>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import './Login.sass'
|
||||
import { Logo, Link, Page, Row, Padding, Box, Radio, Combobox, Input, Button } from '../../components'
|
||||
import { Logo, Link, Page, Row, Padding, Box, Radio, Combobox, Input, Button, Modal, Column } from '../../components'
|
||||
import { IoChevronBack } from 'solid-icons/io'
|
||||
import { createSignal, Show, createEffect } from 'solid-js'
|
||||
import { ofetch } from 'ofetch'
|
||||
|
|
@ -9,22 +9,31 @@ import { useNavigate } from '@solidjs/router'
|
|||
export default () => {
|
||||
const API = import.meta.env.VITE_BACKEND
|
||||
const APPROVERNAME = import.meta.env.VITE_HEAD
|
||||
const navigate = useNavigate()
|
||||
const assessors = JSON.parse(sessionStorage.getItem('registered')!)
|
||||
const roles = ['Assessor', 'Approver']
|
||||
|
||||
const [role, setRole] = createSignal('Assessor')
|
||||
const [name, setName] = createSignal('')
|
||||
const [password, setPassword] = createSignal('')
|
||||
|
||||
const navigate = useNavigate()
|
||||
const [loggedin, setLoggedin] = createSignal(0)
|
||||
const [errorMessage, setErrorMessage] = createSignal('')
|
||||
|
||||
const login = async () => {
|
||||
const employeeid = await ofetch(API + 'get-employeeid/' + name(), { parseResponse: JSON.parse })
|
||||
const dbpassword = await ofetch(API + 'get-password/' + employeeid.result, { parseResponse: JSON.parse })
|
||||
const hashPassword = await securePassword()
|
||||
|
||||
if (dbpassword.result === '0') {
|
||||
setErrorMessage('Not yet registered. Please proceed to Registration.')
|
||||
} else {
|
||||
setErrorMessage('Invalid Password, Try again.')
|
||||
}
|
||||
|
||||
if (dbpassword.result === hashPassword) {
|
||||
navigate('/notification')
|
||||
setLoggedin(2)
|
||||
} else {
|
||||
setLoggedin(1)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -36,6 +45,10 @@ export default () => {
|
|||
return thirdHashing.toString()
|
||||
}
|
||||
|
||||
const gotoMain = () => {
|
||||
navigate('/main')
|
||||
}
|
||||
|
||||
createEffect(() => {
|
||||
if (role() === 'Approver') setName(APPROVERNAME)
|
||||
else if (role() !== 'Approver' && name() === APPROVERNAME) setName('')
|
||||
|
|
@ -112,6 +125,46 @@ export default () => {
|
|||
</Row>
|
||||
</Padding>
|
||||
</Page>
|
||||
|
||||
<div onClick={gotoMain}>
|
||||
<Modal trigger={loggedin() === 2} background="#18412aff" color="#ffffffe4" opacity={0.6}>
|
||||
<Padding top={1} bottom={1} left={4} right={4}>
|
||||
<Column>
|
||||
<Row>
|
||||
<Box curved thickness={3} color="white" padding={1}>
|
||||
<h2>Login Successful</h2>
|
||||
</Box>
|
||||
</Row>
|
||||
|
||||
<Row>
|
||||
<span class="close-text">Click anywhere to close</span>
|
||||
</Row>
|
||||
</Column>
|
||||
</Padding>
|
||||
</Modal>
|
||||
</div>
|
||||
|
||||
<div onClick={() => setLoggedin(0)}>
|
||||
<Modal trigger={loggedin() === 1} background="#562020ff" color="#ffffffe4" opacity={0.6}>
|
||||
<Padding top={1} bottom={1} left={4} right={4}>
|
||||
<Column>
|
||||
<Row>
|
||||
<Box curved thickness={3} color="white" padding={1}>
|
||||
<h2>Login Failed</h2>
|
||||
</Box>
|
||||
</Row>
|
||||
|
||||
<Row>
|
||||
<h3>{errorMessage()}</h3>
|
||||
</Row>
|
||||
|
||||
<Row>
|
||||
<span class="close-text">Click anywhere to close</span>
|
||||
</Row>
|
||||
</Column>
|
||||
</Padding>
|
||||
</Modal>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,11 @@
|
|||
width: 100%
|
||||
text-align: center
|
||||
|
||||
.sub-message
|
||||
padding: 3rem 0 0 0
|
||||
font-size: 0.75rem
|
||||
font-weight: 500
|
||||
|
||||
.filefield
|
||||
display: flex
|
||||
flex-direction: column
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import { ofetch } from 'ofetch'
|
|||
import { SHA3, SHA1 } from 'crypto-js'
|
||||
import dayjs from 'dayjs'
|
||||
import { FileField } from '@kobalte/core/file-field'
|
||||
import { useNavigate } from '@solidjs/router'
|
||||
|
||||
export default () => {
|
||||
const API = import.meta.env.VITE_BACKEND
|
||||
|
|
@ -13,6 +14,8 @@ export default () => {
|
|||
const assessors = JSON.parse(sessionStorage.getItem('assessors')!)
|
||||
const roles = ['ASSESSOR', 'APPROVER']
|
||||
|
||||
const navigate = useNavigate()
|
||||
|
||||
const [role, setRole] = createSignal('')
|
||||
const [name, setName] = createSignal('')
|
||||
const [password, setPassword] = createSignal('')
|
||||
|
|
@ -46,6 +49,7 @@ export default () => {
|
|||
try {
|
||||
register()
|
||||
setSaved(true)
|
||||
updateRegistered()
|
||||
} catch {
|
||||
setSaved(false)
|
||||
}
|
||||
|
|
@ -99,6 +103,27 @@ export default () => {
|
|||
}
|
||||
}
|
||||
|
||||
const getAssessors = async (): Promise<string[]> => {
|
||||
let assessorsNameList: string[] = []
|
||||
|
||||
try {
|
||||
const assessors = await ofetch(API + 'get-list-assessors', { parseResponse: JSON.parse })
|
||||
assessorsNameList = [...assessors.result]
|
||||
return [...assessorsNameList]
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
const updateRegistered = async () => {
|
||||
const registered = await getAssessors()
|
||||
sessionStorage.setItem('assessors', JSON.stringify([...registered]))
|
||||
}
|
||||
|
||||
const gotoIndex = () => {
|
||||
navigate('/')
|
||||
}
|
||||
|
||||
createEffect(async () => {
|
||||
if (role() === 'APPROVER') {
|
||||
try {
|
||||
|
|
@ -210,7 +235,7 @@ export default () => {
|
|||
|
||||
<Show when={allow() === 2}>
|
||||
<h4>Upload Signature</h4>
|
||||
<FileField class="filefield" maxFiles={1} onFileAccept={(data) => setFile(data)} accept=".jpg, .jpeg, .png, .webp, .avif">
|
||||
<FileField class="filefield" maxFiles={1} onFileAccept={(data) => setFile(data)} accept=".png">
|
||||
<FileField.Dropzone class="filefield__dropzone">Drag and drop or click to upload file</FileField.Dropzone>
|
||||
<FileField.HiddenInput />
|
||||
<FileField.ItemList class="filefield__itemList">
|
||||
|
|
@ -256,14 +281,17 @@ export default () => {
|
|||
</Padding>
|
||||
</Page>
|
||||
|
||||
<div onClick={gotoIndex}>
|
||||
<Modal trigger={saved()} background="#ffffffff" color="#000000e4" opacity={0.6}>
|
||||
<Padding top={1} bottom={1} left={4} right={4}>
|
||||
<Column>
|
||||
<Row>
|
||||
<Box curved thickness={3} color="black" padding={1}>
|
||||
<h2>e-Sign Registration Completed</h2>
|
||||
</Box>
|
||||
</Row>
|
||||
<Row>
|
||||
<h3>Your Digital Signature</h3>
|
||||
<h3>Representation of your digital signature</h3>
|
||||
</Row>
|
||||
|
||||
<Row gap={1}>
|
||||
|
|
@ -277,9 +305,14 @@ export default () => {
|
|||
<span>Date: {getDate()}</span>
|
||||
</section>
|
||||
</Row>
|
||||
|
||||
<Row>
|
||||
<span class="sub-message">Click anywhere to close</span>
|
||||
</Row>
|
||||
</Column>
|
||||
</Padding>
|
||||
</Modal>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue