"use client"; import { useTranslations } from 'next-intl'; import { useSettingsStore, type ToolbarPosition, type MailLayout } from '@/stores/settings-store'; import { SettingsSection, SettingItem, RadioGroup, ToggleSwitch } from './settings-section'; import { cn } from '@/lib/utils'; import { usePolicyStore } from '@/stores/policy-store'; import { useAccountStore } from '@/stores/account-store'; const MAIL_LAYOUT_PREVIEW_ROWS = [ { sender: 'Alice', subject: 'Quarterly roadmap', preview: 'The draft is ready for review.', selected: false }, { sender: 'Nadia', subject: 'Design sync', preview: 'Pushed updated mocks and notes.', selected: true }, { sender: 'Billing', subject: 'Invoice 1042', preview: 'Your receipt is attached.', selected: false }, ]; const MAIL_LAYOUT_PREVIEW_ROWS_FOCUS = [ ...MAIL_LAYOUT_PREVIEW_ROWS, { sender: 'Sam', subject: 'Lunch?', preview: '', selected: false }, { sender: 'Newsletter', subject: 'Weekly digest', preview: '', selected: false }, ]; function MailLayoutPreview({ value, t, }: { value: MailLayout; t: (key: string) => string; }) { return (
{t(`mail_layout.${value}`)}
{t(`mail_layout.${value}_description`)}
{value === 'split' && ( <>
{MAIL_LAYOUT_PREVIEW_ROWS.map((row) => (
{row.sender}
{row.subject}
))}
)} {value === 'focus' && (
{MAIL_LAYOUT_PREVIEW_ROWS_FOCUS.map((row) => (
{row.sender} {row.subject}
))}
)} {value === 'horizontal' && (
{MAIL_LAYOUT_PREVIEW_ROWS.map((row) => (
{row.sender} {row.subject}
))}
)}
); } export function LayoutSettings() { const t = useTranslations('settings.appearance'); const tEmail = useTranslations('settings.email_behavior'); const { toolbarPosition, showToolbarLabels, hideAccountSwitcher, showRailAccountList, enableUnifiedMailbox, colorfulSidebarIcons, mailLayout, updateSetting } = useSettingsStore(); const { isSettingLocked, isSettingHidden } = usePolicyStore(); const accounts = useAccountStore(s => s.accounts); return ( {!isSettingHidden('mailLayout') && (
updateSetting('mailLayout', value as MailLayout)} options={[ { value: 'split', label: tEmail('mail_layout.split') }, { value: 'focus', label: tEmail('mail_layout.focus') }, { value: 'horizontal', label: tEmail('mail_layout.horizontal') }, ]} />
)} updateSetting('toolbarPosition', value as ToolbarPosition)} options={[ { value: 'top', label: t('toolbar_position.top') }, { value: 'below-subject', label: t('toolbar_position.below_subject') }, ]} /> updateSetting('showToolbarLabels', checked)} /> updateSetting('hideAccountSwitcher', checked)} /> updateSetting('showRailAccountList', checked)} /> updateSetting('colorfulSidebarIcons', checked)} /> {accounts.length > 1 && ( updateSetting('enableUnifiedMailbox', v)} /> )}
); }