Enhance Admin Dashboard with Batch Management and API Integration (Bonus Included)#3
Enhance Admin Dashboard with Batch Management and API Integration (Bonus Included)#3Sarvajeet2003 wants to merge 5 commits intoLeadlly:mainfrom
Conversation
|
Hi, can you please add a screen record video showing the proper flow of what you have built? |
|
I have attached the screen record video link.
https://drive.google.com/file/d/1d1tnrpEOYJixss1Zn-JAucAKSm7vp1DK/view?usp=sharing
…On Sun, Mar 2, 2025 at 5:38 PM Shivang Yadav ***@***.***> wrote:
Hi, can you please add a screen record video showing the proper flow of
what you have built?
—
Reply to this email directly, view it on GitHub
<#3 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AXG63G5MKGVX7HNPLAK33A32SLYE7AVCNFSM6AAAAABYFD372WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMOJSG4YDCMJYGU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
[image: shivang-16]*shivang-16* left a comment
(Leadlly/leadlly.admin.web#3)
<#3 (comment)>
Hi, can you please add a screen record video showing the proper flow of
what you have built?
—
Reply to this email directly, view it on GitHub
<#3 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AXG63G5MKGVX7HNPLAK33A32SLYE7AVCNFSM6AAAAABYFD372WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMOJSG4YDCMJYGU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
Best regards,
Sarvajeeth U K
+91-8310934161
Portfolio <https://sarvajeet2003.github.io/Portfolio/> | GitHub
<https://github.com/Sarvajeet2003>
|
Summary by BeetleThis PR transforms the Leadlly Admin Web application from a basic template into a fully functional educational institution management platform. It implements three major sections: Dashboard, Student Management (Batches), and Teacher Management, complete with API routes, reusable components, and comprehensive documentation. The changes establish a solid foundation for managing students, teachers, courses, and institutional data with an intuitive, responsive interface. 📁 File Changes Summary (Consolidated across all commits):
Total Changes: 17 files changed, +1842 additions, -78 deletions 🗺️ Walkthrough:graph TD
A[Dashboard Page] --> B[Institute Overview]
A --> C[Students Overview]
A --> D[Teachers Overview]
C --> E[View Students Button]
D --> F[View Teachers Button]
E --> G[Batches Page]
F --> H[Teachers List Page]
G --> I[Filter Controls]
I --> J[API: GET /api/batches]
J --> K[Display Batch Cards]
K --> L[View More Button]
L --> M[Students List Page]
M --> N[API: GET /api/batches/batchId/students]
N --> O[Display Student Table]
H --> P[Search & Filter]
P --> Q[Teacher Cards]
Q --> R[Click Teacher]
R --> S[Teacher Profile Page]
S --> T[Teacher Header]
S --> U[Teacher Stats]
S --> V[Teacher Classes]
S --> W[Teacher Performance]
style A fill:#e1d5e7
style G fill:#dae8fc
style H fill:#d5e8d4
style S fill:#fff2cc
🎯 Key Changes:
⚙️ SettingsSeverity Threshold: 📖 User Guide
|
Beetle is reviewing the changes — Let’s see what you’ve done!🔍 Under Review Commits (5)Files Changed (17)
Ignored Files (6)
⚙️ SettingsSeverity Threshold: 📖 User Guide
|
| <div className="w-full bg-gray-200 rounded-full h-2.5 mb-1"> | ||
| <div | ||
| className="bg-purple-600 h-2.5 rounded-full" | ||
| style={{ width: `${(batch.totalStudents / batch.maxStudents) * 100}%` }} |
There was a problem hiding this comment.
Division by zero vulnerability: If batch.maxStudents is 0, this calculation will result in Infinity or NaN, causing the progress bar to render incorrectly. This could happen if the API returns invalid data or if a batch is created without a maximum student limit.
Confidence: 5/5
Suggested Fix
| style={{ width: `${(batch.totalStudents / batch.maxStudents) * 100}%` }} | |
| style={{ width: `${batch.maxStudents > 0 ? (batch.totalStudents / batch.maxStudents) * 100 : 0}%` }} | |
Add a guard to check if maxStudents is greater than 0 before performing the division. This ensures the progress bar always renders with a valid percentage value.
Prompt for AI
Copy this prompt to your AI IDE to fix this issue locally:
In src/app/(root)/batches/page.tsx around line 189, the progress bar width
calculation divides totalStudents by maxStudents without checking if maxStudents
is zero, which could result in Infinity or NaN; add a ternary check to ensure
maxStudents is greater than 0 before performing the division, returning 0% if
maxStudents is 0 or invalid.
| </tr> | ||
| </thead> | ||
| <tbody className="bg-white divide-y divide-gray-200"> | ||
| {classes.map((cls) => ( |
There was a problem hiding this comment.
The classes.map() call lacks validation and will throw a runtime error if the classes prop is undefined, null, or not an array. This can crash the component and break the teacher profile page when invalid data is passed from the parent component or API.
Confidence: 5/5
Suggested Fix
| {classes.map((cls) => ( | |
| {classes?.map((cls) => ( | |
Use optional chaining (?.) to safely handle cases where classes might be undefined or null. Alternatively, add validation at the component level or provide a default empty array in the props destructuring: const TeacherClasses = ({ classes = [] }: TeacherClassesProps) => {
Prompt for AI
Copy this prompt to your AI IDE to fix this issue locally:
In src/app/(root)/teacher/[teacherId]/_components/TeacherClasses.tsx around line 40,
the classes.map() call will throw a runtime error if classes is undefined, null, or
not an array; add optional chaining by changing classes.map to classes?.map, and
consider adding a default empty array in the props destructuring on line 15 by
changing ({ classes }: TeacherClassesProps) to ({ classes = [] }: TeacherClassesProps)
to ensure the component always has a valid array to work with.
| <div className="w-full bg-gray-200 rounded-full h-2.5"> | ||
| <div | ||
| className="bg-purple-600 h-2.5 rounded-full" | ||
| style={{ width: `${(item.score / item.maxScore) * 100}%` }} |
There was a problem hiding this comment.
Division by zero vulnerability: If item.maxScore is 0, this calculation will result in Infinity or NaN, causing the progress bar to render incorrectly with invalid width values. This could happen if the API returns invalid performance data or if a metric hasn't been scored yet. This is the same issue identified in Comment #13 for the batches page.
Confidence: 5/5
Suggested Fix
| style={{ width: `${(item.score / item.maxScore) * 100}%` }} | |
| style={{ width: `${item.maxScore > 0 ? (item.score / item.maxScore) * 100 : 0}%` }} | |
Add a guard to check if maxScore is greater than 0 before performing the division. This ensures the progress bar always renders with a valid percentage value (0% if maxScore is invalid).
Prompt for AI
Copy this prompt to your AI IDE to fix this issue locally:
In src/app/(root)/teacher/[teacherId]/_components/TeacherPerformance.tsx around line 26,
the progress bar width calculation divides score by maxScore without checking if
maxScore is zero, which could result in Infinity or NaN; add a ternary check to
ensure maxScore is greater than 0 before performing the division, returning 0% if
maxScore is 0 or invalid, to prevent rendering issues with the progress bar.
| const page = parseInt(searchParams.get('page') || '1'); | ||
| const limit = parseInt(searchParams.get('limit') || '10'); |
There was a problem hiding this comment.
Missing input validation for pagination parameters: parseInt() can return NaN if the query parameters contain non-numeric values, which would cause the pagination logic to fail. Additionally, negative values or extremely large values could cause performance issues or incorrect behavior in array slicing operations (lines 148-150).
Confidence: 5/5
Suggested Fix
| const page = parseInt(searchParams.get('page') || '1'); | |
| const limit = parseInt(searchParams.get('limit') || '10'); | |
| const page = Math.max(1, parseInt(searchParams.get('page') || '1') || 1); | |
| const limit = Math.min(100, Math.max(1, parseInt(searchParams.get('limit') || '10') || 10)); | |
Add validation to ensure page is at least 1 and limit is between 1 and 100 (or your preferred maximum). This prevents NaN values, negative numbers, and excessively large limit values that could cause performance issues.
Prompt for AI
Copy this prompt to your AI IDE to fix this issue locally:
In src/app/api/batches/[batchId]/students/route.ts around lines 114-115, the page
and limit parameters are parsed with parseInt without validation for NaN, negative
values, or excessively large numbers; wrap both parseInt calls with Math.max to
ensure minimum values (page >= 1, limit >= 1), add Math.min to limit to enforce
a maximum value (e.g., 100), and use the || operator to provide fallback values
if parseInt returns NaN, ensuring robust pagination that can't be exploited or
cause performance issues.
📍 This suggestion applies to lines 114-115
I have completed the dashboard based on the Figma design. Additionally, I also created the Teacher's Section, as I felt it would contribute to the overall completeness of the project.
Name: Sarvajeeth U K
Email: Sarvajeeth21417@iiitd.ac.in
LinkedIn: https://www.linkedin.com/in/sarvajeeth-uk/