diff --git a/src/components/PricingView.tsx b/src/components/PricingView.tsx index 4061ba7..140057c 100644 --- a/src/components/PricingView.tsx +++ b/src/components/PricingView.tsx @@ -1289,7 +1289,7 @@ export function PricingView({ data, headers, onSaveRow, onCaptureState, onEdit, const colKey = `prc_${col.index}`; const width = columnWidths[colKey] ?? 100; return ( - handleSort(col.index)}> @@ -1332,7 +1332,7 @@ export function PricingView({ data, headers, onSaveRow, onCaptureState, onEdit, handleSort('unitsOuter')}>
@@ -1458,7 +1458,7 @@ export function PricingView({ data, headers, onSaveRow, onCaptureState, onEdit, const colKey = `con_${col.index}`; const width = columnWidths[colKey] ?? 110; return ( - handleSort(col.index)}> @@ -1697,7 +1697,7 @@ export function PricingView({ data, headers, onSaveRow, onCaptureState, onEdit, const colKey = `prc_${col.index}`; return ( - + {isEditing ? (
{ const colKey = `con_${col.index}`; return ( - + {unitBadge(row[col.index], col.name)} ); diff --git a/src/services/gemini.ts b/src/services/gemini.ts index fa563da..bea3f3b 100644 --- a/src/services/gemini.ts +++ b/src/services/gemini.ts @@ -1,16 +1,19 @@ export async function generateGemini(prompt: string, systemPrompt: string): Promise { // Try all possible ways to get the API key + let keySource = 'none'; const apiKey = - (window as any).GEMINI_API_KEY || - localStorage.getItem('GEMINI_API_KEY') || - import.meta.env.VITE_GEMINI_API_KEY || - import.meta.env.GEMINI_API_KEY || - (process.env as any).GEMINI_API_KEY || + (window as any).GEMINI_API_KEY ? (keySource = 'window', (window as any).GEMINI_API_KEY) : + localStorage.getItem('GEMINI_API_KEY') ? (keySource = 'localStorage', localStorage.getItem('GEMINI_API_KEY')) : + import.meta.env.VITE_GEMINI_API_KEY ? (keySource = 'import.meta.env.VITE_GEMINI_API_KEY', import.meta.env.VITE_GEMINI_API_KEY) : + import.meta.env.GEMINI_API_KEY ? (keySource = 'import.meta.env.GEMINI_API_KEY', import.meta.env.GEMINI_API_KEY) : + (process.env as any).GEMINI_API_KEY ? (keySource = 'process.env', (process.env as any).GEMINI_API_KEY) : ''; + console.log(`[Gemini] API Key source: ${keySource}`); + if (!apiKey) { - console.error('No Gemini API Key found in env or storage'); - throw new Error('Gemini API Key not found. Please set VITE_GEMINI_API_KEY in .env or GEMINI_API_KEY in localStorage.'); + console.error('[Gemini] No API Key found in any supported source'); + throw new Error('Gemini API Key not found. Please set VITE_GEMINI_API_KEY in .env or your environment variables.'); } // Model fallback list - using current stable and experimental versions