Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 0 additions & 71 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"next-themes": "^0.4.6",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-google-recaptcha": "^3.1.0",
"react-router-dom": "^6.28.0",
"tailwind-merge": "^3.2.0"
},
Expand All @@ -53,7 +52,6 @@
"@types/node": "^25.0.3",
"@types/react": "^18.3.18",
"@types/react-dom": "^18.3.5",
"@types/react-google-recaptcha": "^2.1.9",
"@vitejs/plugin-react": "^4.3.4",
"autoprefixer": "^10.4.20",
"eslint": "^9.17.0",
Expand Down
4 changes: 0 additions & 4 deletions frontend/src/api/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ export async function translateFile(request: TranslateRequest): Promise<Translat
formData.append('sheets', request.sheets.join(','));
}

if (request.recaptchaToken) {
formData.append('recaptcha_token', request.recaptchaToken);
}

try {
const response = await fetch(`${API_URL}/translate`, {
method: 'POST',
Expand Down
62 changes: 1 addition & 61 deletions frontend/src/components/features/translate/TranslateForm.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState, useCallback, useEffect, useRef } from 'react';
import { motion, AnimatePresence } from 'framer-motion';
import { Upload, FileSpreadsheet, Sparkles, ArrowRight, Shield, Settings2, MessageSquare, ChevronDown, Grid3X3 } from 'lucide-react';
import { Button, Recaptcha, FloatingFeedbackButton, type RecaptchaRef } from '../../ui';
import { Button, FloatingFeedbackButton } from '../../ui';
import { SheetSelector } from './SheetSelector';
import { ResultDisplay } from './ResultDisplay';
import { ProgressIndicator } from './ProgressIndicator';
Expand All @@ -24,8 +24,6 @@ export function TranslateForm() {
const [estimate, setEstimate] = useState<EstimateResult | null>(null);
const [loadingEstimate, setLoadingEstimate] = useState(false);
const [isDragging, setIsDragging] = useState(false);
const [recaptchaToken, setRecaptchaToken] = useState<string | null>(null);
const recaptchaRef = useRef<RecaptchaRef>(null);
const containerRef = useRef<HTMLDivElement>(null);

const { status, error, filename, progress, translate, downloadResult, reset } = useTranslate();
Expand Down Expand Up @@ -88,11 +86,6 @@ export function TranslateForm() {
if (status !== 'idle') {
reset();
}
// Reset reCAPTCHA when file changes
if (fileInfo !== selectedFile) {
recaptchaRef.current?.reset();
setRecaptchaToken(null);
}
}, [status, reset, selectedFile]);

// Handle drag and drop
Expand Down Expand Up @@ -136,30 +129,10 @@ export function TranslateForm() {
}, [handleFileSelect]);

const isTranslating = status === 'uploading' || status === 'translating';
const recaptchaSiteKey = import.meta.env.VITE_RECAPTCHA_SITE_KEY || '';
// reCAPTCHA is required only if site key is configured
const recaptchaRequired = !!recaptchaSiteKey;

const handleTranslate = useCallback(async () => {
if (!selectedFile || !targetLanguage) return;

// If reCAPTCHA is configured, execute it first (invisible mode)
if (recaptchaRequired && !recaptchaToken) {
try {
if (recaptchaRef.current) {
recaptchaRef.current.execute();
return; // Wait for onChange callback to proceed
} else {
// reCAPTCHA ref not available, proceed without it (fallback)
console.warn('reCAPTCHA ref not available, proceeding without verification');
}
} catch (error) {
console.error('reCAPTCHA execution error:', error);
// Continue without reCAPTCHA on error
}
}

// Proceed with translation (token already obtained from reCAPTCHA onChange, or no reCAPTCHA)
await translate({
file: selectedFile.file,
targetLanguage,
Expand All @@ -168,35 +141,13 @@ export function TranslateForm() {
sheets: selectedSheets.length > 0 && selectedSheets.length < sheets.length
? selectedSheets
: undefined,
recaptchaToken: recaptchaToken || undefined,
});
}, [selectedFile, targetLanguage, sourceLanguage, context, selectedSheets, sheets.length, recaptchaToken, recaptchaRequired, translate]);

// Handle reCAPTCHA token received (for invisible mode)
const handleRecaptchaChange = useCallback((token: string | null) => {
setRecaptchaToken(token);
// If we have a token and form is ready, proceed with translation
if (token && selectedFile && targetLanguage) {
translate({
file: selectedFile.file,
targetLanguage,
sourceLanguage: sourceLanguage || undefined,
context: context || undefined,
sheets: selectedSheets.length > 0 && selectedSheets.length < sheets.length
? selectedSheets
: undefined,
recaptchaToken: token,
});
}
}, [selectedFile, targetLanguage, sourceLanguage, context, selectedSheets, sheets.length, translate]);

const handleRetry = useCallback(() => {
reset();
recaptchaRef.current?.reset();
setRecaptchaToken(null);
}, [reset]);

// For invisible reCAPTCHA, button is enabled when form is ready (reCAPTCHA executes on click)
const canTranslate = selectedFile && targetLanguage && !isTranslating;

return (
Expand Down Expand Up @@ -369,17 +320,6 @@ export function TranslateForm() {
</div>
)}

{/* Invisible reCAPTCHA - hidden but always rendered when site key is available */}
{recaptchaSiteKey && (
<div style={{ display: 'none' }}>
<Recaptcha
ref={recaptchaRef}
siteKey={recaptchaSiteKey}
onChange={handleRecaptchaChange}
/>
</div>
)}

{/* Translate Button */}
<Button
disabled={!canTranslate || isTranslating}
Expand Down
48 changes: 0 additions & 48 deletions frontend/src/components/ui/Recaptcha.css

This file was deleted.

57 changes: 0 additions & 57 deletions frontend/src/components/ui/Recaptcha.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions frontend/src/components/ui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@ export { Card, CardHeader, CardContent, CardFooter } from './Card';
export { Dropdown } from './Dropdown';
export { FileDropzone } from './FileDropzone';
export { FloatingFeedbackButton } from './FloatingFeedbackButton';
export { Recaptcha } from './Recaptcha';
export type { RecaptchaRef } from './Recaptcha';
4 changes: 0 additions & 4 deletions frontend/src/hooks/useTranslate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,6 @@ export function useTranslate(): UseTranslateReturn {
formData.append('sheets', request.sheets.join(','));
}

if (request.recaptchaToken) {
formData.append('recaptcha_token', request.recaptchaToken);
}

// Create abort controller for timeout
abortControllerRef.current = new AbortController();

Expand Down
Loading
Loading