Skip to content

modularize:patientappointments page into managable componenets#74

Merged
aditya241104 merged 1 commit into
mainfrom
modularize/patient-appointments
Oct 30, 2025
Merged

modularize:patientappointments page into managable componenets#74
aditya241104 merged 1 commit into
mainfrom
modularize/patient-appointments

Conversation

@aditya241104

@aditya241104 aditya241104 commented Oct 30, 2025

Copy link
Copy Markdown
Collaborator

closes #73

Summary by CodeRabbit

  • New Features
    • Appointments now organized into tabbed views (Upcoming, Today, Past) with category counts.
    • Search and filter functionality added for appointments.
    • New appointment statistics dashboard displaying total, upcoming, completed, and prescription-related metrics.
    • Enhanced appointment cards with status badges, doctor information, and prescription availability indicators.
    • Improved error and loading state displays.

@vercel

vercel Bot commented Oct 30, 2025

Copy link
Copy Markdown

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

Project Deployment Preview Comments Updated (UTC)
quick-clinic Ready Ready Preview Comment Oct 30, 2025 10:29am
quick-clinic-m9k7 Ready Ready Preview Comment Oct 30, 2025 10:29am

@coderabbitai

coderabbitai Bot commented Oct 30, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The PR modularizes the PatientAppointments page by extracting UI components (AppointmentCard, AppointmentHeader, AppointmentTabs, AppointmentStats, ErrorState) into a reusable component suite within a dedicated directory, replacing inline page logic with delegated component composition.

Changes

Cohort / File(s) Change Summary
New Appointment UI Components
client/src/components/Patient/PatientAppointments/AppointmentCard.jsx, AppointmentHeader.jsx, AppointmentStats.jsx, AppointmentTabs.jsx, ErrorState.jsx
Five new React components modularize appointment presentation. AppointmentCard formats dates, renders status badges (pending/confirmed/completed/cancelled/no-show), and displays doctor info, clinic, teleconsultation mode, and prescription status. AppointmentHeader provides search and status filter UI. AppointmentStats computes and displays four metrics (total, upcoming, completed, with prescription) in a responsive grid. AppointmentTabs categorizes appointments (upcoming/today/past) and renders tabbed navigation with empty-state UI. ErrorState displays error alerts.
Main Page Refactoring
client/src/pages/patient/PatientAppointments.jsx
Refactored to delegate rendering to new component suite. Replaces inline UI with AppointmentHeader, AppointmentTabs, AppointmentStats, and ErrorState components. Preserves data fetch, prescription checks, error handling, and state management (search term, filter status, active tab) but restructures control flow from monolithic composition to modular component orchestration.

Sequence Diagram

sequenceDiagram
    participant PA as PatientAppointments<br/>(Page)
    participant AH as AppointmentHeader
    participant AT as AppointmentTabs
    participant STAT as AppointmentStats
    participant AC as AppointmentCard
    participant ES as ErrorState

    PA->>PA: Fetch appointments & check prescriptions
    
    alt Error State
        PA->>ES: Render error via ErrorState
    else Loading State
        PA->>PA: Return Loading component
    else Success
        PA->>AH: Pass searchTerm, setSearchTerm,<br/>filterStatus, setFilterStatus
        activate AH
        AH->>AH: Render search input & filter dropdown
        deactivate AH
        
        PA->>AT: Pass appointments, prescriptionStatus,<br/>activeTab, setActiveTab, onAppointmentClick
        activate AT
        AT->>AT: Categorize by date (upcoming/today/past)
        AT->>AC: Map appointments to cards<br/>for active tab
        activate AC
        AC->>AC: Format date/time, render<br/>status badge & details
        deactivate AC
        AT->>AT: Render empty state if needed
        deactivate AT
        
        PA->>STAT: Pass appointments, prescriptionStatus
        activate STAT
        STAT->>STAT: Calculate metrics & render<br/>stats grid
        deactivate STAT
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

  • Areas requiring attention:
    • AppointmentCard.jsx: Date-fns formatting with try/catch fallback; status badge logic with five states and color/icon mapping; prescription status conditional rendering
    • AppointmentTabs.jsx: Date categorization logic using date-fns (isToday, isBefore, isAfter); useMemo optimization; empty-state messaging per tab
    • PatientAppointments.jsx: Verify component composition correctly preserves state flow and callback handling; confirm data passing to child components maintains reactive updates

Suggested labels

enhancement, UI

Poem

🐰 Five components hop into place,

Modular grace fills the space—

Cards, headers, tabs, and stats align,

PatientAppointments now feels fine!

Refactored with care,

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "modularize:patientappointments page into managable componenets" accurately and clearly describes the primary change—extracting the PatientAppointments page into separate, manageable components. The title is specific enough that a teammate reviewing the git history would immediately understand the purpose of the changeset. While there are minor spelling inconsistencies in the title (typos in "managable" and "componenets"), the intent is unambiguous and directly matches the actual changes implemented.
Linked Issues Check ✅ Passed The PR successfully fulfills the core requirements of issue #73, which requested modularization of client/src/pages/patient/PatientAppointments.jsx into separate components. All five new components (AppointmentCard, AppointmentHeader, AppointmentStats, AppointmentTabs, and ErrorState) have been created in the proposed target directory (client/src/components/Patient/PatientAppointments) as specified. The main PatientAppointments page has been properly refactored to use these new modular components while preserving existing functionality including data fetching, error handling, and filter/search logic.
Out of Scope Changes Check ✅ Passed All code changes in this PR are directly aligned with the stated objective of modularizing the PatientAppointments page. The five new component files represent extracted UI elements and logic that previously existed inline within the original page file, and the refactored PatientAppointments.jsx uses these components while maintaining the same functionality. No new features, dependencies, or unrelated modifications have been introduced outside the scope of the modularization effort.
✨ 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 modularize/patient-appointments

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

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
client/src/pages/patient/PatientAppointments.jsx (1)

27-41: Clear stale error state when refetching.
As written, any transient failure leaves error populated, so even if a later call to fetchAppointments succeeds (e.g., after wiring this helper to a manual “Try again” action), the ErrorState banner keeps showing. Reset the error before starting the request so the UI reflects the latest outcome.

Apply this diff:

 const fetchAppointments = async () => {
   try {
     setLoading(true);
+    setError(null);
     const response = await getPatientAppointments();
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6644f39 and a3302b4.

📒 Files selected for processing (6)
  • client/src/components/Patient/PatientAppointments/AppointmentCard.jsx (1 hunks)
  • client/src/components/Patient/PatientAppointments/AppointmentHeader.jsx (1 hunks)
  • client/src/components/Patient/PatientAppointments/AppointmentStats.jsx (1 hunks)
  • client/src/components/Patient/PatientAppointments/AppointmentTabs.jsx (1 hunks)
  • client/src/components/Patient/PatientAppointments/ErrorState.jsx (1 hunks)
  • client/src/pages/patient/PatientAppointments.jsx (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (6)
client/src/components/Patient/PatientAppointments/AppointmentStats.jsx (1)
client/src/pages/patient/PatientAppointments.jsx (2)
  • appointments (11-11)
  • prescriptionStatus (14-14)
client/src/components/Patient/PatientAppointments/AppointmentTabs.jsx (2)
client/src/pages/patient/PatientAppointments.jsx (3)
  • appointments (11-11)
  • activeTab (17-17)
  • prescriptionStatus (14-14)
client/src/components/Patient/PatientAppointments/AppointmentCard.jsx (1)
  • AppointmentCard (16-159)
client/src/components/Patient/PatientAppointments/ErrorState.jsx (1)
client/src/pages/patient/PatientAppointments.jsx (1)
  • error (13-13)
client/src/pages/patient/PatientAppointments.jsx (5)
client/src/components/ui/Loading.jsx (1)
  • Loading (4-63)
client/src/components/Patient/PatientAppointments/AppointmentHeader.jsx (1)
  • AppointmentHeader (3-43)
client/src/components/Patient/PatientAppointments/ErrorState.jsx (1)
  • ErrorState (3-12)
client/src/components/Patient/PatientAppointments/AppointmentTabs.jsx (1)
  • AppointmentTabs (6-124)
client/src/components/Patient/PatientAppointments/AppointmentStats.jsx (1)
  • AppointmentStats (3-54)
client/src/components/Patient/PatientAppointments/AppointmentHeader.jsx (1)
client/src/pages/patient/PatientAppointments.jsx (2)
  • searchTerm (15-15)
  • filterStatus (16-16)
client/src/components/Patient/PatientAppointments/AppointmentCard.jsx (1)
client/src/pages/patient/PatientAppointments.jsx (1)
  • prescriptionStatus (14-14)

Comment on lines +23 to +24
(isToday(aptDate) &&
differenceInHours(new Date(`${apt.date}T${apt.startTime}`), today) > 0)

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

Fix upcoming filter to include sub-hour appointments.

Line 24 calls differenceInHours(...) > 0, but date-fns truncates the result to whole hours. When an appointment starts within the next 59 minutes, Line 24 evaluates to 0 > 0, so the entry never appears in the Upcoming tab—even though it is still in the future. Users therefore lose sight of imminent appointments until they are an hour away (or less). Switch to a direct date comparison (or a minute-level diff) so any future start time, even within the hour, is included.

-import { differenceInHours, isFuture, isPast, isToday } from 'date-fns';
+import { isFuture, isPast, isToday } from 'date-fns';
@@
-            (isToday(aptDate) &&
-              differenceInHours(new Date(`${apt.date}T${apt.startTime}`), today) > 0)
+            (isToday(aptDate) && new Date(`${apt.date}T${apt.startTime}`) > today)
📝 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
(isToday(aptDate) &&
differenceInHours(new Date(`${apt.date}T${apt.startTime}`), today) > 0)
(isToday(aptDate) && new Date(`${apt.date}T${apt.startTime}`) > today)

@aditya241104 aditya241104 merged commit 03bac7e into main Oct 30, 2025
5 checks passed
@aditya241104 aditya241104 deleted the modularize/patient-appointments branch October 30, 2025 10:58
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.

[MODULARIZE]:PatientAppointments.jsx

1 participant