Feature/admin home#67
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughAdds CreationTime audit metadata across backend DTOs and frontend contexts, introduces EntityMap and getMonthlyCreationChange helper, and refactors the admin dashboard into a kanban layout that integrates live student data and dynamic trends. ChangesAudit Field Integration & Dashboard Kanban Refactor
Sequence DiagramsequenceDiagram
participant DashboardPage
participant StudentProvider
participant TrendHelper as getMonthlyCreationChange
participant UI as KanbanCards
DashboardPage->>StudentProvider: studentActions.getAllStudents()
StudentProvider-->>DashboardPage: students[]
DashboardPage->>TrendHelper: pass students (creationTime)
TrendHelper-->>DashboardPage: percent change
DashboardPage->>UI: render Active Students stat + trend
DashboardPage->>UI: render Applications, Courses, Students cards
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@next-ts/app/`(dashboard)/admin/(protected)/dashboard/page.tsx:
- Around line 60-62: The trend icon is hardcoded to ArrowUpOutlined; change the
rendering in the stat trend block that uses
getMonthlyCreationChange(studentState.students) so it conditionally shows
ArrowUpOutlined when the value is >= 0 and ArrowDownOutlined when the value is <
0 (keep the numeric result next to the icon); update the JSX in the component
that uses styles.statTrend to branch on the result of getMonthlyCreationChange
rather than always rendering ArrowUpOutlined.
In `@next-ts/src/lib/common/helper-methods.ts`:
- Around line 151-169: The monthly bucketing uses local-time getters and
unvalidated Date parsing; change now/currentMonth/currentYear to use UTC
(now.getUTCMonth()/now.getUTCFullYear()), compute previousMonth/previousYear
from those UTC values, and when iterating items replace new
Date(item.creationTime) with a validated Date (e.g., const createdAt = new
Date(item.creationTime); if (isNaN(createdAt.getTime())) return;) then use
createdAt.getUTCMonth() and createdAt.getUTCFullYear() for comparisons; update
any references to currentMonth/currentYear/previousMonth/previousYear and
createdAt in the items.forEach block accordingly.
In `@next-ts/src/providers/application-provider/context.ts`:
- Line 23: Update the interface in context.ts to make the creationTime field
optional (add '?') so it matches ICourse and IStudent and supports partial
hydration/construction; locate the interface/type that declares creationTime in
this file (context.ts) and change creationTime: Date to creationTime?: Date and
run typechecks to ensure downstream usages handle undefined appropriately.
- Line 34: Remove the misplaced creationTime property from the
IApplicationStateContext interface and add it to the ICourseApplication entity
interface instead: locate IApplicationStateContext and delete the creationTime
field, then open ICourseApplication and declare creationTime?: Date (or
appropriate type) there so the timestamp lives on the entity rather than the
state container.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: c5751d4e-a15b-44e9-bbc4-33bfebdcf4fc
📒 Files selected for processing (10)
aspnet-core/src/Moipone.PublicSite.Application/CourseApplications/Dto/CourseApplicationDto.csaspnet-core/src/Moipone.PublicSite.Application/ShortCourses/Dto/ShortCourseDto.csaspnet-core/src/Moipone.PublicSite.Application/Students/Dto/StudentDto.csnext-ts/app/(dashboard)/admin/(protected)/dashboard/page.tsxnext-ts/app/(dashboard)/admin/(protected)/dashboard/style.tsnext-ts/src/lib/common/constants.tsxnext-ts/src/lib/common/helper-methods.tsnext-ts/src/providers/application-provider/context.tsnext-ts/src/providers/course-provider/context.tsnext-ts/src/providers/student-provider/context.ts
| <div className={styles.statTrend}> | ||
| <ArrowUpOutlined /> +12% this month | ||
| <ArrowUpOutlined /> {getMonthlyCreationChange(studentState.students)} | ||
| </div> |
There was a problem hiding this comment.
Trend direction indicator is hardcoded as “up”.
Line 61 always shows an upward icon, even when getMonthlyCreationChange(...) is negative.
Proposed fix
+import { ArrowDownOutlined, ArrowRightOutlined, ArrowUpOutlined, BookOutlined, FileTextOutlined, TrophyOutlined, UserOutlined } from '@ant-design/icons';
...
+ const studentMonthlyChange = getMonthlyCreationChange(students);
...
- <div className={styles.statTrend}>
- <ArrowUpOutlined /> {getMonthlyCreationChange(studentState.students)}
- </div>
+ <div className={styles.statTrend}>
+ {studentMonthlyChange >= 0 ? <ArrowUpOutlined /> : <ArrowDownOutlined />}
+ {Math.abs(studentMonthlyChange)}%
+ </div>🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@next-ts/app/`(dashboard)/admin/(protected)/dashboard/page.tsx around lines 60
- 62, The trend icon is hardcoded to ArrowUpOutlined; change the rendering in
the stat trend block that uses getMonthlyCreationChange(studentState.students)
so it conditionally shows ArrowUpOutlined when the value is >= 0 and
ArrowDownOutlined when the value is < 0 (keep the numeric result next to the
icon); update the JSX in the component that uses styles.statTrend to branch on
the result of getMonthlyCreationChange rather than always rendering
ArrowUpOutlined.
| const now = new Date(); | ||
|
|
||
| const currentMonth = now.getMonth(); | ||
| const currentYear = now.getFullYear(); | ||
|
|
||
| const previousMonth = currentMonth === 0 ? 11 : currentMonth - 1; | ||
| const previousYear = | ||
| currentMonth === 0 ? currentYear - 1 : currentYear; | ||
|
|
||
| let currentCount = 0; | ||
| let previousCount = 0; | ||
|
|
||
| items.forEach(item => { | ||
| if (!item.creationTime) return; | ||
|
|
||
| const createdAt = new Date(item.creationTime); | ||
|
|
||
| const month = createdAt.getMonth(); | ||
| const year = createdAt.getFullYear(); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
find . -name "helper-methods.ts" -type fRepository: blebelo/moipone
Length of output: 102
🏁 Script executed:
sed -n '145,180p' ./next-ts/src/lib/common/helper-methods.ts | cat -nRepository: blebelo/moipone
Length of output: 1113
🏁 Script executed:
sed -n '130,150p' ./next-ts/src/lib/common/helper-methods.ts | cat -nRepository: blebelo/moipone
Length of output: 548
🏁 Script executed:
rg "getMonthlyCreationChange" --type ts --type tsx -A 2 -B 2Repository: blebelo/moipone
Length of output: 87
🏁 Script executed:
rg "getMonthlyCreationChange" -A 2 -B 2Repository: blebelo/moipone
Length of output: 1520
🏁 Script executed:
sed -n '145,190p' ./next-ts/src/lib/common/helper-methods.ts | cat -nRepository: blebelo/moipone
Length of output: 1302
Use UTC month boundaries for consistent trend analytics across timezones.
The function uses local-time getMonth() and getFullYear() to bucket records by month. This causes month boundaries to shift based on each viewer's timezone—an item created at 2024-01-31 23:00 UTC appears in February for UTC+2 users but January for UTC-5 users. Dashboard trends become viewer-dependent rather than data-dependent.
Additionally, new Date(item.creationTime) can produce invalid dates without validation, leading to NaN in comparisons.
Use UTC variants and add date validation:
Proposed fix
- const currentMonth = now.getMonth();
- const currentYear = now.getFullYear();
+ const currentMonth = now.getUTCMonth();
+ const currentYear = now.getUTCFullYear();
...
- const month = createdAt.getMonth();
- const year = createdAt.getFullYear();
+ if (Number.isNaN(createdAt.getTime())) return;
+ const month = createdAt.getUTCMonth();
+ const year = createdAt.getUTCFullYear();🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@next-ts/src/lib/common/helper-methods.ts` around lines 151 - 169, The monthly
bucketing uses local-time getters and unvalidated Date parsing; change
now/currentMonth/currentYear to use UTC
(now.getUTCMonth()/now.getUTCFullYear()), compute previousMonth/previousYear
from those UTC values, and when iterating items replace new
Date(item.creationTime) with a validated Date (e.g., const createdAt = new
Date(item.creationTime); if (isNaN(createdAt.getTime())) return;) then use
createdAt.getUTCMonth() and createdAt.getUTCFullYear() for comparisons; update
any references to currentMonth/currentYear/previousMonth/previousYear and
createdAt in the items.forEach block accordingly.
| status?: RefListApplicationStatus; | ||
| decisionReason?: string; | ||
| decisionDate?: Date; | ||
| creationTime: Date; |
There was a problem hiding this comment.
Make creationTime optional for consistency.
The creationTime field is non-optional here, but optional in ICourse and IStudent. Frontend entity interfaces should use optional fields to support partial hydration and construction patterns.
🔧 Suggested fix
- creationTime: Date;
+ creationTime?: Date;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| creationTime: Date; | |
| creationTime?: Date; |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@next-ts/src/providers/application-provider/context.ts` at line 23, Update the
interface in context.ts to make the creationTime field optional (add '?') so it
matches ICourse and IStudent and supports partial hydration/construction; locate
the interface/type that declares creationTime in this file (context.ts) and
change creationTime: Date to creationTime?: Date and run typechecks to ensure
downstream usages handle undefined appropriately.
| error?: string; | ||
| application?: ICourseApplication; | ||
| applications?: ICourseApplication[]; | ||
| creationTime?: Date; |
There was a problem hiding this comment.
Remove misplaced creationTime field from state context.
State context interfaces (IApplicationStateContext) should only contain request state and entity references (application, applications), not loose entity fields. The creationTime field belongs on the ICourseApplication entity interface (line 23), not on the state container.
🔧 Suggested fix
application?: ICourseApplication;
applications?: ICourseApplication[];
- creationTime?: Date;
}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@next-ts/src/providers/application-provider/context.ts` at line 34, Remove the
misplaced creationTime property from the IApplicationStateContext interface and
add it to the ICourseApplication entity interface instead: locate
IApplicationStateContext and delete the creationTime field, then open
ICourseApplication and declare creationTime?: Date (or appropriate type) there
so the timestamp lives on the entity rather than the state container.
Summary by CodeRabbit
New Features
Style