import { useState } from 'react'; import { ActivityIndicator, Text, TouchableOpacity, View } from 'react-native'; import { useTranslation } from 'react-i18next'; import { useMailTitleEdit } from '../../hooks/useMailTitleEdit'; import { FormSheet } from '../FormSheet'; import { SheetFieldStack } from '../SheetFieldStack'; type Props = { visible: boolean; connectionId: string; currentTitle: string | null; onClose: () => void; onSuccess: (newTitle: string | null) => void; }; export function EditMailTitleSheet({ visible, connectionId, currentTitle, onClose, onSuccess, }: Props) { const { t } = useTranslation(); const { saveTitle, saving, error } = useMailTitleEdit(); const [title, setTitle] = useState(currentTitle ?? ''); function handleClose() { setTitle(currentTitle ?? ''); onClose(); } async function handleSave() { const ok = await saveTitle(connectionId, title); if (ok) { onSuccess(title.trim() || null); onClose(); } } return ( {}} > {error && ( {error} )} {saving ? ( ) : ( {t('mail.title_save')} )} ); }