Skip to content

Feature/admin home#67

Open
blebelo wants to merge 3 commits into
mainfrom
feature/adminHome
Open

Feature/admin home#67
blebelo wants to merge 3 commits into
mainfrom
feature/adminHome

Conversation

@blebelo
Copy link
Copy Markdown
Owner

@blebelo blebelo commented May 13, 2026

Summary by CodeRabbit

  • New Features

    • Creation timestamps now tracked for courses, students, and applications
    • Admin dashboard displays live student counts with automatic monthly trend calculations
    • Dashboard redesigned with kanban-style cards for Applications, Courses, and Students
  • Style

    • Updated admin dashboard layout with improved responsive design and visual hierarchy

Review Change Stack

@blebelo blebelo self-assigned this May 13, 2026
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
moipone Ready Ready Preview, Comment May 13, 2026 9:06am

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ea459f7b-2c0b-41bd-8161-9955e3c2d31a

📥 Commits

Reviewing files that changed from the base of the PR and between 82e747a and fd3be32.

📒 Files selected for processing (2)
  • next-ts/src/lib/common/helper-methods.ts
  • next-ts/src/providers/application-provider/context.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • next-ts/src/providers/application-provider/context.ts
  • next-ts/src/lib/common/helper-methods.ts

Walkthrough

Adds 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.

Changes

Audit Field Integration & Dashboard Kanban Refactor

Layer / File(s) Summary
Backend DTOs with Audit Fields
aspnet-core/src/Moipone.PublicSite.Application/CourseApplications/Dto/CourseApplicationDto.cs, aspnet-core/src/Moipone.PublicSite.Application/ShortCourses/Dto/ShortCourseDto.cs, aspnet-core/src/Moipone.PublicSite.Application/Students/Dto/StudentDto.cs
Three backend DTOs each gain a CreationTime property within a new #region Audit Field block.
Frontend Entity Context Definitions
next-ts/src/providers/application-provider/context.ts, next-ts/src/providers/course-provider/context.ts, next-ts/src/providers/student-provider/context.ts
Four frontend interfaces add optional creationTime?: Date; ICourse fixes a typo by renaming applicaionsapplications.
Shared Utilities for Monthly Analytics
next-ts/src/lib/common/constants.tsx, next-ts/src/lib/common/helper-methods.ts
Introduce EntityMap union type and getMonthlyCreationChange() helper that calculates month-over-month percentage change in item creation.
Dashboard Page Component with Student Integration
next-ts/app/(dashboard)/admin/(protected)/dashboard/page.tsx
Replace mock student count with live student-provider data; add guarded one-time load effect; swap mainGrid layout for kanban cards displaying Applications, Courses, and Students; compute Active Students count and trend from provider creationTime data.
Dashboard Styling for Kanban Layout
next-ts/app/(dashboard)/admin/(protected)/dashboard/style.ts
Replace mainGrid with responsive kanbanGrid; add kanban-specific styles (body, list, buttons, empty states); rename courseIconlistItemIcon; reduce application item padding.

Sequence Diagram

sequenceDiagram
  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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • blebelo/moipone#7: Introduces the ShortCourseDto definition that this PR extends with audit metadata.
  • blebelo/moipone#11: Adds course application APIs and DTO scaffolding that this PR augments with CreationTime fields.

Suggested reviewers

  • codespace-cloudmaindesk
  • mblebelo

Poem

🐰 A hop through time, we now shall keep,

Creation dates in storage deep,
Three cards in kanban, tidy and bright,
Students, courses, apps in sight,
Small hops, big timelines — what a delight!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Feature/admin home' is vague and uses non-descriptive branch-naming conventions rather than a clear description of the actual changes made. Revise the title to clearly describe the main change, such as 'Add CreationTime audit fields to DTOs and enhance admin dashboard with student tracking' or a more concise summary of the primary objective.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/adminHome

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 243d109 and 82e747a.

📒 Files selected for processing (10)
  • aspnet-core/src/Moipone.PublicSite.Application/CourseApplications/Dto/CourseApplicationDto.cs
  • aspnet-core/src/Moipone.PublicSite.Application/ShortCourses/Dto/ShortCourseDto.cs
  • aspnet-core/src/Moipone.PublicSite.Application/Students/Dto/StudentDto.cs
  • next-ts/app/(dashboard)/admin/(protected)/dashboard/page.tsx
  • next-ts/app/(dashboard)/admin/(protected)/dashboard/style.ts
  • next-ts/src/lib/common/constants.tsx
  • next-ts/src/lib/common/helper-methods.ts
  • next-ts/src/providers/application-provider/context.ts
  • next-ts/src/providers/course-provider/context.ts
  • next-ts/src/providers/student-provider/context.ts

Comment on lines 60 to 62
<div className={styles.statTrend}>
<ArrowUpOutlined /> +12% this month
<ArrowUpOutlined /> {getMonthlyCreationChange(studentState.students)}
</div>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

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.

Comment on lines +151 to +169
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();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

find . -name "helper-methods.ts" -type f

Repository: blebelo/moipone

Length of output: 102


🏁 Script executed:

sed -n '145,180p' ./next-ts/src/lib/common/helper-methods.ts | cat -n

Repository: blebelo/moipone

Length of output: 1113


🏁 Script executed:

sed -n '130,150p' ./next-ts/src/lib/common/helper-methods.ts | cat -n

Repository: blebelo/moipone

Length of output: 548


🏁 Script executed:

rg "getMonthlyCreationChange" --type ts --type tsx -A 2 -B 2

Repository: blebelo/moipone

Length of output: 87


🏁 Script executed:

rg "getMonthlyCreationChange" -A 2 -B 2

Repository: blebelo/moipone

Length of output: 1520


🏁 Script executed:

sed -n '145,190p' ./next-ts/src/lib/common/helper-methods.ts | cat -n

Repository: 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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

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.

Suggested change
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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant