"use client";
import { useState } from 'react';
import { useTranslations } from 'next-intl';
import { useSettingsStore } from '@/stores/settings-store';
import type { MentionAddsRecipientTo, ReplyIdentityMatch, SendDelaySeconds } from '@/stores/settings-store';
import { useAuthStore } from '@/stores/auth-store';
import { usePolicyStore } from '@/stores/policy-store';
import { SettingsSection, SettingItem, Select, ToggleSwitch } from './settings-section';
import { TemplateSettings } from './template-settings';
import { Button } from '@/components/ui/button';
import { X, ChevronRight } from '@/components/icons';
/**
* The Composing page: the editor, replying, what happens before a send,
* read receipts, templates (their own tab before) and a pointer to where
* signatures live, since people look for them here.
*/
export function ComposingSettings() {
const t = useTranslations('settings.email_behavior');
const tPage = useTranslations('settings.composing_page');
const templatesEnabled = usePolicyStore((s) => s.isFeatureEnabled('templatesEnabled'));
const [newKeyword, setNewKeyword] = useState('');
const {
quickReplyEnabled,
autoSelectReplyIdentity,
replyIdentityMatch,
plainTextMode,
rtlEditingSupport,
attachmentReminderEnabled,
attachmentReminderKeywords,
emptySubjectWarningEnabled,
recipientMentionsEnabled,
mentionAddsRecipientTo,
sendDelaySeconds,
signaturePosition,
signatureSeparatorEnabled,
requestReadReceiptDefault,
readReceiptResponse,
updateSetting,
} = useSettingsStore();
const { client } = useAuthStore();
const delayedSendSupported = client?.hasDelayedSend() ?? false;
// Catch-all matching only rewrites From, which the admin can switch off.
const customFromEnabled = usePolicyStore((s) => s.isFeatureEnabled('customFromEnabled'));
return (
updateSetting('plainTextMode', checked)}
/>
updateSetting('recipientMentionsEnabled', checked)}
/>
{recipientMentionsEnabled && (
)}
updateSetting('rtlEditingSupport', checked)}
/>
updateSetting('quickReplyEnabled', checked)}
/>
updateSetting('autoSelectReplyIdentity', checked)}
/>
{autoSelectReplyIdentity && customFromEnabled && (
)}
updateSetting('signatureSeparatorEnabled', checked)}
/>
updateSetting('attachmentReminderEnabled', checked)}
/>
{attachmentReminderEnabled && (
{t('attachment_reminder.keywords_description')}
{attachmentReminderKeywords.map((kw) => (
{kw}
))}
)}
updateSetting('emptySubjectWarningEnabled', checked)}
/>
updateSetting('requestReadReceiptDefault', checked)}
/>
{templatesEnabled &&
}
);
}