'use client'; import { useState } from 'react'; import { useTranslations } from 'next-intl'; import { Button } from '@/components/ui/button'; import { SettingsSection, SettingItem, Select } from './settings-section'; import { IdentityManagerModal } from '@/components/identity/identity-manager-modal'; import { useIdentityStore } from '@/stores/identity-store'; import { useSettingsStore } from '@/stores/settings-store'; import { SUPPORTED_SUB_ADDRESS_DELIMITERS, isSupportedSubAddressDelimiter, isValidSubAddressDelimiter, } from '@/lib/sub-addressing'; const CUSTOM_DELIMITER_SENTINEL = '__custom__'; const DEFAULT_CUSTOM_DELIMITER = '~'; /** * The Account page's "Email addresses" section: the identities you send * from (each with its name and signature), sub-addressing and, with * Advanced on, the delimiter the server uses for it. Was its own * Identities tab, with the delimiter over on Composing. */ export function EmailAddressesSection() { const t = useTranslations('settings.identities'); const tAccount = useTranslations('settings.account'); const tEmail = useTranslations('settings.email_behavior'); const { identities } = useIdentityStore(); const { subAddressDelimiter, updateSetting } = useSettingsStore(); const [showModal, setShowModal] = useState(false); return ( <> {/* Identity Count */}
{identities.length === 0 ? t('identities_count.count_zero') : identities.length === 1 ? t('identities_count.count_one') : t('identities_count.count_other', { count: identities.length })}
{/* Sub-Addressing Info */}
{ const next = e.target.value.slice(0, 1); if (next && isValidSubAddressDelimiter(next)) { updateSetting('subAddressDelimiter', next); } }} aria-label={tEmail('sub_address_delimiter.custom_input_label')} placeholder={DEFAULT_CUSTOM_DELIMITER} className="w-16 px-2 py-1 text-sm font-mono text-center bg-background border border-border rounded-md focus:outline-none focus:ring-1 focus:ring-ring" /> )}
{/* Identity Manager Modal */} setShowModal(false)} /> ); }