import { Button } from '@/components/ui/button' import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/components/ui/dialog' import { Drawer, DrawerContent, DrawerDescription, DrawerHeader, DrawerTitle } from '@/components/ui/drawer' import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { useScreenSize } from '@/providers/ScreenSizeProvider' import { useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' type Props = { open: boolean onResult: (password: string | null) => void } export default function NcryptsecPasswordPrompt({ open, onResult }: Props) { const { t } = useTranslation() const { isSmallScreen } = useScreenSize() const [password, setPassword] = useState('') useEffect(() => { if (open) setPassword('') }, [open]) const title = t('Enter the password to decrypt your ncryptsec') const submit = () => { const trimmed = password.trim() onResult(trimmed.length > 0 ? trimmed : null) } const cancel = () => { onResult(null) } const form = (
{ e.preventDefault() submit() }} >
setPassword(e.target.value)} />
) if (isSmallScreen) { return ( { if (!next) cancel() }} > {title} {title}
{form}
) } return ( { if (!next) cancel() }} > {title} {title} {form} ) }