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
Show 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) => {
...
@@ -6,15 +6,14 @@ export const subscribeCurriculum = async (req, res) => {
try
{
try
{
// Check if the user is already subscribed to the curriculum
// 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
(
!
userProgress
)
{
// If there is no user progress record for this user, create a new one
// If there is no user progress record for this user, create a new one
const
newU
serProgress
=
new
UserProgress
({
u
serProgress
=
new
UserProgress
({
userId
,
userId
,
curriculums
:
[
curriculum
],
curriculums
:
[
curriculum
],
});
});
await
newUserProgress
.
save
();
}
else
{
}
else
{
// If there is an existing user progress record, check if the curriculum already exists
// If there is an existing user progress record, check if the curriculum already exists
const
existingCurriculumIndex
=
userProgress
.
curriculums
.
findIndex
(
c
=>
c
.
curriculumCode
===
curriculum
.
curriculumCode
);
const
existingCurriculumIndex
=
userProgress
.
curriculums
.
findIndex
(
c
=>
c
.
curriculumCode
===
curriculum
.
curriculumCode
);
...
...
Project/Frontend/SignConnectPlus/src/pages/learning-management/learning-curriculums/list/list.tsx
View file @
2d1af9bb
...
@@ -47,6 +47,7 @@ const allColumns = [
...
@@ -47,6 +47,7 @@ const allColumns = [
const
List
=
()
=>
{
const
List
=
()
=>
{
const
dispatch
=
useDispatch
();
const
dispatch
=
useDispatch
();
const
{
curriculums
,
error
,
success
,
isLoading
}
=
useSelector
(
state
=>
state
.
curriculum
);
const
{
curriculums
,
error
,
success
,
isLoading
}
=
useSelector
(
state
=>
state
.
curriculum
);
const
{
success
:
userProgressSuccess
}
=
useSelector
(
state
=>
state
.
userProgress
);
const
[
data
,
setData
]
=
useState
<
curriculumType
[]
>
([])
const
[
data
,
setData
]
=
useState
<
curriculumType
[]
>
([])
...
@@ -91,7 +92,7 @@ const List = () => {
...
@@ -91,7 +92,7 @@ const List = () => {
*/
*/
useEffect
(()
=>
{
useEffect
(()
=>
{
dispatch
(
fetchCurriculums
());
dispatch
(
fetchCurriculums
());
},
[
dispatch
]);
},
[
dispatch
,
userProgressSuccess
]);
useEffect
(()
=>
{
useEffect
(()
=>
{
setData
(
curriculums
);
setData
(
curriculums
);
...
...
Project/Frontend/SignConnectPlus/src/sections/learning-management/learning-curriculums/CurriculumCard.tsx
View file @
2d1af9bb
...
@@ -15,7 +15,7 @@ import {
...
@@ -15,7 +15,7 @@ import {
import
MainCard
from
'
components/MainCard
'
;
import
MainCard
from
'
components/MainCard
'
;
// assets
// assets
import
{
PlusOutlined
,
SendOutlined
}
from
'
@ant-design/icons
'
;
import
{
MinusOutlined
,
PlusOutlined
,
SendOutlined
}
from
'
@ant-design/icons
'
;
import
AnimateButton
from
'
components/@extended/AnimateButton
'
;
import
AnimateButton
from
'
components/@extended/AnimateButton
'
;
import
useAuth
from
'
hooks/useAuth
'
;
import
useAuth
from
'
hooks/useAuth
'
;
import
{
useDispatch
,
useSelector
}
from
'
store
'
;
import
{
useDispatch
,
useSelector
}
from
'
store
'
;
...
@@ -46,6 +46,7 @@ const CurriculumCard = ({ curriculum }: { curriculum: curriculumType }) => {
...
@@ -46,6 +46,7 @@ const CurriculumCard = ({ curriculum }: { curriculum: curriculumType }) => {
const
[
desc
,
setDesc
]
=
useState
(
curriculum
.
curriculumDescription
?.
slice
(
0
,
100
))
const
[
desc
,
setDesc
]
=
useState
(
curriculum
.
curriculumDescription
?.
slice
(
0
,
100
))
const
[
readMore
,
setReadMore
]
=
useState
(
false
)
const
[
readMore
,
setReadMore
]
=
useState
(
false
)
const
[
isSubscribed
,
setIsSubscribed
]
=
useState
(
false
)
/**
/**
* API Config
* API Config
...
@@ -135,6 +136,20 @@ const CurriculumCard = ({ curriculum }: { curriculum: curriculumType }) => {
...
@@ -135,6 +136,20 @@ const CurriculumCard = ({ curriculum }: { curriculum: curriculumType }) => {
}
}
},
[
success
])
},
[
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
(
return
(
<>
<>
<
Animation
<
Animation
...
@@ -168,27 +183,33 @@ const CurriculumCard = ({ curriculum }: { curriculum: curriculumType }) => {
...
@@ -168,27 +183,33 @@ const CurriculumCard = ({ curriculum }: { curriculum: curriculumType }) => {
</
Typography
>
</
Typography
>
</
Grid
>
</
Grid
>
<
Grid
item
xs=
{
6
}
>
<
Grid
item
xs=
{
6
}
>
<
Box
sx=
{
{
display
:
'
inline-block
'
}
}
>
<
Box
sx=
{
{
display
:
'
inline-block
'
,
width
:
"
100%
"
}
}
>
<
AnimateButton
>
<
AnimateButton
>
<
Button
<
Button
fullWidth
fullWidth
size=
'small'
variant=
"outlined"
variant=
"outlined"
endIcon=
{
<
PlusOutlined
/>
}
endIcon=
{
isSubscribed
?
<
MinusOutlined
/>
:
<
PlusOutlined
/>
}
sx=
{
{
my
:
2
,
width
:
"
100%
"
}
}
sx=
{
{
my
:
2
,
width
:
"
100%
"
}
}
onClick=
{
FollowCurriculum
}
onClick=
{
()
=>
{
color=
'success'
if
(
!
isSubscribed
)
{
FollowCurriculum
()
}
}
}
color=
{
isSubscribed
?
'
secondary
'
:
'
success
'
}
disabled=
{
isLoading
}
disabled=
{
isLoading
}
>
>
{
isLoading
?
<
CircularProgress
/>
:
'
Follow Curriculum
'
}
{
isLoading
?
<
CircularProgress
/>
:
<>
{
isSubscribed
?
'
Un Follow Curriculum
'
:
'
Follow Curriculum
'
}
</>
}
</
Button
>
</
Button
>
</
AnimateButton
>
</
AnimateButton
>
</
Box
>
</
Box
>
</
Grid
>
</
Grid
>
<
Grid
item
xs=
{
6
}
>
<
Grid
item
xs=
{
6
}
>
<
Box
sx=
{
{
display
:
'
inline-block
'
}
}
>
<
Box
sx=
{
{
display
:
'
inline-block
'
,
width
:
"
100%
"
}
}
>
<
AnimateButton
>
<
AnimateButton
>
<
Button
<
Button
fullWidth
fullWidth
size=
'small'
variant=
"outlined"
variant=
"outlined"
endIcon=
{
<
SendOutlined
/>
}
endIcon=
{
<
SendOutlined
/>
}
sx=
{
{
my
:
2
,
width
:
"
100%
"
}
}
sx=
{
{
my
:
2
,
width
:
"
100%
"
}
}
...
...
Project/Frontend/SignConnectPlus/src/types/curriculum.ts
View file @
2d1af9bb
...
@@ -14,7 +14,7 @@ export interface curriculumType {
...
@@ -14,7 +14,7 @@ export interface curriculumType {
createdAt
?:
Date
createdAt
?:
Date
updatedBy
?:
string
updatedBy
?:
string
updatedAt
?:
Date
updatedAt
?:
Date
subscribedUser
?:
any
[]
subscribedUser
?:
string
[]
}
}
export
type
Curriculum
=
{
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