@@ -49,7 +49,7 @@ const ClassworkLessons: FC<ClassworkLessonsProps> = () => {
4949 } ,
5050 } ,
5151 } )
52- const classworkLessons = useMemo (
52+ const classworkLessonsProps = useMemo (
5353 ( ) => dataClasswork ?. lessons . lessons ?? [ ] ,
5454 [ dataClasswork ?. lessons . lessons ] ,
5555 )
@@ -58,6 +58,28 @@ const ClassworkLessons: FC<ClassworkLessonsProps> = () => {
5858 ( ) => dataClasswork ?. lessons . count ?? 0 ,
5959 [ dataClasswork ?. lessons . count ] ,
6060 )
61+
62+ const classworkLessons : ANY [ ] = useMemo ( ( ) => classworkLessonsProps . map ( ( item : ANY , index : ANY ) => {
63+ const current = new Date ( )
64+ const startTime = new Date ( item . startTime )
65+ const beforeLessonStartTime = classworkLessonsProps [ index - 1 ]
66+ ? new Date ( classworkLessonsProps [ index - 1 ] ?. startTime )
67+ : current
68+ if (
69+ startTime . getTime ( ) > current . getTime ( ) &&
70+ beforeLessonStartTime . getTime ( ) <= current . getTime ( )
71+ ) {
72+ return {
73+ ...item ,
74+ isNext : true ,
75+ }
76+ }
77+ return {
78+ ...item ,
79+ isNext : false ,
80+ }
81+ } ) , [ classworkLessonsProps ] )
82+
6183 if ( ! courseId ) {
6284 return < div > Course not found</ div >
6385 }
@@ -84,8 +106,14 @@ const ClassworkLessons: FC<ClassworkLessonsProps> = () => {
84106 {
85107 label : 'Tiêu đề' ,
86108 render : ( classworkLesson , index ) => (
87- < Typography variant = "body1" fontWeight = "bold" >
109+ < Typography
110+ variant = "body1"
111+ fontWeight = "bold"
112+ >
88113 < Link
114+ className = {
115+ classworkLesson . isNext ? 'title-hightlight' : ''
116+ }
89117 to = { buildPath (
90118 STUDYING_COURSE_DETAIL_CLASSWORK_LESSON ,
91119 {
@@ -94,7 +122,9 @@ const ClassworkLessons: FC<ClassworkLessonsProps> = () => {
94122 } ,
95123 ) }
96124 >
97- Buổi { page === 0 ? index + 1 : index + 1 + ( page * perPage ) } : { classworkLesson . description }
125+ Buổi{ ' ' }
126+ { page === 0 ? index + 1 : index + 1 + page * perPage } :{ ' ' }
127+ { classworkLesson . description } { classworkLesson . isNext ? ' (Buổi tiếp theo)' : '' }
98128 </ Link >
99129 </ Typography >
100130 ) ,
0 commit comments