Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ export default function EventsPage() {

if (teams.length > 0) {
fetchEvents();
} else if (!authLoading) {
// Auth is ready but the coach has no teams (e.g. a new showcase org):
// clear the skeleton and fall through to the honest empty state instead
// of spinning on `loading` forever.
setEvents([]);
setLoading(false);
Comment on lines +174 to +179

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

1. No memory doc update 📘 Rule violation ⚙ Maintainability

This change alters user-visible behavior by clearing the Events loading skeleton when `teams.length
=== 0, but there is no corresponding update to memory/features/*` docs and no explicit comment
explaining why a doc update is unnecessary.
Agent Prompt
## Issue description
A user-visible behavior change was made (coaches with zero teams now exit loading and see the empty state), but the `memory/features/*` documentation was not updated and there is no explicit in-code rationale for omitting a doc update.

## Issue Context
PR adds a new branch that sets `events` to `[]` and `loading` to `false` when auth is ready and `teams.length === 0`, changing what users see on the Events page.

## Fix Focus Areas
- src/app/baseball/(dashboard)/dashboard/events/EventsClient.tsx[174-179]
- memory/features/calendar-events.md[91-98]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

}
Comment on lines +174 to 180

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

2. Teams-loading misread as empty 🐞 Bug ≡ Correctness

The new else if (!authLoading) branch sets loading false whenever teams.length === 0, even if
teams are still being fetched, so coaches with teams can briefly see the “No upcoming events” empty
state before teams arrive. This occurs because useTeams() loads teams asynchronously and exposes
isLoading, but EventsClient doesn’t gate the empty-teams path on it.
Agent Prompt
### Issue description
`EventsClient` treats `teams.length === 0` as a final state once `authLoading` is false, but `useTeams()` begins with `teams=[]` and fetches teams asynchronously. This can show the empty state briefly for coaches who actually have teams.

### Issue Context
`useTeams()` already exposes `isLoading`, and other pages (e.g. OrgDashboard) use it to avoid falling through to an empty state before team data is loaded.

### Fix Focus Areas
- src/app/baseball/(dashboard)/dashboard/events/EventsClient.tsx[102-181]

### Suggested change
1. Read `isLoading` from `useTeams()`:
   - `const { teams, isLoading: teamsLoading } = useTeams();`
2. Update the effect to avoid the empty-teams branch while teams are still loading:
   - If `teamsLoading` is true, do nothing (keep skeleton / loading state).
   - Only when `!teamsLoading && !authLoading && teams.length === 0`, clear events and set `loading` false.
3. Add `teamsLoading` to the effect dependency array.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +174 to 180

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Informational

3. Stale fetcherror on no-teams 🐞 Bug ☼ Reliability

When teams.length === 0, the new branch sets events and loading but does not reset
fetchError, so an old fetch error banner can persist even though the UI is now in an expected
no-teams empty state. This can happen if a fetch previously failed and teams later becomes empty in
the same session.
Agent Prompt
### Issue description
The `teams.length === 0` path sets `events=[]` and `loading=false` but leaves any previous `fetchError` intact, so the error banner can remain visible in an expected empty state.

### Issue Context
`fetchError` is rendered regardless of `loading`, and is only cleared inside `fetchEvents()`.

### Fix Focus Areas
- src/app/baseball/(dashboard)/dashboard/events/EventsClient.tsx[133-181]
- src/app/baseball/(dashboard)/dashboard/events/EventsClient.tsx[371-399]

### Suggested change
In the `teams.length === 0` branch (and/or alongside the `setEvents([])` call), add `setFetchError(null)` so the UI doesn’t retain a stale error when no fetch is being performed.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

}, [authLoading, coach?.id, teams]);

Expand Down
Loading