Updated register page
This commit is contained in:
parent
d3219d1ea8
commit
8523538bf3
1 changed files with 74 additions and 17 deletions
|
|
@ -1,14 +1,49 @@
|
||||||
import './Register.sass'
|
import './Register.sass'
|
||||||
import { Logo, Link, Page, Row, Padding, Form, Combobox, Box, File } from '../../components'
|
import { Logo, Link, Page, Row, Padding, Combobox, Box, File, Button, Modal, Column } from '../../components'
|
||||||
import { IoChevronBack } from 'solid-icons/io'
|
import { IoChevronBack } from 'solid-icons/io'
|
||||||
import { Show, createSignal } from 'solid-js'
|
import { Show, createSignal } from 'solid-js'
|
||||||
|
import { ofetch } from 'ofetch'
|
||||||
|
import { SHA3 } from 'crypto-js'
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
|
const API = import.meta.env.VITE_BACKEND
|
||||||
const assessors = JSON.parse(sessionStorage.getItem('assessors')!)
|
const assessors = JSON.parse(sessionStorage.getItem('assessors')!)
|
||||||
const roles = ['ASSESSOR', 'APPROVER']
|
const roles = ['ASSESSOR', 'APPROVER']
|
||||||
|
|
||||||
const [role, setRole] = createSignal('')
|
const [role, setRole] = createSignal('')
|
||||||
const [name, setName] = createSignal('')
|
const [name, setName] = createSignal('')
|
||||||
|
const [id, setId] = createSignal(0)
|
||||||
|
const [signature, setSignature] = createSignal('')
|
||||||
|
const [saved, setSaved] = createSignal(false)
|
||||||
|
|
||||||
|
const getEmployeeId = async (val: string) => {
|
||||||
|
try {
|
||||||
|
setName(val)
|
||||||
|
const id = await ofetch(API + 'get-employeeid/' + val, { parseResponse: JSON.parse })
|
||||||
|
setId(id.result)
|
||||||
|
} catch {
|
||||||
|
setId(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const generateSignature = () => {
|
||||||
|
const hash = SHA3(id().toString())
|
||||||
|
setSignature(hash.toString())
|
||||||
|
|
||||||
|
try {
|
||||||
|
register()
|
||||||
|
setSaved(true)
|
||||||
|
} catch {
|
||||||
|
setSaved(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const register = async () => {
|
||||||
|
await ofetch(API + 'post-registration', {
|
||||||
|
method: 'POST',
|
||||||
|
body: { data: id(), data2: signature() },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
@ -36,27 +71,49 @@ export default () => {
|
||||||
<Row>
|
<Row>
|
||||||
<span class="box-title">Registration</span>
|
<span class="box-title">Registration</span>
|
||||||
</Row>
|
</Row>
|
||||||
<Form>
|
|
||||||
<h4>Role</h4>
|
<h4>Role</h4>
|
||||||
<Combobox options={roles} placeholder="Select your role" value={role()} onChange={setRole} />
|
<Combobox options={roles} placeholder="Select your role" value={role()} onChange={setRole} />
|
||||||
<Show when={role() === 'ASSESSOR'}>
|
<Show when={role() === 'ASSESSOR'}>
|
||||||
<h4>List of Assessors</h4>
|
<h4>List of Assessors</h4>
|
||||||
<Combobox options={assessors} placeholder="Select your name" value={name()} onChange={setName} />
|
<Combobox options={assessors} placeholder="Select your name" value={name()} onChange={(val) => getEmployeeId(val!)} />
|
||||||
<h4>Upload Signature</h4>
|
<h4>Upload Signature</h4>
|
||||||
<File />
|
<File />
|
||||||
|
|
||||||
|
<Padding top={2} bottom={0} left={0} right={0}>
|
||||||
|
<Row>
|
||||||
|
<Button edges="curved" design="bo-primary" label="Register" onClick={generateSignature} />
|
||||||
|
</Row>
|
||||||
|
</Padding>
|
||||||
</Show>
|
</Show>
|
||||||
<Show when={role() === 'APPROVER'}>
|
<Show when={role() === 'APPROVER'}>
|
||||||
<h4>Name of Approver</h4>
|
<h4>Name of Approver</h4>
|
||||||
<span class="approver-name">ARCH. KHASHAYAR L. TOGHYANI</span>
|
<span class="approver-name">ARCH. KHASHAYAR L. TOGHYANI</span>
|
||||||
<h4>Upload Signature</h4>
|
<h4>Upload Signature</h4>
|
||||||
<File />
|
<File />
|
||||||
|
|
||||||
|
<Padding top={2} bottom={0} left={0} right={0}>
|
||||||
|
<Row>
|
||||||
|
<Button edges="curved" design="bo-primary" label="Register" onClick={generateSignature} />
|
||||||
|
</Row>
|
||||||
|
</Padding>
|
||||||
</Show>
|
</Show>
|
||||||
</Form>
|
|
||||||
</Box>
|
</Box>
|
||||||
</Row>
|
</Row>
|
||||||
</Padding>
|
</Padding>
|
||||||
</Padding>
|
</Padding>
|
||||||
</Page>
|
</Page>
|
||||||
|
|
||||||
|
<Modal trigger={!saved()} background="#0f1720f3" color="#ffffffe4">
|
||||||
|
<Padding top={1} bottom={1} left={4} right={4}>
|
||||||
|
<Column>
|
||||||
|
<Row>
|
||||||
|
<span>e-Sign Registration Complete</span>
|
||||||
|
</Row>
|
||||||
|
|
||||||
|
<span>e-Sign Registration Complete</span>
|
||||||
|
</Column>
|
||||||
|
</Padding>
|
||||||
|
</Modal>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue