Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 53 additions & 9 deletions app/[locale]/dashboard/student/courses/[courseId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Button } from '@/components/ui/button'
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '@/components/ui/card'
import { Progress } from '@/components/ui/progress'
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'
import { cn } from '@/utils'
import { createClient } from '@/utils/supabase/server'

const ExerciseCard = ({ title, description, difficulty, type, status, courseId, exerciseId, t }) => (
Expand Down Expand Up @@ -278,10 +279,14 @@ export default async function CourseStudentPage({
<TabsTrigger value="exams">{t('dashboard.student.CourseStudentPage.exams')}</TabsTrigger>
</TabsList>
<TabsContent
className='grid gap-4 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4'
className={
cn('grid gap-4 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4',
courseData.data.lessons.length === 0 && 'flex justify-center'
)
}
value="lessons"
>
{courseData.data.lessons
{courseData.data.lessons.length > 0 ? courseData.data.lessons
.sort((a, b) => a.sequence - b.sequence)
.map((lesson) => {
const status = lesson.lesson_completions.length > 0 ? 'Completed' : lesson.lessons_ai_task_messages.length > 0 ? 'In Progress' : 'Not Started'
Expand All @@ -299,13 +304,25 @@ export default async function CourseStudentPage({
t={t}
/>
)
})}
}
) : (
<NoDataPlaceholder
iconSrc="/img/404(2).jpeg"
iconAlt="No Data"
message={t('dashboard.student.CourseStudentPage.noLessons')}
description={t('dashboard.student.CourseStudentPage.noLessonsDescription')}
/>
)}
</TabsContent>
<TabsContent
className='grid gap-4 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4'
className={
cn('grid gap-4 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4',
courseData.data.exercises.length === 0 && 'flex justify-center'
)
}
value="exercises"
>
{courseData.data.exercises
{courseData.data.exercises.length > 0 ? courseData.data.exercises
.map((exercise) => {
// if exercise has a completion, it is completed, else if it has a message, it is in progress else not started
const status = exercise.exercise_completions?.length > 0 ? 'Completed' : exercise.exercise_messages?.length > 0 ? 'In Progress' : 'Not Started'
Expand All @@ -323,13 +340,25 @@ export default async function CourseStudentPage({
t={t}
/>
)
})}
}
) : (
<NoDataPlaceholder
iconSrc="/img/404(2).jpeg"
iconAlt="No Data"
message={t('dashboard.student.CourseStudentPage.noExercises')}
description={t('dashboard.student.CourseStudentPage.noExercisesDescription')}
/>
)}
</TabsContent>
<TabsContent
className='grid gap-4 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4'
className={
cn('grid gap-4 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4',
courseData.data.exams.length === 0 && 'flex justify-center'
)
}
value="exams"
>
{courseData.data.exams
{courseData.data.exams.length > 0 ? courseData.data.exams
.sort((a, b) => a.sequence - b.sequence)
.map((exam) => (
<ExamCard
Expand All @@ -353,9 +382,24 @@ export default async function CourseStudentPage({
examId={exam.exam_id}
t={t}
/>
))}
)) : (
<NoDataPlaceholder
iconSrc="/img/404(2).jpeg"
iconAlt="No Data"
message={t('dashboard.student.CourseStudentPage.noExams')}
description={t('dashboard.student.CourseStudentPage.noExamsDescription')}
/>
)}
</TabsContent>
</Tabs>
</div>
)
}

const NoDataPlaceholder = ({ iconSrc, iconAlt, message, description }) => (
<div className="flex flex-col items-center justify-center p-6 text-center bg-white dark:bg-gray-800 rounded-lg shadow-md container mx-auto">
<Image src={iconSrc} alt={iconAlt} width={250} height={250} className="mb-4 rounded-lg" />
<h2 className="text-xl font-semibold mb-2">{message}</h2>
<p className="text-gray-600 dark:text-gray-400">{description}</p>
</div>
)
6 changes: 6 additions & 0 deletions app/locales/en/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ export default {
exercisesCompleted: 'Exercises Completed',
inProgress: 'In Progress',
continue: 'Continue',
noExercises: 'No exercises available',
noExercisesDescription: 'There are no exercises available for this lesson.',
noLessons: 'No lessons available',
noLessonsDescription: 'There are no lessons available for this course.',
noExams: 'No exams available',
noExamsDescription: 'There are no exams available for this course.',
},
LessonPage: {
description: 'View and track your progress through the course lessons.',
Expand Down
6 changes: 6 additions & 0 deletions app/locales/es/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ export default {
exercisesCompleted: 'Ejercicios completados',
inProgress: 'En progreso',
continue: 'Continuar',
noExercises: 'No hay ejercicios disponibles',
noExercisesDescription: 'No hay ejercicios disponibles para este curso.',
noLessons: 'No hay lecciones disponibles',
noLessonsDescription: 'No hay lecciones disponibles para este curso.',
noExams: 'No hay exámenes disponibles',
noExamsDescription: 'No hay exámenes disponibles para este curso.',
},
LessonPage: {
description: 'Ver y realizar un seguimiento de tu progreso a través de la lección.',
Expand Down
Binary file added public/img/404(2).jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.