import { Modal, Stack, Text, Button, PasswordInput, Group, } from "@mantine/core"; import { useTranslation } from "react-i18next"; import { type KeyboardEventHandler } from "react"; import { Z_INDEX_OVER_FULLSCREEN_SURFACE } from "@app/styles/zIndex"; interface EncryptedPdfUnlockModalProps { opened: boolean; fileName?: string; password: string; errorMessage?: string | null; isProcessing: boolean; remainingCount: number; onPasswordChange: (value: string) => void; onUnlock: () => void; onUnlockAll: () => void; onSkip: () => void; } const EncryptedPdfUnlockModal = ({ opened, fileName, password, errorMessage, isProcessing, remainingCount, onPasswordChange, onUnlock, onUnlockAll, onSkip, }: EncryptedPdfUnlockModalProps) => { const { t } = useTranslation(); const handleKeyDown: KeyboardEventHandler = (event) => { if (event.key === "Enter" && !isProcessing && password.trim().length > 0) { onUnlock(); } }; return ( {fileName} {t( "encryptedPdfUnlock.description", "This PDF is password protected. Enter the password so you can continue working with it.", )} onPasswordChange(event.currentTarget.value)} onKeyDown={handleKeyDown} disabled={isProcessing} autoFocus /> {errorMessage ? ( {errorMessage} ) : null} {remainingCount > 0 && ( )} ); }; export default EncryptedPdfUnlockModal;