-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddPrescription.jsx
68 lines (62 loc) · 1.53 KB
/
AddPrescription.jsx
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
import { useState } from "react";
import "../Css/formInput.css";
import FormInput from "./FormInput";
const AddPrescription = () => {
const [values, setValues] = useState({
username: "",
Consultation: "",
file: "",
});
const inputs = [
{
id: 1,
name: "username",
type: "text",
placeholder: "Docter's Name",
errorMessage:
"username should be 3-16 characters and shouldn't include any special character!",
label: "Docter's Name",
pattern: "^[A-Za-z0-9]{3,16}$",
required: true,
},
{
id: 3,
name: "Consultation Date",
type: "date",
placeholder: "Consultation Date",
label: "Consultation Date",
},
{
id: 4,
name: "file",
type: "file",
placeholder: "Prescription",
label: " Upload Prescription",
},
];
const handleSubmit = (e) => {
e.preventDefault();
};
const onChange = (e) => {
setValues({ ...values, [e.target.name]: e.target.value });
};
return (
<>
<div className="app">
<form onSubmit={handleSubmit}>
<p className="an"> Add New Prescription</p>
{inputs.map((input) => (
<FormInput
key={input.id}
{...input}
value={values[input.name]}
onChange={onChange}
/>
))}
<button className="b1">Submit</button>
</form>
</div>
</>
);
};
export default AddPrescription;