diff --git a/frontend/src/services/api.ts b/frontend/src/services/api.ts index abe324a..f1bf33d 100644 --- a/frontend/src/services/api.ts +++ b/frontend/src/services/api.ts @@ -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 || '/'; -console.log('API Service: Using backend URL:', BACKEND_API_URL); axios.defaults.baseURL = BACKEND_API_URL; @@ -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(); @@ -222,4 +221,4 @@ export const getJobOpenings = async (): Promise => { throw new Error(response.data.message); } return response.data.data; -}; // Force rebuild Sun Aug 31 19:49:51 EDT 2025 +}; diff --git a/frontend/src/services/enhanced.ts b/frontend/src/services/enhanced.ts index 6bee364..6e90e8e 100644 --- a/frontend/src/services/enhanced.ts +++ b/frontend/src/services/enhanced.ts @@ -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 { + 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 { const [state, team] = await Promise.all([ - 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 { 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() }; } @@ -34,4 +50,4 @@ export async function enhanceState(state: State): Promise { regions: new Set(), cities: new Set() }; -} \ No newline at end of file +}