1
1
import React , { useState , useEffect } from "react" ;
2
2
import { TextField } from "@mui/material" ;
3
+ import FormControl from "@mui/material/FormControl" ;
4
+ import MenuItem from "@mui/material/MenuItem" ;
3
5
import Button from "@mui/material/Button" ;
4
6
import { useForm } from "react-hook-form" ;
5
7
import { VscEye } from "react-icons/vsc" ;
@@ -16,6 +18,7 @@ const RegisterForm = ({ handleModeChange }) => {
16
18
const [ complete , setComplete ] = useState ( "idle" ) ;
17
19
//---show/hide password option---
18
20
const [ showPassword , setShowPassword ] = useState ( false ) ;
21
+ const [ selectedSchool , setSelectedSchool ] = useState ( false ) ;
19
22
const handleClickShowPassword = ( ) => setShowPassword ( ( show ) => ! show ) ;
20
23
21
24
const {
@@ -48,6 +51,11 @@ const RegisterForm = ({ handleModeChange }) => {
48
51
validate : passwordMatch ,
49
52
} ) ;
50
53
54
+ const SchoolNameList = [
55
+ "Western Mindanao Adventist Academy" ,
56
+ "Paul’s Institute of Technology of Iligan City, Inc" ,
57
+ ] ;
58
+
51
59
useEffect ( ( ) => {
52
60
if ( registerStatus === "loading" ) {
53
61
setComplete ( "loading" ) ;
@@ -124,6 +132,56 @@ const RegisterForm = ({ handleModeChange }) => {
124
132
</ p >
125
133
) }
126
134
</ div >
135
+ < FormControl
136
+ sx = { {
137
+ marginBottom : 3 ,
138
+ width : "100%" ,
139
+ } }
140
+ >
141
+ < TextField
142
+ select
143
+ label = "What School"
144
+ variant = "outlined"
145
+ name = "selected_school"
146
+ error = { selectedSchool ? true : false }
147
+ { ...register ( "selected_school" , {
148
+ required : "This is required." ,
149
+ } ) }
150
+ SelectProps = { {
151
+ MenuProps : { disableScrollLock : true } ,
152
+ style : {
153
+ height : "47px" ,
154
+ } ,
155
+ } }
156
+ >
157
+ < MenuItem value = "" >
158
+ < p
159
+ className = "text-slate-500 text-[12px]"
160
+ onClick = { ( ) => {
161
+ setSelectedSchool ( true ) ;
162
+ } }
163
+ >
164
+ Select one
165
+ </ p >
166
+ </ MenuItem >
167
+ { SchoolNameList . map ( ( school , index ) => (
168
+ < MenuItem
169
+ key = { index }
170
+ value = { school }
171
+ onClick = { ( ) => {
172
+ setSelectedSchool ( false ) ;
173
+ } }
174
+ >
175
+ { school }
176
+ </ MenuItem >
177
+ ) ) }
178
+ </ TextField >
179
+ { errors . selected_school && (
180
+ < p className = "ml-1 mt-1 text-[13px] text-red-500 mb-[-0.2rem]" >
181
+ { selectedSchool && errors . selected_school . message }
182
+ </ p >
183
+ ) }
184
+ </ FormControl >
127
185
< div className = "mb-5 w-full" >
128
186
< TextField
129
187
label = "Username"
@@ -258,6 +316,12 @@ const RegisterForm = ({ handleModeChange }) => {
258
316
background : "#f1c320" , // Same color when hovered
259
317
} ,
260
318
} }
319
+ onClick = { ( ) => {
320
+ watch ( "selected_school" ) === "" ||
321
+ watch ( "selected_school" ) === undefined
322
+ ? setSelectedSchool ( true )
323
+ : setSelectedSchool ( false ) ;
324
+ } }
261
325
>
262
326
REGISTER
263
327
</ Button >
0 commit comments