'use client'; import * as React from 'react'; import { createPortal } from 'react-dom'; import { DoorOpen, KeyRound } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { PinInput } from '@/components/ui/pin-input'; import { isPinInputComplete } from '@/lib/pin-input'; interface PinLockModalProps { open: boolean; isSubmitting: boolean; error?: string | null; onSubmit: (pin: string) => Promise; onLogout?: () => void; } export function PinLockModal({ open, isSubmitting, error, onSubmit, onLogout }: PinLockModalProps) { const [pin, setPin] = React.useState(''); const [mounted, setMounted] = React.useState(false); React.useEffect(() => { setMounted(true); }, []); React.useEffect(() => { if (open) { setPin(''); } }, [open]); React.useEffect(() => { if (!open || typeof document === 'undefined') return; const previousOverflow = document.body.style.overflow; document.body.style.overflow = 'hidden'; return () => { document.body.style.overflow = previousOverflow; }; }, [open]); async function handleSubmit(event: React.FormEvent) { event.preventDefault(); await onSubmit(pin); } if (!open || !mounted) return null; return createPortal(
{onLogout ? ( ) : null}

Введите PIN-код

Сессия заблокирована из-за бездействия. Подтвердите PIN, чтобы продолжить работу.

{error ?

{error}

: null} {onLogout ? ( ) : null}
, document.body ); }