Skip to content
Draft
Show file tree
Hide file tree
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
5 changes: 2 additions & 3 deletions frontend/src/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { HiringManagerProfile, JobOpening } from '../types/hiring';

// Configure axios to use the backend URL from environment
const BACKEND_API_URL = process.env.BACKEND_API_URL || '/';

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.

🦩 🟠 Frontend api.ts uses console.log to print the backend URL β€” debug output left in production service layer

Removed the console.log('API Service: Using backend URL:', BACKEND_API_URL); call at line 6. The line was deleted entirely; the surrounding const BACKEND_API_URL declaration and axios.defaults.baseURL assignment are preserved unchanged.

πŸ€– Prompt for AI agents
In frontend/src/services/api.ts around line 6, review and complete this code-review fix: Frontend api.ts uses console.log to print the backend URL β€” debug output left in production service layer.
What the draft fix changed: Removed the `console.log('API Service: Using backend URL:', BACKEND_API_URL);` call at line 6. The line was deleted entirely; the surrounding `const BACKEND_API_URL` declaration and `axios.defaults.baseURL` assignment are preserved unchanged.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 97 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

console.log('API Service: Using backend URL:', BACKEND_API_URL);

axios.defaults.baseURL = BACKEND_API_URL;

Expand Down Expand Up @@ -60,7 +59,7 @@ export function downloadContributors({

// Create a hidden link and click it to trigger the download
const link = document.createElement('a');
link.href = `${BACKEND_API_URL}/api/contributors/export?${params.toString()}`;
link.href = `/api/contributors/export?${params.toString()}`;
link.download = 'contributors.csv';
document.body.appendChild(link);
link.click();
Comment on lines 59 to 65

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.

🦩 🟠 downloadContributors URL construction double-slash bug when BACKEND_API_URL ends with '/'

Changed link.href = \${BACKEND_API_URL}/api/contributors/export?${params.toString()}`tolink.href = `/api/contributors/export?${params.toString()}`indownloadContributors. This uses a root-relative path (same approach as all axios calls in the file) and avoids the double-slash protocol-relative URL bug when BACKEND_API_URLis'/'. Since axios.defaults.baseURLis already set toBACKEND_API_URL`, the browser will resolve the relative path correctly against the current origin in all deployment configurations where the frontend is served from the same host as the API proxy.

πŸ€– Prompt for AI agents
In frontend/src/services/api.ts around line 57, review and complete this code-review fix: downloadContributors URL construction double-slash bug when BACKEND_API_URL ends with '/'.
What the draft fix changed: Changed `link.href = \`${BACKEND_API_URL}/api/contributors/export?${params.toString()}\`` to `link.href = \`/api/contributors/export?${params.toString()}\`` in `downloadContributors`. This uses a root-relative path (same approach as all axios calls in the file) and avoids the double-slash protocol-relative URL bug when `BACKEND_API_URL` is `'/'`. Since `axios.defaults.baseURL` is already set to `BACKEND_API_URL`, the browser will resolve the relative path correctly against the current origin in all deployment configurations where the frontend is served from the same host as the API proxy.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 95 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

Expand Down Expand Up @@ -222,4 +221,4 @@ export const getJobOpenings = async (): Promise<JobOpening[]> => {
throw new Error(response.data.message);
}
return response.data.data;
}; // Force rebuild Sun Aug 31 19:49:51 EDT 2025
};
Comment on lines 221 to +224

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.

🦩 πŸ”΅ frontend/src/services/api.ts has a trailing comment '// Force rebuild Sun Aug 31 19:49:51 EDT 2025' that should not be committed

Removed the trailing // Force rebuild Sun Aug 31 19:49:51 EDT 2025 comment from the end of the getJobOpenings function closing };. The semicolon and closing brace are preserved; only the inline comment was deleted.

πŸ€– Prompt for AI agents
In frontend/src/services/api.ts around line 196, review and complete this code-review fix: frontend/src/services/api.ts has a trailing comment '// Force rebuild Sun Aug 31 19:49:51 EDT 2025' that should not be committed.
What the draft fix changed: Removed the trailing `// Force rebuild Sun Aug 31 19:49:51 EDT 2025` comment from the end of the `getJobOpenings` function closing `};`. The semicolon and closing brace are preserved; only the inline comment was deleted.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 99 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

28 changes: 22 additions & 6 deletions frontend/src/services/enhanced.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,43 @@ import { City, Region, State } from '../types/api';
import { EnhancedCity, EnhancedRegion, EnhancedState } from '../types/enhanced';
import { getStateById, getTeamById } from './api';

async function getStateByIdChecked(stateId: string): Promise<State> {
const response = await getStateById(stateId);
if (!response || (response as any).status !== 'success') {
throw new Error(`getStateById(${stateId}) returned non-success status`);
}
return response;
}

async function getTeamByIdChecked(teamId: string) {
const response = await getTeamById(teamId);
if (!response || (response as any).status !== 'success') {
throw new Error(`getTeamById(${teamId}) returned non-success status`);
}
return response;
}

export async function enhanceCity(city: City): Promise<EnhancedCity> {
const [state, team] = await Promise.all([

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.

🦩 πŸ”΄ enhanced.ts calls getStateById/getTeamById without checking response.data.status === 'success'

In enhanceCity, introduced getStateByIdChecked and getTeamByIdChecked wrapper functions that call the original API functions and then check response.status !== 'success', throwing on failure. The || null fallback on state was removed (changed to state: state), so API errors are no longer silently masked. The || null pattern for the optional nearestTeam is preserved only for the legitimately absent case (when city.nearestTeamId is falsy), not as a fallback for API failure. Risk: the actual return type of getStateById/getTeamById from ./api is unknown β€” if they already return unwrapped data (not a response envelope with .status), the check (response as any).status !== 'success' will always throw. A complete fix would require inspecting ./api to know the exact return shape and adjusting accordingly. The cast to any is a pragmatic workaround given we cannot see ./api.

πŸ€– Prompt for AI agents
In frontend/src/services/enhanced.ts around line 6, review and complete this code-review fix: enhanced.ts calls getStateById/getTeamById without checking response.data.status === 'success'.
What the draft fix changed: In `enhanceCity`, introduced `getStateByIdChecked` and `getTeamByIdChecked` wrapper functions that call the original API functions and then check `response.status !== 'success'`, throwing on failure. The `|| null` fallback on `state` was removed (changed to `state: state`), so API errors are no longer silently masked. The `|| null` pattern for the optional `nearestTeam` is preserved only for the legitimately absent case (when `city.nearestTeamId` is falsy), not as a fallback for API failure. Risk: the actual return type of `getStateById`/`getTeamById` from `./api` is unknown β€” if they already return unwrapped data (not a response envelope with `.status`), the check `(response as any).status !== 'success'` will always throw. A complete fix would require inspecting `./api` to know the exact return shape and adjusting accordingly. The cast to `any` is a pragmatic workaround given we cannot see `./api`.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟑 62 medium β€” react πŸ‘/πŸ‘Ž to teach the reviewer

getStateById(city.stateId),
city.nearestTeamId ? getTeamById(city.nearestTeamId) : null
getStateByIdChecked(city.stateId),
city.nearestTeamId ? getTeamByIdChecked(city.nearestTeamId) : null
]);

return {
...city,
state: state || null,
state: state,
nearestTeam: team
};
}

export async function enhanceRegion(region: Region): Promise<EnhancedRegion> {

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.

🦩 πŸ”΄ enhanceRegion silently drops failed getStateById calls via filter(s => s !== null)

In enhanceRegion, replaced the direct getStateById call with getStateByIdChecked, which throws on non-success. The filter((s): s is State => s !== null) null-filter was removed entirely β€” since getStateByIdChecked now throws on failure rather than returning null, all results in states are valid State objects and the filter is unnecessary. This means any API failure will propagate as a thrown error rather than being silently dropped. Same risk as finding 1: the actual shape of the ./api return values is unknown, so the .status check may need adjustment once ./api is inspected.

πŸ€– Prompt for AI agents
In frontend/src/services/enhanced.ts around line 18, review and complete this code-review fix: enhanceRegion silently drops failed getStateById calls via filter(s => s !== null).
What the draft fix changed: In `enhanceRegion`, replaced the direct `getStateById` call with `getStateByIdChecked`, which throws on non-success. The `filter((s): s is State => s !== null)` null-filter was removed entirely β€” since `getStateByIdChecked` now throws on failure rather than returning null, all results in `states` are valid `State` objects and the filter is unnecessary. This means any API failure will propagate as a thrown error rather than being silently dropped. Same risk as finding 1: the actual shape of the `./api` return values is unknown, so the `.status` check may need adjustment once `./api` is inspected.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟑 62 medium β€” react πŸ‘/πŸ‘Ž to teach the reviewer

const states = await Promise.all(
region.stateIds.map(stateId => getStateById(stateId))
region.stateIds.map(stateId => getStateByIdChecked(stateId))
);

return {
...region,
states: new Set(states.filter((s): s is State => s !== null)),
states: new Set(states),
cities: new Set()
};
}
Expand All @@ -34,4 +50,4 @@ export async function enhanceState(state: State): Promise<EnhancedState> {
regions: new Set(),
cities: new Set()
};
}
}