File size: 1,917 Bytes
9fed9f2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
import React, { useState, useEffect } from 'react';
import './App.css';
import Header from './components/Header';
import Footer from './components/Footer';
import TextSelector from './components/TextSelector';
import GeminiChat from './components/GeminiChat';
interface SelectedWord {
word: string;
}
function App() {
const [selectedWords, setSelectedWords] = useState<SelectedWord[]>([]);
const [geminiInput, setGeminiInput] = useState('');
const selectedWordsText = selectedWords.map(w => w.word).join(', ');
const GEMINI_API_KEY = process.env.REACT_APP_GEMINI_API_KEY || '';
useEffect(() => {
if (!GEMINI_API_KEY) {
console.error('Gemini API key not found');
}
}, [GEMINI_API_KEY]);
const handleGenerateWithAI = () => {
if (!selectedWordsText) {
alert('Please select some words first');
return;
}
if (!GEMINI_API_KEY) {
alert('API key not configured. Please check the setup.');
return;
}
const prompt = `Please write the English and their three Hindi meaning side by side for these words:- ${selectedWordsText}`;
setGeminiInput(prompt);
};
return (
<div className="app-wrapper">
<Header />
<main className="app-container">
<div className="main-section">
<TextSelector onWordSelect={setSelectedWords} />
</div>
<div className="comma-separated-section">
<h2>Selected Words</h2>
<div className="selected-words-text">
{selectedWordsText || 'No words selected'}
</div>
<button
onClick={handleGenerateWithAI}
className="generate-ai-button"
disabled={!selectedWordsText}
>
Generate Excel File
</button>
</div>
<GeminiChat apiKey={GEMINI_API_KEY} initialInput={geminiInput} />
</main>
<Footer />
</div>
);
}
export default App;
|