refactor: centralize feature API calls#297
Conversation
- Move cohorts, dashboard, search and trainee-profile HTTP calls into feature api/api.ts modules - Update React Query hooks to consume typed API helpers - Extract shared search response and trainee save request types Refs: HackYourFuture#287
There was a problem hiding this comment.
Pull request overview
This PR implements issue #287 by centralizing previously inline HTTP requests into feature-scoped api/api.ts modules and updating React Query hooks to call these typed API helpers.
Changes:
- Added per-feature
api/api.tsmodules for cohorts, dashboard, search, and trainee-profile subfeatures (personal info, interactions, tests, strikes). - Updated React Query hooks to use the new API helper functions instead of inline
axioscalls. - Extracted shared request/response types (e.g.,
SearchResultResponse,SaveTraineeRequestData) into dedicated type definitions.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| client/src/features/trainee-profile/personal-info/data/useTraineeInfoData.tsx | Refactors hooks to call getTraineeInfo/saveTraineeInfo and imports shared request type. |
| client/src/features/trainee-profile/personal-info/api/types.ts | Introduces SaveTraineeRequestData type for trainee profile saves. |
| client/src/features/trainee-profile/personal-info/api/api.ts | Adds typed API helpers for trainee info fetch/save. |
| client/src/features/trainee-profile/interactions/data/interaction-queries.ts | Updates interaction hooks to use centralized API helpers. |
| client/src/features/trainee-profile/interactions/api/api.ts | Adds interaction API helper functions and error handling. |
| client/src/features/trainee-profile/education/tests/data/test-queries.ts | Updates test hooks to use centralized API helpers. |
| client/src/features/trainee-profile/education/tests/api/api.ts | Adds tests API helper functions and error handling. |
| client/src/features/trainee-profile/education/strikes/data/strike-queries.ts | Updates strike hooks to use centralized API helpers. |
| client/src/features/trainee-profile/education/strikes/api/api.ts | Adds strikes API helper functions and error handling. |
| client/src/features/search/data/queries.ts | Refactors search query hook to use getSearchResults. |
| client/src/features/search/api/api.ts | Adds search API helper function. |
| client/src/features/search/Search.ts | Extracts SearchResultResponse type alongside SearchResult. |
| client/src/features/dashboard/data/useDashboardData.tsx | Refactors dashboard query hook to use getDashboardData. |
| client/src/features/dashboard/api/api.ts | Adds dashboard API helper function. |
| client/src/features/cohorts/data/useCohortsData.tsx | Refactors cohorts query hook to use getCohorts. |
| client/src/features/cohorts/api/api.ts | Adds cohorts API helper function. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
zalexa19
left a comment
There was a problem hiding this comment.
Dear Hadely,
The changes look good!
Thank you for your contribution :)
stasel
left a comment
There was a problem hiding this comment.
Looks good. Can you please resolve all the comments? I will merge the PR after everything is resolved
@stasel , I've resolved all the comments. |
|
Thank you for your contribution |
* refactor: centralize feature API calls - Move cohorts, dashboard, search and trainee-profile HTTP calls into feature api/api.ts modules - Update React Query hooks to consume typed API helpers - Extract shared search response and trainee save request types Refs: HackYourFuture#287 * Improved error handling * Removed try/catch to preserve 401 redirect functionality * improved parameter handling * refactor: streamline API response handling in trainee info functions * fixed params for axios
Refs: #287