Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2023-029
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
2023-029
2023-029
Commits
2d1af9bb
Commit
2d1af9bb
authored
Sep 04, 2023
by
janithgamage1.ed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: update
Desc : update project
parent
e3dcca4e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
16 deletions
+37
-16
Project/Backend/Server_Node/controllers/userProgress.controller.js
...ackend/Server_Node/controllers/userProgress.controller.js
+3
-4
Project/Frontend/SignConnectPlus/src/pages/learning-management/learning-curriculums/list/list.tsx
...es/learning-management/learning-curriculums/list/list.tsx
+3
-2
Project/Frontend/SignConnectPlus/src/sections/learning-management/learning-curriculums/CurriculumCard.tsx
...arning-management/learning-curriculums/CurriculumCard.tsx
+30
-9
Project/Frontend/SignConnectPlus/src/types/curriculum.ts
Project/Frontend/SignConnectPlus/src/types/curriculum.ts
+1
-1
No files found.
Project/Backend/Server_Node/controllers/userProgress.controller.js
View file @
2d1af9bb
...
...
@@ -6,15 +6,14 @@ export const subscribeCurriculum = async (req, res) => {
try
{
// Check if the user is already subscribed to the curriculum
cons
t
userProgress
=
await
UserProgress
.
findOne
({
userId
});
le
t
userProgress
=
await
UserProgress
.
findOne
({
userId
});
if
(
!
userProgress
)
{
// If there is no user progress record for this user, create a new one
const
newU
serProgress
=
new
UserProgress
({
u
serProgress
=
new
UserProgress
({
userId
,
curriculums
:
[
curriculum
],
});
await
newUserProgress
.
save
();
}
else
{
// If there is an existing user progress record, check if the curriculum already exists
const
existingCurriculumIndex
=
userProgress
.
curriculums
.
findIndex
(
c
=>
c
.
curriculumCode
===
curriculum
.
curriculumCode
);
...
...
@@ -37,7 +36,7 @@ export const subscribeCurriculum = async (req, res) => {
userProgress
.
totalCurriculumsMarks
=
totalCurriculumsMarks
;
const
curriculumCode
=
curriculum
.
curriculumCode
// Now, update the curriculum collection with the subscribed user
await
Curriculum
.
updateOne
(
{
curriculumCode
},
...
...
Project/Frontend/SignConnectPlus/src/pages/learning-management/learning-curriculums/list/list.tsx
View file @
2d1af9bb
...
...
@@ -47,6 +47,7 @@ const allColumns = [
const
List
=
()
=>
{
const
dispatch
=
useDispatch
();
const
{
curriculums
,
error
,
success
,
isLoading
}
=
useSelector
(
state
=>
state
.
curriculum
);
const
{
success
:
userProgressSuccess
}
=
useSelector
(
state
=>
state
.
userProgress
);
const
[
data
,
setData
]
=
useState
<
curriculumType
[]
>
([])
...
...
@@ -83,7 +84,7 @@ const List = () => {
setPage
(
p
);
_DATA
.
jump
(
p
);
};
/**
* API Config
...
...
@@ -91,7 +92,7 @@ const List = () => {
*/
useEffect
(()
=>
{
dispatch
(
fetchCurriculums
());
},
[
dispatch
]);
},
[
dispatch
,
userProgressSuccess
]);
useEffect
(()
=>
{
setData
(
curriculums
);
...
...
Project/Frontend/SignConnectPlus/src/sections/learning-management/learning-curriculums/CurriculumCard.tsx
View file @
2d1af9bb
...
...
@@ -15,7 +15,7 @@ import {
import
MainCard
from
'
components/MainCard
'
;
// assets
import
{
PlusOutlined
,
SendOutlined
}
from
'
@ant-design/icons
'
;
import
{
MinusOutlined
,
PlusOutlined
,
SendOutlined
}
from
'
@ant-design/icons
'
;
import
AnimateButton
from
'
components/@extended/AnimateButton
'
;
import
useAuth
from
'
hooks/useAuth
'
;
import
{
useDispatch
,
useSelector
}
from
'
store
'
;
...
...
@@ -46,13 +46,14 @@ const CurriculumCard = ({ curriculum }: { curriculum: curriculumType }) => {
const
[
desc
,
setDesc
]
=
useState
(
curriculum
.
curriculumDescription
?.
slice
(
0
,
100
))
const
[
readMore
,
setReadMore
]
=
useState
(
false
)
const
[
isSubscribed
,
setIsSubscribed
]
=
useState
(
false
)
/**
* API Config
* User Progress API
*/
const
FollowCurriculum
=
()
=>
{
const
FollowCurriculum
=
()
=>
{
if
(
!
user
)
{
// User is missing
dispatch
(
...
...
@@ -97,7 +98,7 @@ const CurriculumCard = ({ curriculum }: { curriculum: curriculumType }) => {
dispatch
(
addUserProgress
(
user
.
id
,
curriculum
));
}
}
// handel error
useEffect
(()
=>
{
if
(
error
!=
null
)
{
...
...
@@ -135,6 +136,20 @@ const CurriculumCard = ({ curriculum }: { curriculum: curriculumType }) => {
}
},
[
success
])
useEffect
(()
=>
{
if
(
curriculum
.
subscribedUser
)
{
const
userId
=
user
?.
id
;
// Assuming user.id is how you get the user's ID
const
isUserSubscribed
=
curriculum
.
subscribedUser
.
includes
(
userId
!
);
if
(
isUserSubscribed
)
{
setIsSubscribed
(
true
)
}
}
},
[
curriculum
,
user
]);
return
(
<>
<
Animation
...
...
@@ -168,27 +183,33 @@ const CurriculumCard = ({ curriculum }: { curriculum: curriculumType }) => {
</
Typography
>
</
Grid
>
<
Grid
item
xs=
{
6
}
>
<
Box
sx=
{
{
display
:
'
inline-block
'
}
}
>
<
Box
sx=
{
{
display
:
'
inline-block
'
,
width
:
"
100%
"
}
}
>
<
AnimateButton
>
<
Button
fullWidth
size=
'small'
variant=
"outlined"
endIcon=
{
<
PlusOutlined
/>
}
endIcon=
{
isSubscribed
?
<
MinusOutlined
/>
:
<
PlusOutlined
/>
}
sx=
{
{
my
:
2
,
width
:
"
100%
"
}
}
onClick=
{
FollowCurriculum
}
color=
'success'
onClick=
{
()
=>
{
if
(
!
isSubscribed
)
{
FollowCurriculum
()
}
}
}
color=
{
isSubscribed
?
'
secondary
'
:
'
success
'
}
disabled=
{
isLoading
}
>
{
isLoading
?
<
CircularProgress
/>
:
'
Follow Curriculum
'
}
{
isLoading
?
<
CircularProgress
/>
:
<>
{
isSubscribed
?
'
Un Follow Curriculum
'
:
'
Follow Curriculum
'
}
</>
}
</
Button
>
</
AnimateButton
>
</
Box
>
</
Grid
>
<
Grid
item
xs=
{
6
}
>
<
Box
sx=
{
{
display
:
'
inline-block
'
}
}
>
<
Box
sx=
{
{
display
:
'
inline-block
'
,
width
:
"
100%
"
}
}
>
<
AnimateButton
>
<
Button
fullWidth
size=
'small'
variant=
"outlined"
endIcon=
{
<
SendOutlined
/>
}
sx=
{
{
my
:
2
,
width
:
"
100%
"
}
}
...
...
Project/Frontend/SignConnectPlus/src/types/curriculum.ts
View file @
2d1af9bb
...
...
@@ -14,7 +14,7 @@ export interface curriculumType {
createdAt
?:
Date
updatedBy
?:
string
updatedAt
?:
Date
subscribedUser
?:
any
[]
subscribedUser
?:
string
[]
}
export
type
Curriculum
=
{
...
...
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