[30a88f42] feat: Centralize API key handling and fix product enrichment\n\n- Centralized GEMINI_API_KEY loading from project root .env file.\n- Corrected product enrichment: added /enrich-product endpoint in Node.js, implemented mode in Python backend, and updated frontend to use new API for product analysis.\n- Fixed to pass product data correctly for enrichment.\n- Updated documentation ().

This commit is contained in:
2026-02-17 07:14:51 +00:00
parent 7be5d47604
commit d13d3a2f36
6 changed files with 94 additions and 13 deletions

View File

@@ -57,6 +57,8 @@ const App: React.FC = () => {
const [generationStep, setGenerationStep] = useState<number>(0); // 0: idle, 1-6: step X is complete
const [selectedIndustry, setSelectedIndustry] = useState<string>('');
const [batchStatus, setBatchStatus] = useState<{ current: number; total: number; industry: string } | null>(null);
const [isEnriching, setIsEnriching] = useState<boolean>(false);
// Project Persistence
const [projectId, setProjectId] = useState<string | null>(null);
@@ -69,6 +71,43 @@ const App: React.FC = () => {
const STEP_TITLES = t.stepTitles;
const STEP_KEYS: (keyof AnalysisData)[] = ['offer', 'targetGroups', 'personas', 'painPoints', 'gains', 'messages', 'customerJourney'];
const handleEnrichRow = async (productName: string, productUrl?: string) => {
setIsEnriching(true);
setError(null);
try {
const response = await fetch(`${API_BASE_URL}/enrich-product`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
productName,
productUrl,
language: inputData.language
}),
});
if (!response.ok) {
const errorData = await response.json();
throw new Error(errorData.details || `HTTP error! status: ${response.status}`);
}
const newRow = await response.json();
setAnalysisData(prev => {
const currentOffer = prev.offer || { headers: [], rows: [], summary: [] };
return {
...prev,
offer: {
...currentOffer,
rows: [...currentOffer.rows, newRow]
}
};
});
} catch (e) {
console.error(e);
setError(e instanceof Error ? `Fehler beim Anreichern: ${e.message}` : 'Unbekannter Fehler beim Anreichern.');
} finally {
setIsEnriching(false);
}
};
// --- AUTO-SAVE EFFECT ---
useEffect(() => {
if (generationStep === 0 || !inputData.companyUrl) return;
@@ -507,9 +546,10 @@ const App: React.FC = () => {
const canAdd = ['offer', 'targetGroups'].includes(stepKey);
const canDelete = ['offer', 'targetGroups', 'personas'].includes(stepKey);
const handleManualAdd = (newRow: string[]) => {
const handleManualAdd = () => {
const newEmptyRow = Array(step.headers.length).fill('');
const currentRows = step.rows || [];
handleDataChange(stepKey, { ...step, rows: [...currentRows, newRow] });
handleDataChange(stepKey, { ...step, rows: [...currentRows, newEmptyRow] });
};
return (
@@ -521,8 +561,8 @@ const App: React.FC = () => {
rows={step.rows}
onDataChange={(newRows) => handleDataChange(stepKey, { ...step, rows: newRows })}
canAddRows={canAdd}
onEnrichRow={canAdd ? handleManualAdd : undefined}
isEnriching={false}
onEnrichRow={stepKey === 'offer' ? handleEnrichRow : handleManualAdd}
isEnriching={isEnriching}
canDeleteRows={canDelete}
onRestart={() => handleStepRestart(stepKey)}
t={t}