Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle for no activity or courses student layer 2 dash #669

Merged
merged 1 commit into from
Jan 19, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function ResidentWeeklyActivityTable({
</tr>
</thead>
<tbody className="flex flex-col gap-4 mt-4 overflow-auto h-36 scrollbar">
{courses ? (
{courses.length > 0 ? (
courses.map(
(course: RecentCourse, index: number) => {
const totalTime = convertSeconds(
Expand Down
32 changes: 19 additions & 13 deletions frontend/src/Pages/StudentDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,25 @@ export default function StudentLayer2() {
<h1 className="text-5xl">Hi, {user.name_first ?? 'Student'}!</h1>
<h2> Pick Up Where You Left Off</h2>
<div className="card card-row-padding flex flex-col gap-3">
<div className="gap-3 grid grid-cols-4">
{courses
.slice(0, slice)
.map((course: RecentCourse, index: number) => {
return (
<CourseCard
course={course}
recent
key={index}
/>
);
})}
</div>
{courses.length > 0 ? (
<div className="gap-3 grid grid-cols-4">
{courses
.slice(0, slice)
.map((course: RecentCourse, index: number) => {
return (
<CourseCard
course={course}
recent
key={index}
/>
);
})}
</div>
) : (
<p className="body">
You are not currently enrolled in any courses.
</p>
)}
{courses.length > 4 && (
<button
className="flex justify-end text-teal-3 hover:text-teal-4 body"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/routeLoaders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const getStudentLayer2Data: LoaderFunction = async () => {

return json({
courses: courses.courses,
week_activity: activity.activities
week_activity: activity.activities || []
});
};

Expand Down
Loading