feat: Documentation and Tool Config Update
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -15,6 +15,6 @@ View your app in AI Studio: https://ai.studio/apps/drive/1ZPnGbhaEnyhIyqs2rYhcPX
|
||||
|
||||
1. Install dependencies:
|
||||
`npm install`
|
||||
2. Set the `GEMINI_API_KEY` in [.env.local](.env.local) to your Gemini API key
|
||||
2. Set the `GEMINI_API_KEY` in the central `.env` file in the project's root directory.
|
||||
3. Run the app:
|
||||
`npm run dev`
|
||||
|
||||
@@ -12,7 +12,7 @@ interface StepDisplayProps {
|
||||
onDataChange: (newRows: string[][]) => void;
|
||||
canAddRows?: boolean;
|
||||
canDeleteRows?: boolean;
|
||||
onEnrichRow?: (productName: string, productUrl?: string) => Promise<void>;
|
||||
onEnrichRow?: (productName: string, productUrl?: string) => void;
|
||||
isEnriching?: boolean;
|
||||
onRestart?: () => void;
|
||||
t: typeof translations.de;
|
||||
@@ -106,12 +106,7 @@ export const StepDisplay: React.FC<StepDisplayProps> = ({ title, summary, header
|
||||
};
|
||||
|
||||
const handleAddRowClick = () => {
|
||||
if (onEnrichRow) {
|
||||
setIsAddingRow(true);
|
||||
} else {
|
||||
const newEmptyRow = Array(headers.length).fill('');
|
||||
onDataChange([...rows, newEmptyRow]);
|
||||
}
|
||||
setIsAddingRow(true);
|
||||
};
|
||||
|
||||
const handleConfirmAddRow = () => {
|
||||
|
||||
@@ -89,6 +89,15 @@ router.post('/next-step', (req, res) => {
|
||||
} catch (e) { res.status(500).json({ error: e.message }); }
|
||||
});
|
||||
|
||||
router.post('/enrich-product', (req, res) => {
|
||||
const { productName, productUrl, language } = req.body;
|
||||
const args = [SCRIPT_PATH, '--mode', 'enrich_product', '--product_name', productName, '--language', language];
|
||||
if (productUrl) {
|
||||
args.push('--product_url', productUrl);
|
||||
}
|
||||
runPythonScript(args, res);
|
||||
});
|
||||
|
||||
router.get('/projects', (req, res) => runPythonScript([dbScript, 'list'], res));
|
||||
router.get('/projects/:id', (req, res) => runPythonScript([dbScript, 'load', req.params.id], res));
|
||||
router.delete('/projects/:id', (req, res) => runPythonScript([dbScript, 'delete', req.params.id], res));
|
||||
|
||||
@@ -3,7 +3,7 @@ import { defineConfig, loadEnv } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
|
||||
export default defineConfig(({ mode }) => {
|
||||
const env = loadEnv(mode, '.', '');
|
||||
const env = loadEnv(mode, '../', '');
|
||||
return {
|
||||
base: '/b2b/',
|
||||
server: {
|
||||
|
||||
Reference in New Issue
Block a user