Skip to content

refactor: add and remove logic to consolidate schedule popout to remove duplicated code#1128

Merged
carddev81 merged 2 commits into
CK-7vn/total-refactorfrom
carddev81/refactorschedulepopouts
May 13, 2026
Merged

refactor: add and remove logic to consolidate schedule popout to remove duplicated code#1128
carddev81 merged 2 commits into
CK-7vn/total-refactorfrom
carddev81/refactorschedulepopouts

Conversation

@carddev81
Copy link
Copy Markdown
Contributor

Pre-Submission PR Checklist

  • No debug/console/fmt.Println statements
  • Unnecessary development comments removed
  • All acceptance criteria verified
  • Functions according to ticket specifications
  • Tested manually where applicable
  • Branch rebased with latest main
  • No business logic exists within the database layer

Description of the change

Schedule popout logic was consolidated between the Schedule page and the Classes Detail page. Removes duplicated logic and now the code is shared between both pages.

NOTE: Didn't touch any modals here, left as is.

  • Related issues: N/A Refactor

Screenshot(s)

Schedule Page:

image

Class Details Page:
image

@carddev81 carddev81 requested a review from a team as a code owner May 12, 2026 20:25
@carddev81 carddev81 requested review from CK-7vn and removed request for a team May 12, 2026 20:25
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ab137652-4d71-4e78-96cb-7474080e7a88

📥 Commits

Reviewing files that changed from the base of the PR and between c0620cf and 957d359.

📒 Files selected for processing (1)
  • frontend/src/components/schedule/SessionDetailSheet.tsx

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Session detail shows program name and optional "Active" status badge.
    • New action callbacks: take attendance, view class details, and custom reschedule flow.
    • Customizable cancellation undo label and option to hide rescheduled badges.
    • Optional event override and flag to disable modify actions.
  • Refactor

    • Consolidated session detail UI and simplified schedule action flows.

Walkthrough

SessionDetailSheet gains optional admin/calendar props and callbacks; Schedule.tsx adds event→SessionDisplay mapping and centralizes session UI into the enhanced SessionDetailSheet, replacing the previous inline sheet and trimming modals to reschedule and restore. Two class-detail tabs update imports to the shared component.

Changes

Session Detail Sheet Consolidation & Admin Integration

Layer / File(s) Summary
SessionDetailSheet Props Contract Extension
frontend/src/components/schedule/SessionDetailSheet.tsx
SessionDetailSheetProps expands with optional fields for programName, showActiveBadge, hideRescheduledBadge, cancellationActionLabel, onReschedule, onTakeAttendance, onViewClassDetails, facilityEvent, and disableModifyActions; props receive defaults on destructure.
SessionDetailSheet Data & State Handling
frontend/src/components/schedule/SessionDetailSheet.tsx
canModify is additionally gated by disableModifyActions and reschedule state; facilityEvent uses an override when provided; showTakeAttendance is derived from callbacks and session/cancellation/attendance state.
SessionDetailSheet Badges & Status Display
frontend/src/components/schedule/SessionDetailSheet.tsx
Rescheduled and Rescheduled Class badges respect hideRescheduledBadge; new Active badge rendered when showActiveBadge is true; Status visibility uses nullish coalescing to detect overrides.
SessionDetailSheet Content & Styling
frontend/src/components/schedule/SessionDetailSheet.tsx
Program name conditionally rendered; Room and Instructor lines use !!originalRoom/!!originalInstructorName for line-through and display override values via nullish coalescing; Rescheduled Class block and cancellation undo buttons use cancellationActionLabel.
SessionDetailSheet Actions & Modal Rendering
frontend/src/components/schedule/SessionDetailSheet.tsx
Actions panel appears when canModify or take-attendance is available; Take Attendance and View Full Class Details buttons rendered from callbacks; Reschedule button calls onReschedule if provided or opens internal modal otherwise; reschedule modal is not shown when external handler exists.
Schedule Data Layer: Helpers & State
frontend/src/pages/Schedule.tsx
Adds date/time formatting utilities and facilityEventToSessionDisplay mapper to compute formatted date/time and status flags; component state removes cancel/change-room/change-instructor modal state and keeps only reschedule/restore flags.
Schedule Integration & Action Handlers
frontend/src/pages/Schedule.tsx
Adds handlers for attendance, class-detail navigation, reschedule, and cancellation/restore; derives UI flags (past, cancellationActionLabel, disableModifyActions, showActiveBadge); replaces inline Sheet UI with SessionDetailSheet and reduces modal set to reschedule and restore.
Import Path Consolidation
frontend/src/pages/class-detail/ScheduleTab.tsx, frontend/src/pages/class-detail/SessionsTab.tsx
Updates SessionDetailSheet imports from ./SessionDetailSheet to @/components/schedule/SessionDetailSheet.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main objective: consolidating schedule popout logic to remove duplicated code between pages.
Description check ✅ Passed The description is directly related to the changeset, explaining the consolidation of schedule popout logic and removal of duplicated code between Schedule and Class Details pages.
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

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

@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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
frontend/src/components/schedule/SessionDetailSheet.tsx (1)

200-205: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Consider renaming disableModifyActions to reduce double-negative.

The prop disableModifyActions requires !disableModifyActions in the condition, creating a double-negative that can reduce readability. Consider renaming to allowModifyActions or canModifyActions for clearer intent.

♻️ Proposed refactor

In the interface (lines 55-75):

-    /** Force-disable the modify actions block (Reschedule/Cancel/Change Instructor/Change Room) regardless of session flags. */
-    disableModifyActions?: boolean;
+    /** Enable the modify actions block (Reschedule/Cancel/Change Instructor/Change Room) when true. */
+    allowModifyActions?: boolean;

In the destructuring and logic (lines 138-205):

-    disableModifyActions = false
+    allowModifyActions = true
 }: SessionDetailSheetProps) {
     ...
     const canModify =
-        !disableModifyActions &&
+        allowModifyActions &&
         !hasAttendance &&
🤖 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 `@frontend/src/components/schedule/SessionDetailSheet.tsx` around lines 200 -
205, The condition computing canModify is hard to read due to the prop name
disableModifyActions causing a double-negative; rename the prop to
allowModifyActions (or canModifyActions) in the component's props/interface,
update every destructuring site that reads disableModifyActions (e.g., the props
declaration and the destructuring around where canModify is computed), and
replace the negation in the canModify expression with the positive check (use
allowModifyActions instead of !disableModifyActions) so the computed const
canModify = allowModifyActions && !hasAttendance && !isCancelled &&
!isRescheduledFrom && !isCancelledReschedule remains clear and correct; ensure
any parent component usages and type definitions are updated to the new prop
name to keep types consistent.
🤖 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 `@frontend/src/components/schedule/SessionDetailSheet.tsx`:
- Around line 266-275: The Active badge currently shares the same Tailwind
classes as the Completed badge, causing confusion; update the Badge rendered
when showActiveBadge is true (the Badge in the showActiveBadge branch) to use a
distinct color scheme (e.g., a blue or amber palette) by replacing the className
"bg-green-50 text-[`#556830`] border-green-200" with a new set of classes that
visually distinguish Active from Completed (choose consistent bg, text and
border classes such as "bg-blue-50 text-[`#0f62fe`] border-blue-200" or similar)
so the Active Badge is clearly different from the Completed Badge.
- Around line 24-28: SessionDetailSheet imports page-level artifacts which
breaks component boundaries: move the shared types and helpers (session-utils
exports SessionDisplay and findActiveOverride) into a dedicated shared utilities
directory and update imports in SessionDetailSheet and any other consumers to
reference that shared module; then resolve the duplicate RescheduleSessionModal
implementations by either consolidating them into a single shared modal
implementation (pick the desired behavior—FormModal with room conflict handling
or Dialog with SWR data fetching) and placing it under components/shared or
components/schedule, or split responsibilities clearly (e.g., keep data-fetching
wrapper in pages/class-detail that uses a shared presentational
RescheduleSessionModal from components) and update SessionDetailSheet to import
the correct consolidated/shared RescheduleSessionModal.

---

Outside diff comments:
In `@frontend/src/components/schedule/SessionDetailSheet.tsx`:
- Around line 200-205: The condition computing canModify is hard to read due to
the prop name disableModifyActions causing a double-negative; rename the prop to
allowModifyActions (or canModifyActions) in the component's props/interface,
update every destructuring site that reads disableModifyActions (e.g., the props
declaration and the destructuring around where canModify is computed), and
replace the negation in the canModify expression with the positive check (use
allowModifyActions instead of !disableModifyActions) so the computed const
canModify = allowModifyActions && !hasAttendance && !isCancelled &&
!isRescheduledFrom && !isCancelledReschedule remains clear and correct; ensure
any parent component usages and type definitions are updated to the new prop
name to keep types consistent.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 3af9ee74-2194-4a3b-b640-0d9ee2ec0e4c

📥 Commits

Reviewing files that changed from the base of the PR and between ddab0d2 and c0620cf.

📒 Files selected for processing (4)
  • frontend/src/components/schedule/SessionDetailSheet.tsx
  • frontend/src/pages/Schedule.tsx
  • frontend/src/pages/class-detail/ScheduleTab.tsx
  • frontend/src/pages/class-detail/SessionsTab.tsx

Comment on lines +24 to +28
import { RescheduleSessionModal } from '@/pages/class-detail/RescheduleSessionModal';
import {
findActiveOverride,
type SessionDisplay
} from '@/pages/class-detail/session-utils';
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot May 12, 2026

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:

#!/bin/bash
# Check if RescheduleSessionModal and session-utils are used in multiple locations
rg -l 'RescheduleSessionModal' --type=tsx --type=ts
rg -l 'session-utils|SessionDisplay' --type=tsx --type=ts

Repository: UnlockedLabs/UnlockEdv2

Length of output: 123


🏁 Script executed:

#!/bin/bash
# Search for files containing RescheduleSessionModal (without --type flags)
echo "=== Files containing RescheduleSessionModal ==="
rg 'RescheduleSessionModal' -l --glob='*.ts' --glob='*.tsx' frontend/src/

echo ""
echo "=== Files containing session-utils or SessionDisplay ==="
rg 'session-utils|SessionDisplay' -l --glob='*.ts' --glob='*.tsx' frontend/src/

echo ""
echo "=== Check directory structure of pages and components ==="
find frontend/src/pages/class-detail -type f \( -name '*.ts' -o -name '*.tsx' \) 2>/dev/null | head -20

echo ""
echo "=== Check SessionDetailSheet location and imports ==="
cat -n frontend/src/components/schedule/SessionDetailSheet.tsx | head -35

Repository: UnlockedLabs/UnlockEdv2

Length of output: 3063


🏁 Script executed:

#!/bin/bash
echo "=== RescheduleSessionModal in components/schedule ==="
head -30 frontend/src/components/schedule/RescheduleSessionModal.tsx

echo ""
echo "=== RescheduleSessionModal in pages/class-detail ==="
head -30 frontend/src/pages/class-detail/RescheduleSessionModal.tsx

echo ""
echo "=== Check what SessionDetailSheet is actually using ==="
rg 'RescheduleSessionModal' -A 3 -B 3 frontend/src/components/schedule/SessionDetailSheet.tsx | head -40

echo ""
echo "=== Check if session-utils should be in shared location ==="
wc -l frontend/src/pages/class-detail/session-utils.ts
head -20 frontend/src/pages/class-detail/session-utils.ts

Repository: UnlockedLabs/UnlockEdv2

Length of output: 3336


Move shared utilities to a dedicated shared directory; consolidate RescheduleSessionModal implementations.

SessionDetailSheet (in components/schedule/) imports RescheduleSessionModal from @/pages/class-detail/ and depends on session-utils (also from pages), creating an architectural issue where a shared component depends on page-specific code.

Additionally, RescheduleSessionModal has two distinct implementations:

  • components/schedule/RescheduleSessionModal.tsx (FormModal-based with room conflict handling)
  • pages/class-detail/RescheduleSessionModal.tsx (Dialog-based with SWR data fetching)

The current usage in SessionDetailSheet imports the pages version, but this inconsistency suggests an incomplete refactoring. Move session-utils and its exports (SessionDisplay, findActiveOverride) to a shared utilities directory, then consolidate the RescheduleSessionModal implementations or clearly separate their concerns and place them in the correct architectural layer.

🤖 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 `@frontend/src/components/schedule/SessionDetailSheet.tsx` around lines 24 -
28, SessionDetailSheet imports page-level artifacts which breaks component
boundaries: move the shared types and helpers (session-utils exports
SessionDisplay and findActiveOverride) into a dedicated shared utilities
directory and update imports in SessionDetailSheet and any other consumers to
reference that shared module; then resolve the duplicate RescheduleSessionModal
implementations by either consolidating them into a single shared modal
implementation (pick the desired behavior—FormModal with room conflict handling
or Dialog with SWR data fetching) and placing it under components/shared or
components/schedule, or split responsibilities clearly (e.g., keep data-fetching
wrapper in pages/class-detail that uses a shared presentational
RescheduleSessionModal from components) and update SessionDetailSheet to import
the correct consolidated/shared RescheduleSessionModal.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This will be consolidated in another PR.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@carddev81, understood — thanks for the context! Would you like me to open a follow-up GitHub issue to track the consolidation of session-utils / SessionDisplay / findActiveOverride into a shared utilities directory and the resolution of the duplicate RescheduleSessionModal implementations? That way it won't get lost before the next PR.

Comment on lines +266 to +275
if (showActiveBadge) {
return (
<Badge
variant="outline"
className="bg-green-50 text-[#556830] border-green-200"
>
Active
</Badge>
);
}
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot May 12, 2026

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

Active and Completed badges use identical styling.

The "Active" badge (lines 266-275) uses the same colors as the "Completed" badge (lines 256-265): bg-green-50 text-[#556830] border-green-200. This may cause users to confuse active sessions with completed ones.

Consider using distinct colors for the "Active" badge to improve visual differentiation.

🎨 Proposed fix with distinct styling
         if (showActiveBadge) {
             return (
                 <Badge
                     variant="outline"
-                    className="bg-green-50 text-[`#556830`] border-green-200"
+                    className="bg-emerald-50 text-emerald-700 border-emerald-300"
                 >
                     Active
                 </Badge>
             );
         }
📝 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
if (showActiveBadge) {
return (
<Badge
variant="outline"
className="bg-green-50 text-[#556830] border-green-200"
>
Active
</Badge>
);
}
if (showActiveBadge) {
return (
<Badge
variant="outline"
className="bg-emerald-50 text-emerald-700 border-emerald-300"
>
Active
</Badge>
);
}
🤖 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 `@frontend/src/components/schedule/SessionDetailSheet.tsx` around lines 266 -
275, The Active badge currently shares the same Tailwind classes as the
Completed badge, causing confusion; update the Badge rendered when
showActiveBadge is true (the Badge in the showActiveBadge branch) to use a
distinct color scheme (e.g., a blue or amber palette) by replacing the className
"bg-green-50 text-[`#556830`] border-green-200" with a new set of classes that
visually distinguish Active from Completed (choose consistent bg, text and
border classes such as "bg-blue-50 text-[`#0f62fe`] border-blue-200" or similar)
so the Active Badge is clearly different from the Completed Badge.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

CSS will be fixed in another PR

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@carddev81 Understood! Would you like me to open a follow-up GitHub issue to track the badge styling fix so it doesn't get lost?

Copy link
Copy Markdown
Member

@CK-7vn CK-7vn left a comment

Choose a reason for hiding this comment

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

Just one tiny thing, that's it.

!hasAttendance &&
!isCancelled &&
!isRescheduledFrom &&
!isCancelledReschedule;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we need && !isRescheduledTo here, but thats it my friend!

@carddev81 carddev81 merged commit 781e356 into CK-7vn/total-refactor May 13, 2026
8 of 9 checks passed
@carddev81 carddev81 deleted the carddev81/refactorschedulepopouts branch May 13, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants