Repository navigation
Expand file tree
/
Copy pathCustomResetView.tsx
More file actions
77 lines (71 loc) · 3.15 KB
/
Copy pathCustomResetView.tsx
File metadata and controls
77 lines (71 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { ICustomResetLogin } from "@sibvisions/reactui";
import { Button } from "primereact/button";
import { Dropdown, DropdownChangeParams } from "primereact/dropdown"
import { InputText } from "primereact/inputtext"
import React, { FC, FormEvent, useState } from "react"
/**
* A custom login mask which replaces the reset one
* @param props - the properties received by the reactui
*/
const CustomResetView: FC<ICustomResetLogin> = (props) => {
/** The value of the email field in the reset mask */
const [email, setEmail] = useState<string>("");
/** Model of departments for the dropdown */
const departments = [
{ name: "IT", code: "IT"},
{ name: "Human Resources", code: "HR" },
{ name: "Logistics", code: "LO" },
{ name: "Marketing", code: "MA" },
{ name: "", code: "" }
]
/** The currently selected department */
const [selectedDepartment, setSelectedDepartment] = useState<{ name: string, code: string }|undefined>(undefined);
/** Handles the department-selection */
const handleDepartments = (e: DropdownChangeParams) => {
if (!e.value.name) {
setSelectedDepartment(undefined)
}
else {
setSelectedDepartment(e.value)
}
}
/**
* The submit event of the reset form
* @param e - the form event
*/
const resetSubmit= (e:FormEvent<HTMLFormElement>) => {
e.preventDefault();
props.sendResetRequest(email, { department: selectedDepartment });
}
return (
<div className="custom-reset-wrapper">
<div className="custom-reset-header">
<i className="pi pi-lock custom-reset-lock" />
<span className="custom-reset-header-text">Reset your Password!</span>
</div>
<form onSubmit={resetSubmit} className="custom-reset-form">
<div className="p-fluid">
<div className="p-field p-input-icon-left">
<i className="pi pi-user" />
<InputText
value={email}
id="email"
type="text"
autoComplete="email"
placeholder="Email"
onChange={(event: React.ChangeEvent<HTMLInputElement>) => setEmail(event.target.value)} />
</div>
<div className="p-field p-input-icon-left">
<i className="department-icon pi pi-briefcase" />
<Dropdown value={selectedDepartment} options={departments} onChange={(e) => handleDepartments(e)} optionLabel="name" placeholder="Department" />
</div>
<div className="reset-password-button-wrapper">
<Button className="custom-login-button" label="Cancel" icon="pi pi-times" onClick={() => props.setLoginMode("default")} />
<Button className="custom-login-button" type="submit" label="Send" icon="pi pi-send" />
</div>
</div>
</form>
</div>
)
}
export default CustomResetView