"use client"; import { useState, useCallback } from 'react'; import { useTranslations } from 'next-intl'; import { useConfig } from '@/hooks/use-config'; import { useSettingsStore } from '@/stores/settings-store'; import { SettingsSection, SettingItem, ToggleSwitch } from './settings-section'; import { Mail, X } from 'lucide-react'; export function ComposingSettings() { const t = useTranslations('settings.email_behavior'); const { appName } = useConfig(); const [defaultMailStatus, setDefaultMailStatus] = useState<'idle' | 'success' | 'error'>('idle'); const [newKeyword, setNewKeyword] = useState(''); const { autoSelectReplyIdentity, attachmentReminderEnabled, attachmentReminderKeywords, updateSetting, } = useSettingsStore(); const handleSetDefaultMailProgram = useCallback(() => { try { if (typeof navigator !== 'undefined' && navigator.registerProtocolHandler) { navigator.registerProtocolHandler('mailto', `${window.location.origin}/compose?mailto=%s`); setDefaultMailStatus('success'); } } catch { setDefaultMailStatus('error'); } }, []); return ( updateSetting('autoSelectReplyIdentity', checked)} /> 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" />
)}
{defaultMailStatus === 'success' && (

{t('default_mail_program.success')}

)} {defaultMailStatus === 'error' && (

{t('default_mail_program.error')}

)}
); }