Ramon wchm api v2#291
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the WCHM (“Who Can Help Me”) WordPress block to use the new /v2/... API endpoints so it can return correct contact data from the non-deprecated data warehouse tables, and expands the UI to show separate RA contact types.
Changes:
- Switch department/officer/RA lookups to the new
/v2/*endpoints and display Pre-Award, Post-Award, and After-the-Fact contacts separately. - Update the block’s base API path wiring (editor + saved markup) and regenerate built
build/wchm/*bundles. - Update generated asset dependency lists for the updated bundles.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| src/wchm/save.js | Sets the base API path in saved block markup (used by frontend rendering). |
| src/wchm/edit.js | Sets the base API path for editor preview rendering. |
| src/wchm/components/autoComplete.js | Moves fetches to v2 endpoints and renders new contact sections. |
| build/wchm/index.js | Regenerated editor bundle containing the updated API logic and base URL wiring. |
| build/wchm/index.asset.php | Regenerated editor asset manifest. |
| build/wchm/frontend.js | Regenerated frontend bundle containing the updated API logic. |
| build/wchm/frontend.asset.php | Regenerated frontend asset manifest. |
Comments suppressed due to low confidence (1)
src/wchm/components/autoComplete.js:23
- The Azure APIM subscription key is embedded directly in client-side JavaScript. This value will be publicly visible to anyone loading the page (and in the built assets), which usually defeats the purpose of an API key and can allow quota abuse. Consider moving these calls behind a server-side proxy (WordPress endpoint) or injecting a short-lived token at runtime instead of hard-coding the key in the bundle.
headers: {
"Content-Type": "application/json",
"Ocp-Apim-Subscription-Key": "8dd787c43de54148bf5e10686b6b6e20",
},
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (selectedItemId) { | ||
| try { | ||
| const response = await fetch( | ||
| `${baseApiPath}officer/${selectedItemId}`, | ||
| `${baseApiPath}v2/officers/${selectedItemId}`, | ||
| { | ||
| method: "GET", | ||
| headers: { |
There was a problem hiding this comment.
The /v2/officers/... integration changes the endpoint, but the processing logic for officerData still filters by item.Officer !== "" (see the filtering immediately after the fetch). If the v2 response uses the new contactFullName/title/userID fields you render later, this filter will likely drop all records and the officer section will appear empty. Update the filtering to align with the v2 schema (or remove it if unnecessary).
There was a problem hiding this comment.
I'll check this, I tested with deptId B1309 and saw officers, but its a good idea to purge unnecessary fields.
| {preAwardRasData.map((contactInfo) => ( | ||
| <div className="mb-4"> | ||
| <h4 className="mb-1">{contactInfo.contactFullName}</h4> | ||
| <p className="mb-1">{contactInfo.title}</p> |
There was a problem hiding this comment.
Elements rendered inside .map(...) are missing a stable key prop (e.g., the <div className="mb-4"> inside preAwardRasData.map). This will trigger React warnings and can cause inefficient or incorrect UI updates when lists change. Provide a unique key (e.g., a contact id or a composite of userID + role).
There was a problem hiding this comment.
Do we need a key? These are not interactive, but we can add a key for console logs if needed....
|
@ramon-west-asu RE: your comments - sounds good... I can take care of those based on your comments if you're busy elsewhere. I had some minor changes to block.json and some other clean up, I will hold off until your latest push, unless you want me to fully take over. |
…ug console.log Agent-Logs-Url: https://github.com/ASU-KE/UnityBlocks/sessions/b58f6537-d64a-4839-89cb-4709c51683e8 Co-authored-by: jkcox <8856538+jkcox@users.noreply.github.com>
jkcox
left a comment
There was a problem hiding this comment.
Merging to catch up branch with latest unityblock features. Will create new branch for requested changes
Add new RA contact types by fetching from these new endpoints
/v2/pre-award-ras
/v2/post-award-ras
/v2/after-the-fact-ras
/v2/officers
/v2/departments
This will also resolve issues with old data / wrong contacts due to deprecated database tables in the Data Warehouse. v2 endpoints query the correct database tables.