Skip to content

[MPDX-9914] - Wire the MPD Goal Admin coach picker to the API - #2022

Merged
wjames111 merged 9 commits into
mainfrom
MPDX-9914
Sep 4, 2026
Merged

[MPDX-9914] - Wire the MPD Goal Admin coach picker to the API#2022
wjames111 merged 9 commits into
mainfrom
MPDX-9914

Conversation

@wjames111

Copy link
Copy Markdown
Contributor

Description

Wires the MPD Goal Admin coach picker to the real API, replacing the mock coach list and the local-state-only assignment.

  • New AssignCoach.graphql: NewStaffCohortAssignableCoaches query and AssignCoachToNewStaffCohortAttendee mutation. The mutation selects newStaffCohortAttendees { id coach { ... } } so the payload normalizes over the cached attendee rows.
  • MpdGoalAdminContext runs the coaches query for the selected cohort and exposes assignableCoaches. assignCoach(rowIds, coachId) is now a real mutation, modelled on runAndSendNewStaffCohort from MPDX-9912 including refetchQueries + awaitRefetchQueries. coachOverrides is gone.
  • Both TODO(MPDX-9914) comments in GoalsTable and GoalsTableToolbar are resolved, and mockData.ts is deleted.
  • AssignCoachModal gains a loading prop, an explanatory message when a cohort genuinely has no eligible coaches, and an inline error that keeps the modal open with the selection intact when assignment fails.

Stacked on CruGlobal/mpdx_api#3590, which adds both operations. Coach eligibility is sourced from OneApp's mpd_coach role rather than typed in — that PR has the reasoning, but briefly: staging has ~190 login emails mapping to two or more distinct people, so identifying a coach by email either picks an arbitrary person or blocks those coaches outright.

Jira: MPDX-9914 (frontend half of MPDX-9685).

CI will be red until the API reaches staging

src/graphql is gitignored (.gitignore:42), so CI regenerates the schema from api.stage.mpdx.org, which does not yet serve these fields. GqlMockedProvider builds its mock schema from that file, so the MpdGoalAdmin tests will fail on CI until mpdx_api#3590 is merged and deployed to staging. They pass locally against the API branch's SDL. Please don't read that failure as a defect in this PR — but equally, don't merge this before the API is on staging.

Testing

Requires mpdx_api#3590 deployed to staging, and an account with mpd_supervisor_admin.

  • Go to the MPD Goal Admin table and select a training cohort
  • Open Assign Coach from a row's menu, or select several rows and use the bulk action
  • Check the coach dropdown is populated from the API rather than the old hardcoded names (Amy Wilson, Bea Christians, …)
  • Assign a coach and check the Coach column updates for every selected row
  • Pick a cohort whose ministries have no mpd_coach holders in OneApp and check the modal explains that rather than showing an empty dropdown

To exercise it before the API is on staging, run codegen against the API branch:

API_URL=/path/to/mpdx_api/app/graphql/schema.graphql yarn gql

Checklist:

  • I have given my PR a title with the format "MPDX-(JIRA#) (summary sentence max 80 chars)"
  • I have applied the appropriate labels (Add the label "Preview" to automatically create a preview environment)
  • I have run the Claude Code /quality:agent-review command locally and fixed any relevant suggestions
  • I have requested a review from another person on the project
  • I have tested my changes in preview or in staging
  • I have cleaned up my commit history

@wjames111 wjames111 self-assigned this Sep 4, 2026
@wjames111 wjames111 added On Staging Will be merged to the staging branch by Github Actions Preview Environment Add this label to create an Amplify Preview labels Sep 4, 2026
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Preview branch generated at https://MPDX-9914.d3dytjb8adxkk5.amplifyapp.com

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Bundle sizes [mpdx-react]

Compared against 914884c

No significant changes found

@wjames111 wjames111 left a comment

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.

Multi-Agent Review, 6 specialist agents plus dependency impact

Verdict: BLOCKERS FOUND. 2 blocking, 4 important. Agents were selected by this repo's own .claude/rules/code-review.md triggers: Architecture, Testing, Standards, Data Integrity, UX, and the Financial Reporting domain agent. Security did not trigger (no pages/api/**, Apollo link/client, next.config, env, or .claude/** changes).

The two blockers

1. Deploy ordering, and it is stricter than it looks. CI codegens against production, not staging: ci.yml:21 resolves API_URL to https://api.mpdx.org/graphql unless the Staging API label is present, and ci.yml:196-199 blocks merge while that label is applied. So every red check on this PR has one root cause, namely that yarn gql cannot resolve newStaffCohortAssignableCoaches or coachId, and it clears only when the API reaches production. Current state: merged to mpdx_api master, not yet on staging, not in production. No change to this PR fixes it. Please do not triage the 12 red chunks as broken work.

2. A test that cannot fail for what its name promises. See the inline comment on GoalsTableToolbar.test.tsx:341. Proven by deliberately breaking the source and observing a green suite.

Note on the risk score

The rules file scores this 10/10 CRITICAL, but that is driven almost entirely by file count, seven ordinary component files at +1 each, rather than by anything dangerous. There is no auth, no Apollo cache config, no API route and no dependency change here. Read the reviewer recommendation as experienced, not senior maintainer.

Dismissed as a false positive

as unknown as on the throwing test mocks was flagged at 5.0 by one agent and explicitly cleared by another, which checked roughly 15 sibling sites including two pre-existing in this same file. Established idiom, not a violation, so it is not reported.

Verified clean

Localization is fully compliant: all three new strings go through t(), keys are static, no interpolation inside a key, and the translation.json diff is three pure single-line additions with no yarn extract spray. No any, no @ts-ignore, no non-null assertions, no fireEvent, no debug output. The mockData.ts deletion is safe, since it had exactly one export and zero remaining importers, and it was the one mock module imported by production code, so removing it is a net improvement. The cross-repo contract matches the API branch field for field. newStaffCohortAssignableCoaches is genuinely unpaginated, so there is no silent truncation. The Financial Reporting agent confirmed its path trigger was a false positive and that attendeeToRow's goal fields are byte-identical.


Findings on related files (not in this PR)

[Medium] src/components/HrTools/CLAUDE.md:175 still reads "only mockData.ts's mockCoaches is still stubbed, pending MPDX-9914". This PR deletes that file and closes that ticket. Flagged by four agents. That file auto-loads for anyone touching HrTools/, so leaving it stale actively misinforms the next reader. One-line fix, but it is not in this PR's diff so it cannot be posted as a line comment.


Findings below severity 7.0 can be dismissed with /dismiss: <reason> as a reply.

Comment thread src/components/HrTools/MpdGoalAdmin/MpdGoalAdminContext.tsx Outdated
Comment thread src/components/HrTools/MpdGoalAdmin/mpdGoalAdminHelpers.ts Outdated
Comment thread src/components/HrTools/MpdGoalAdmin/AssignCoachModal/AssignCoachModal.tsx Outdated
Comment thread src/components/HrTools/MpdGoalAdmin/MpdGoalAdminContext.tsx
Comment thread src/components/HrTools/MpdGoalAdmin/MpdGoalAdminContext.tsx Outdated
Comment thread src/components/HrTools/MpdGoalAdmin/mpdGoalAdminHelpers.ts Outdated
Comment thread src/components/HrTools/MpdGoalAdmin/MpdGoalAdminContext.test.tsx Outdated
Comment thread src/components/HrTools/MpdGoalAdmin/AssignCoachModal/AssignCoachModal.tsx Outdated
@wjames111
wjames111 requested a review from canac September 4, 2026 15:59
@wjames111

Copy link
Copy Markdown
Contributor Author

@canac the updates to 9685 didn't get into staging, so persisting the coach assignment won't work. The code should be right on production though. Going to go back and update mpdx_api staging.

@canac

canac commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

It looks like we need to deduplicate the coaches list on the backend.

Screenshot 2026-09-04 at 1 10 55 PM

@canac canac 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.

This looks good! It's awesome to see this coming together!

It looks like the coaching list needs to be deduplicated, but I think that should be a backend change.

Comment thread src/components/HrTools/MpdGoalAdmin/AssignCoach.graphql Outdated
Comment thread src/components/HrTools/MpdGoalAdmin/MpdGoalAdminContext.tsx Outdated
@wjames111
wjames111 merged commit 42130df into main Sep 4, 2026
23 of 24 checks passed
@wjames111
wjames111 deleted the MPDX-9914 branch September 4, 2026 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

On Staging Will be merged to the staging branch by Github Actions Preview Environment Add this label to create an Amplify Preview

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants