Files
odysseus/static/js/emailShared.js
T
2026-06-27 13:05:44 +00:00

20 lines
723 B
JavaScript

const API_BASE = window.location.origin;
export function emailAccountQuery(prefix = '&') {
const accountId = window.__odysseusActiveEmailAccount || '';
if (!accountId) return '';
const lead = prefix === '?' ? '?' : '&';
return `${lead}account_id=${encodeURIComponent(accountId)}`;
}
export function emailApiUrl(path, params = {}) {
const url = new URL(`${API_BASE}${path}`);
const accountId = window.__odysseusActiveEmailAccount || '';
if (accountId) url.searchParams.set('account_id', accountId);
Object.entries(params || {}).forEach(([key, value]) => {
if (value === undefined || value === null || value === '') return;
url.searchParams.set(key, String(value));
});
return url.toString();
}