// Settings view — verification defaults, migration defaults, connection info import { api } from './api.js'; import { state } from './state.js'; import { escHtml } from './utils.js'; const SETTINGS_KEY = 'migrator_settings'; export function loadSettings() { try { return JSON.parse(localStorage.getItem(SETTINGS_KEY)) || {}; } catch { return {}; } } export function saveSettings(settings) { localStorage.setItem(SETTINGS_KEY, JSON.stringify(settings)); } export function renderSettings() { const outlet = document.getElementById('router-outlet'); const s = loadSettings(); outlet.innerHTML = `
Verification
Default recipient for test envelopes
Test Recipient Name
Pre-filled in the Send Test dialog on the Verification screen
Test Recipient Email
Pre-filled in the Send Test dialog
Auto-Void Timer (hours)
Reminder to void test envelopes after this many hours (display only — no automatic action)
Migration Defaults
Pre-set options in the migration options modal
Overwrite Existing by Default
When on, the Overwrite Existing toggle in the migration modal starts enabled
Include Documents by Default
Embed PDFs in the Docusign template payload
Connections
Current platform connection status (connect via top bar)
Loading…
`; // Wire toggles document.querySelectorAll('.toggle').forEach(btn => { btn.addEventListener('click', () => { btn.classList.toggle('on'); btn.setAttribute('aria-checked', btn.classList.contains('on')); }); }); // Save document.getElementById('btn-save-settings')?.addEventListener('click', () => { const updated = { testRecipientName: document.getElementById('set-recipient-name')?.value.trim() || '', testRecipientEmail: document.getElementById('set-recipient-email')?.value.trim() || '', autoVoidHours: parseInt(document.getElementById('set-auto-void')?.value) || 24, defaultOverwrite: document.getElementById('set-overwrite')?.classList.contains('on') || false, defaultIncludeDocs: document.getElementById('set-include-docs')?.classList.contains('on') !== false, }; saveSettings(updated); const confirm = document.getElementById('save-confirm'); if (confirm) { confirm.style.display = 'inline'; setTimeout(() => { confirm.style.display = 'none'; }, 2500); } }); // Load connection info _loadConnInfo(); } async function _loadConnInfo() { const connEl = document.getElementById('settings-conn-info'); if (!connEl) return; try { const data = await api.auth.status(); connEl.innerHTML = `
Adobe Sign ${data.adobe ? 'Connected' : 'Not connected'} ${data.adobe ? '● Connected' : '○ Disconnected'}
Docusign ${data.docusign ? 'Connected' : 'Not connected'} ${data.docusign ? '● Connected' : '○ Disconnected'}
Adobe Auth Mode ${escHtml(data.adobe_auth_mode || '—')}
Docusign Auth Mode ${escHtml(data.docusign_auth_mode || '—')}
Browser Session ID ${escHtml(data.session_id || '—')}
Docusign Account ID ${escHtml(data.docusign_account_id || '—')}
API Environment ${escHtml(data.base_url || '—')}
`; } catch (e) { connEl.innerHTML = `
Failed to load connection info: ${escHtml(e.message)}
`; } }