'use client'; import { useState } from 'react'; import { Loader2 } from 'lucide-react'; import { useTranslations } from 'next-intl'; import { AlertDialog, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from '@/components/ui/alert-dialog'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '@/components/ui/select'; const CLEANUP_PRESETS = [3, 7, 30]; interface CleanupDialogProps { open: boolean; onOpenChange: (open: boolean) => void; onConfirm: (retentionDays: number) => void; loading: boolean; } export function CleanupDialog({ open, onOpenChange, onConfirm, loading, }: CleanupDialogProps) { const t = useTranslations('accessLogs.cleanupDialog'); const tCommon = useTranslations('common'); const [mode, setMode] = useState('7'); const [customDays, setCustomDays] = useState('14'); const [error, setError] = useState(null); const handleConfirm = () => { const retentionDays = mode === 'custom' ? Number.parseInt(customDays, 10) : Number.parseInt(mode, 10); if (!Number.isFinite(retentionDays) || retentionDays < 1) { setError(t('invalidDays')); return; } setError(null); onConfirm(retentionDays); }; return ( {t('title')} {t('description')}
{mode === 'custom' ? (
setCustomDays(e.target.value)} disabled={loading} />
) : null} {error ?

{error}

: null}
{tCommon('cancel')}
); }