Skip to content

Conversation

@codeunia-dev
Copy link
Owner

@codeunia-dev codeunia-dev commented Dec 15, 2025

This PR enhances the Staff History page by bringing leave requests and attendance records together in one view, making it easier for admins and managers to understand staff availability at a glance.

Additionally, it includes a one-time attendance backfill script to ensure historical data stays consistent after the update.


✅ Key Highlights

  • 📊 Unified Staff History View

    • Leave requests are now displayed alongside attendance records
    • Improves visibility and reduces context switching
  • 🕰️ Attendance Backfill Script

    • Backfills missing attendance data where applicable
    • Helps maintain accurate historical records
  • 🧹 Refactoring & Cleanup

    • Minor logic cleanup for better readability and maintainability

🔍 Why This Change?

Previously, attendance and leave data lived in separate contexts, making it harder to:

  • Cross-check absences
  • Debug attendance inconsistencies
  • Get a complete picture of staff activity

This update solves that by showing the full story in one place.


🧪 Testing Notes

  • Verified staff history page renders both attendance and leave data correctly
  • Backfill script tested on existing records without impacting valid entries

Authored by: @akshay0611

Summary by CodeRabbit

  • New Features

    • Integrated leave records into staff history view alongside attendance records.
    • Records now sorted chronologically by date in descending order.
  • User Experience

    • Leave entries displayed with distinctive blue-tinted styling and leave type information.
    • Attendance entries show check-in/check-out times, duration, and status indicators.
    • Updated messaging for empty history state.

✏️ Tip: You can customize this high-level summary in your review settings.

…story page and add attendance backfill script.
@vercel
Copy link

vercel bot commented Dec 15, 2025

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

Project Deployment Review Updated (UTC)
codeunia Building Building Preview, Comment Dec 15, 2025 9:42am

@codeunia-dev codeunia-dev merged commit b6a4e38 into main Dec 15, 2025
2 of 4 checks passed
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 15, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Staff history page now displays attendance and leave records in a unified timeline. New LeaveRecord type with discriminator field introduced. Data fetching retrieves and merges both attendance logs and leave requests, sorted by date. Table rendering and stats calculations updated to handle both record types with distinct styling.

Changes

Cohort / File(s) Summary
Staff history timeline expansion
app/staff/history/page.tsx
Introduced LeaveRecord type alongside extended AttendanceRecord with type: 'attendance' discriminator. History state now accepts union type (AttendanceRecord | LeaveRecord)[]. Data fetching logic retrieves both attendance logs and leave requests, filters rejected leaves, and merges/sorts by date. Conditional rendering added to display leave entries (with blue-tinted styling) and attendance entries separately. Stats calculations refactored to compute metrics from attendance records only. UI text updated and messaging changed from "No attendance records found." to "No records found."

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Areas requiring extra attention:

  • Type system coherence: verify discriminator fields correctly distinguish records throughout component
  • Data fetching and merging logic: confirm attendance and leave data are properly combined, filtered (leaves exclude rejected status), and sorted correctly by respective date fields
  • Conditional rendering: validate that both record types display correctly with appropriate field mappings and styling differentiation
  • Stats calculations: ensure totalHours and daysPresent only derive from attendance records, not leaves
  • Edge cases: behavior with empty datasets, mixed record ordering, and rejected leave statuses

Poem

🐰✨ Two timelines now hop as one,
Attendance and leave records unified!
Blue-tinted rows show time away,
While attendance shines bright as day—
History flows smooth, complete, and spry! 🎉

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/staff-admin-attendance-routing

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 93f7eb7 and 58bc1bf.

📒 Files selected for processing (1)
  • app/staff/history/page.tsx (4 hunks)

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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants