Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-158
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
2
Merge Requests
2
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-158
2022-158
Commits
17a5a424
Commit
17a5a424
authored
Oct 03, 2022
by
Thiwanka K.A.T
🎯
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'IT19076362' into 'master'
CREATE: module delete integrated See merge request
!81
parents
63737548
6666465c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
12 deletions
+9
-12
backend/database.db
backend/database.db
+0
-0
backend/routes/module_routes.py
backend/routes/module_routes.py
+0
-2
frontend/src/pages/ManageModules.js
frontend/src/pages/ManageModules.js
+9
-10
No files found.
backend/database.db
View file @
17a5a424
No preview for this file type
backend/routes/module_routes.py
View file @
17a5a424
...
...
@@ -34,8 +34,6 @@ def get_modules():
for
module
in
module_obj
:
modules
.
append
({
"id"
:
module
.
id
,
"name"
:
module
.
name
,
"code"
:
module
.
code
,
"created_at"
:
module
.
created_at
,
"updated_at"
:
module
.
updated_at
})
print
(
modules
)
if
module_obj
is
None
:
return
jsonify
({
'err'
:
"Module does not exist"
}),
HTTP_400_BAD_REQUEST
...
...
frontend/src/pages/ManageModules.js
View file @
17a5a424
...
...
@@ -13,19 +13,20 @@ import "../assets/css/Usercreate.css";
const
ManageModules
=
()
=>
{
const
[
btnState
,
setBtnState
]
=
useState
(
false
);
const
[
error
,
setError
]
=
useState
(
""
);
const
[
isLoading
,
setIsLoading
]
=
useState
(
tru
e
);
const
[
isLoading
,
setIsLoading
]
=
useState
(
fals
e
);
const
[
module
,
setModule
]
=
useState
({
code
:
""
,
name
:
""
});
const
[
modules
,
setModules
]
=
useState
([]);
const
fields
=
[
""
,
"
Module Code
"
,
"
Module Name
"
,
"
Created At
"
,
"
Actions
"
];
const
fields
=
[
""
,
"
ID
"
,
"
Module Code
"
,
"
Module Name
"
,
"
Created At
"
,
"
Actions
"
];
const
renderOrderHead
=
(
item
,
index
)
=>
<
th
key
=
{
index
}
>
{
item
}
<
/th>
;
const
renderOrderBody
=
(
item
,
index
)
=>
(
<
tr
key
=
{
index
}
>
<
td
>
{
index
+
1
}
<
/td
>
<
td
>
{
item
.
id
}
<
/td
>
<
td
>
{
item
.
code
}
<
/td
>
<
td
>
{
item
.
name
}
<
/td
>
<
td
>
{
item
.
createdAt
}
<
/td
>
<
td
>
{
new
Date
(
item
.
created_at
).
toLocaleString
()
}
<
/td
>
<
td
>
<
div
style
=
{{
display
:
"
flex
"
,
alignItems
:
"
center
"
}}
>
<
Link
to
=
{
``
}
>
...
...
@@ -36,7 +37,7 @@ const ManageModules = () => {
style
=
{{
marginLeft
:
"
2rem
"
}}
onClick
=
{()
=>
{
if
(
window
.
confirm
(
"
Are you sure to delete this module?
"
))
{
deleteHandler
(
item
.
_id
,
item
.
username
);
deleteHandler
(
item
.
id
);
}
}}
>
...
...
@@ -59,14 +60,12 @@ const ManageModules = () => {
}
try
{
const
res
=
await
axios
.
post
(
"
/modules/create
"
,
module
);
console
.
log
(
res
);
await
axios
.
post
(
"
modules/create
"
,
module
);
setModule
({
code
:
""
,
name
:
""
});
getAllModules
();
setError
(
""
);
window
.
alert
(
"
Module added successfully
"
);
getAllModules
();
setBtnState
(
false
);
setIsLoading
(
true
);
}
catch
(
err
)
{
setBtnState
(
false
);
setError
(
err
.
response
.
data
.
message
);
...
...
@@ -74,14 +73,14 @@ const ManageModules = () => {
}
};
const
deleteHandler
=
async
(
id
,
username
)
=>
{
const
deleteHandler
=
async
id
=>
{
try
{
const
res
=
await
axios
.
delete
(
`modules/
${
id
}
`
);
if
(
res
.
statusText
===
"
OK
"
)
{
getAllModules
();
setError
(
""
);
window
.
alert
(
"
Class
has been successfully deleted
"
);
window
.
alert
(
"
Module
has been successfully deleted
"
);
setIsLoading
(
true
);
}
}
catch
(
err
)
{
...
...
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