"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('replyIdentityMatch', value as ReplyIdentityMatch)} options={[ { value: 'exact', label: t('reply_identity_match.exact') }, { value: 'domain', label: t('reply_identity_match.domain') }, ]} /> )} updateSetting('sendDelaySeconds', Number(value) as SendDelaySeconds)} options={[ { value: '0', label: t('send_delay.off') }, { value: '10', label: t('send_delay.seconds', { seconds: 10 }) }, { value: '30', label: t('send_delay.seconds', { seconds: 30 }) }, { value: '60', label: t('send_delay.seconds', { seconds: 60 }) }, ]} /> {sendDelaySeconds > 0 && !delayedSendSupported && (

{t('send_delay.unsupported')}

)}
updateSetting('attachmentReminderEnabled', checked)} /> {attachmentReminderEnabled && (

{t('attachment_reminder.keywords_description')}

{attachmentReminderKeywords.map((kw) => ( {kw} ))}
{ e.preventDefault(); const trimmed = newKeyword.trim().toLowerCase(); if (trimmed && !attachmentReminderKeywords.includes(trimmed)) { updateSetting('attachmentReminderKeywords', [...attachmentReminderKeywords, trimmed]); } setNewKeyword(''); }} > setNewKeyword(e.target.value)} placeholder={t('attachment_reminder.add_placeholder')} className="flex-1 min-w-0 px-2 py-1 text-sm bg-background border border-border rounded-md focus:outline-none focus:ring-1 focus:ring-ring" />
)} updateSetting('emptySubjectWarningEnabled', checked)} /> updateSetting('requestReadReceiptDefault', checked)} />