Files
office_translator/frontend/src/app/dashboard/translate/LanguageSelector.tsx
Sepehr Ramezani 26bd096a06 feat: production deployment - full update with providers, admin, glossaries, pricing, tests
Major changes across backend, frontend, infrastructure:
- Provider system with model selection (Google, DeepL, OpenAI, Ollama, Google Cloud)
- Admin panel: user management, pricing, settings
- Glossary system with CSV import/export
- Subscription and tier quota management
- Security hardening (rate limiting, API key auth, path traversal fixes)
- Docker compose for dev, prod, and IONOS deployment
- Alembic migrations for new tables
- Frontend: dashboard, pricing page, landing page, i18n (en/fr)
- Test suite and verification scripts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-25 15:01:47 +02:00

106 lines
3.5 KiB
TypeScript

'use client';
import { ArrowRight, Loader2, AlertCircle } from 'lucide-react';
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '@/components/ui/select';
import { useI18n } from '@/lib/i18n';
import type { Language } from './types';
interface LanguageSelectorProps {
sourceLang: string;
targetLang: string;
languages: Language[];
isLoading?: boolean;
error?: string | null;
onSourceChange: (value: string) => void;
onTargetChange: (value: string) => void;
}
export function LanguageSelector({
sourceLang,
targetLang,
languages,
isLoading,
error,
onSourceChange,
onTargetChange,
}: LanguageSelectorProps) {
const { t } = useI18n();
return (
<div className="flex flex-col gap-3">
{error && (
<div className="flex items-center gap-2 rounded-lg bg-destructive/10 px-3 py-2 text-xs text-destructive">
<AlertCircle className="size-3.5 shrink-0" />
<span>{t('dashboard.translate.language.loadErrorPrefix')} {error}</span>
</div>
)}
<div className="flex items-end gap-3">
{/* Source language */}
<div className="flex flex-1 flex-col gap-1.5">
<label className="text-sm font-medium text-foreground">
{t('dashboard.translate.language.source')}
</label>
<Select value={sourceLang} onValueChange={onSourceChange} disabled={isLoading}>
<SelectTrigger className="h-11 w-full">
{isLoading ? (
<div className="flex items-center gap-2 text-muted-foreground">
<Loader2 className="size-3.5 animate-spin" />
<span>{t('dashboard.translate.language.loading')}</span>
</div>
) : (
<SelectValue placeholder={t('dashboard.translate.language.autoDetect')} />
)}
</SelectTrigger>
<SelectContent>
<SelectItem value="auto">{t('dashboard.translate.language.autoDetect')}</SelectItem>
{languages.map((lang) => (
<SelectItem key={lang.code} value={lang.code}>
{lang.name}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
{/* Arrow — flips in RTL via rtl: variant */}
<div className="mb-2 flex size-9 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground">
<ArrowRight className="size-4 rtl:rotate-180" />
</div>
{/* Target language */}
<div className="flex flex-1 flex-col gap-1.5">
<label className="text-sm font-medium text-foreground">
{t('dashboard.translate.language.target')}
</label>
<Select value={targetLang} onValueChange={onTargetChange} disabled={isLoading}>
<SelectTrigger className="h-11 w-full">
{isLoading ? (
<div className="flex items-center gap-2 text-muted-foreground">
<Loader2 className="size-3.5 animate-spin" />
<span>{t('dashboard.translate.language.loading')}</span>
</div>
) : (
<SelectValue placeholder={t('dashboard.translate.language.selectPlaceholder')} />
)}
</SelectTrigger>
<SelectContent>
{languages.map((lang) => (
<SelectItem key={lang.code} value={lang.code}>
{lang.name}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
</div>
</div>
);
}