Repository navigation
[Customer Portal][FE][Web] Centralize API Header Logic and Upgrade Oxygen UI to 0.4.0 - #96
Conversation
Update @wso2/oxygen-ui and @wso2/oxygen-ui-icons-react to ^0.4.0 in apps/customer-portal/webapp/package.json to pick up the latest fixes and improvements. This aligns package versions with @wso2/oxygen-ui-charts-react which is already at ^0.4.0.
Regenerate pnpm lock for apps/customer-portal/webapp: bump @wso2/oxygen-ui and @wso2/oxygen-ui-icons-react specifiers/versions to ^0.4.0 / 0.4.0 and update related @wso2/oxygen-ui-charts-react references. The lockfile also drops and cleans up several transitive/obsolete entries (various @mui/x-charts-vendor/@mui/x-charts entries, older d3 packages, internmap v1, bezier-easing, delaunator, robust-predicates, etc.) as part of the dependency resolution changes.
Add addApiHeaders utility in apps/customer-portal/webapp/src/utils/apiUtils.ts to standardize headers for authenticated fetch requests. The function accepts an ID token and returns Content-Type, Accept, Authorization (Bearer), and x-user-id-token headers. File includes the project Apache 2.0 license header and a typed return signature.
Replace duplicated inline fetch header objects with a centralized addApiHeaders(idToken) utility across several customer-portal API hooks. Adds the import for addApiHeaders and updates fetch calls to use it, consolidating header construction (Content-Type, Accept, Authorization, x-user-id-token) and reducing repetition. Affected files: useGetCasesFilters, useGetProjectCases, useGetProjectCasesStats, useGetProjectDetails, useGetProjectStat, useGetProjectSupportStats, useGetProjects, useGetUserDetails.
📝 WalkthroughWalkthroughThis PR upgrades two WSO2 Oxygen UI dependencies to version 0.4.0 and introduces a centralized API header utility function ( Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
61806ca
into
wso2-open-operations:customer-portal-milestone-1
Purpose
This PR focuses on two main improvements: upgrading the Oxygen UI design system to version
0.4.0to leverage latest components and fixes, and centralizing the API header construction logic into a reusable utility function to reduce code duplication and improve maintainability.Goals
@wso2/oxygen-uito version0.4.0.Approach
package.jsonto reference Oxygen UI0.4.0and ran a clean install to verify compatibility.addApiHeadersin the API utility layer. This function accepts anidTokenand returns the standardized header object required by the backend.useGetProjects,useGetProjectDetails,useGetSupportStats, etc.) with calls to the newaddApiHeadersfunction.Code Refactoring Detail
Before:
After:
User stories
Walkthrough
This PR upgrades the project's core UI library and introduces a centralized
addApiHeadersutility. It refactors all existing data-fetching hooks to use this utility, ensuring thatAuthorization,Accept, and customx-user-id-tokenheaders are applied consistently across the application.Changes
package.json@wso2/oxygen-uifrom previous version to0.4.0.src/api/utils.ts(or relevant)addApiHeadersfunction.src/api/useQueryanduseMutationhooks to use the new header utility.src/api/__tests__/utils.test.tsaddApiHeadersto verify correct header mapping.Automation tests
addApiHeaderscorrectly injects theidTokeninto bothAuthorizationandx-user-id-tokenfields.application/json.0.4.0upgrade.Summary by CodeRabbit
Chores
Refactor