Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-073
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2022-073
2022-073
Commits
3ae60f45
Commit
3ae60f45
authored
Nov 12, 2022
by
NilanDMeegoda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modifications to candidate registration
parent
7463ea5a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
136 additions
and
3 deletions
+136
-3
web-app/backend/server.py
web-app/backend/server.py
+28
-1
web-app/frontend/src/pages/student/student_reg.jsx
web-app/frontend/src/pages/student/student_reg.jsx
+108
-2
No files found.
web-app/backend/server.py
View file @
3ae60f45
...
...
@@ -100,7 +100,12 @@ def data():
age
=
body
[
'age'
]
residence
=
body
[
'residence'
]
disorders
=
body
[
'disorders'
]
# db.users.insert_one({
email
=
body
[
'email'
]
contactNo
=
body
[
'contactNo'
]
institute
=
body
[
'institute'
]
status
=
body
[
'status'
]
parent
=
body
[
'parent'
]
db
.
db
[
'users'
]
.
insert_one
({
"firstName"
:
firstName
,
"lastName"
:
lastName
,
...
...
@@ -109,6 +114,11 @@ def data():
"age"
:
age
,
"residence"
:
residence
,
"disorders"
:
disorders
,
"email"
:
email
,
"contactNo"
:
contactNo
,
"institute"
:
institute
,
"status"
:
status
,
"parent"
:
parent
,
})
return
jsonify
({
'status'
:
'Candidate details are added to the system successfully!'
,
...
...
@@ -140,6 +150,23 @@ def data():
dataJson
.
append
(
dataDict
)
return
jsonify
(
dataJson
)
@
app
.
route
(
'/institutes/'
,
methods
=
[
'GET'
])
@
cross_origin
()
def
data3
():
# GET all data from database
if
request
.
method
==
'GET'
:
allData
=
db
.
db
[
'institutes'
]
.
find
()
dataJson
=
[]
for
data
in
allData
:
id
=
data
[
'_id'
]
name
=
data
[
'name'
]
dataDict
=
{
'id'
:
str
(
id
),
'name'
:
name
,
}
dataJson
.
append
(
dataDict
)
return
jsonify
(
dataJson
)
@
app
.
route
(
'/users/<string:id>'
,
methods
=
[
'GET'
,
'DELETE'
,
'PUT'
])
def
onedata
(
id
):
...
...
web-app/frontend/src/pages/student/student_reg.jsx
View file @
3ae60f45
import
React
,
{
useState
}
from
"
react
"
;
import
React
,
{
useState
,
useEffect
}
from
"
react
"
;
import
{
ContainerCard
}
from
"
../../components/index
"
;
import
toast
,
{
Toaster
}
from
"
react-hot-toast
"
;
import
"
./student_reg.css
"
;
...
...
@@ -12,8 +12,31 @@ const StdReg_screen = () => {
const
[
nationality
,
setNationality
]
=
useState
(
""
);
const
[
school
,
setSchool
]
=
useState
(
""
);
const
[
age
,
setAge
]
=
useState
(
""
);
const
[
email
,
setEmail
]
=
useState
(
""
);
const
[
contactNo
,
setContactNo
]
=
useState
(
""
);
const
[
parent
,
setParent
]
=
useState
(
""
);
const
[
institute
,
setInstitute
]
=
useState
(
""
);
const
[
residence
,
setResidence
]
=
useState
(
""
);
const
[
disorders
,
setDisorders
]
=
useState
(
""
);
const
[
instituteData
,
setInstituteData
]
=
useState
([{}]);
const
headerConfig
=
{
headers
:
{
"
Access-Control-Allow-Origin
"
:
"
*
"
,
"
Content-Type
"
:
"
application/json
"
,
},
};
useEffect
(()
=>
{
const
fetchData
=
async
()
=>
{
const
response
=
await
API
.
get
(
"
institutes/
"
,
headerConfig
)
.
then
((
response
)
=>
setInstituteData
(
response
.
data
))
.
catch
((
err
)
=>
{
console
.
log
(
err
.
message
);
});
};
fetchData
();
},
[]);
let
handleSubmit
=
async
(
e
)
=>
{
e
.
preventDefault
();
...
...
@@ -26,6 +49,11 @@ const StdReg_screen = () => {
age
:
age
,
residence
:
residence
,
disorders
:
disorders
,
parent
:
parent
,
status
:
false
,
institute
:
institute
,
email
:
email
,
contactNo
:
contactNo
,
};
await
API
.
post
(
"
users/
"
,
JSON
.
stringify
(
payload
),
{
headers
:
{
...
...
@@ -44,6 +72,9 @@ const StdReg_screen = () => {
setAge
(
""
);
setResidence
(
""
);
setDisorders
(
""
);
setContactNo
(
""
);
setEmail
(
""
);
setParent
(
""
);
toast
.
success
(
"
Candidate has been added successfully
"
);
}
else
{
toast
.
error
(
"
Some error occured
"
);
...
...
@@ -119,7 +150,82 @@ const StdReg_screen = () => {
onChange=
{
(
e
)
=>
setLastName
(
e
.
target
.
value
)
}
/>
</
div
>
<
div
className=
"col-span-6 sm:col-span-3"
>
<
label
htmlFor=
"parent-name"
className=
"block text-sm font-medium text-gray-700"
>
Parent name
</
label
>
<
input
type=
"text"
name=
"parent-name"
id=
"parent-name"
value=
{
parent
}
className=
"mt-1 text-black focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-2 rounded-md"
onChange=
{
(
e
)
=>
setParent
(
e
.
target
.
value
)
}
/>
</
div
>
<
div
className=
"col-span-6 sm:col-span-3"
>
<
label
htmlFor=
"contactNo"
className=
"block text-sm font-medium text-gray-700"
>
Contact number
</
label
>
<
input
type=
"text"
name=
"contactNo"
id=
"contactNo"
value=
{
contactNo
}
className=
"mt-1 text-black focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-2 rounded-md"
onChange=
{
(
e
)
=>
setContactNo
(
e
.
target
.
value
)
}
/>
</
div
>
<
div
className=
"col-span-6 sm:col-span-3"
>
<
label
htmlFor=
"email"
className=
"block text-sm font-medium text-gray-700"
>
Email
</
label
>
<
input
type=
"email"
name=
"email"
id=
"email"
value=
{
email
}
className=
"mt-1 text-black focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-2 rounded-md"
onChange=
{
(
e
)
=>
setEmail
(
e
.
target
.
value
)
}
/>
</
div
>
<
div
className=
"col-span-6 sm:col-span-3"
>
<
label
htmlFor=
"institute"
className=
"block text-sm font-medium text-gray-700"
>
Please select the medical center
</
label
>
<
select
id=
"institute"
name=
"institute"
defaultValue=
{
"
DEFAULT
"
}
className=
"mt-1 block text-black w-40 py-2 px-3 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"
onChange=
{
(
e
)
=>
setInstitute
(
e
.
target
.
value
)
}
>
<
option
value=
"DEFAULT"
disabled
>
Select ...
</
option
>
{
instituteData
.
map
((
e
,
key
)
=>
{
return
(
<
option
key=
{
key
}
value=
{
e
.
id
}
>
{
e
.
name
}
</
option
>
);
})
}
</
select
>
</
div
>
<
div
className=
"col-span-6 sm:col-span-3"
>
<
label
htmlFor=
"country"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment