This commit is contained in:
Ccjcarkbla
2026-09-13 10:00:13 -04:00
parent 9b04f26c82
commit 349f469602
31 changed files with 1455 additions and 37 deletions
+15 -5
View File
@@ -58,7 +58,7 @@
</div>
<div class="form-group">
<label class="form-label" for="logo-file">Logo (PNG/JPG, max 2MB)</label>
<label class="form-label" for="logo-file">Logo (PNG/JPG/GIF/WebP, max 5MB)</label>
<input class="form-input" type="file" id="logo-file" accept="image/*">
<img id="logo-preview" style="display:none;max-height:60px;margin-top:var(--space-2);">
</div>
@@ -271,8 +271,8 @@
const { data } = await res.json();
el.innerHTML = `<table class="table"><thead><tr><th>Name</th><th>Email</th><th>Role</th><th>Status</th><th></th></tr></thead><tbody>
${data.map(u => `<tr>
<td>${u.name}</td>
<td>${u.email}</td>
<td>${[u.firstName, u.lastName].filter(Boolean).join(' ') || u.username}</td>
<td>${u.email || '—'}</td>
<td>${u.role}</td>
<td><span class="badge badge-${u.isActive ? 'success' : 'danger'}">${u.isActive ? 'Active' : 'Inactive'}</span></td>
<td class="table-actions">
@@ -392,6 +392,12 @@
}
} catch {}
// Server errors are shaped { error: { code, message } }
async function errMessage(res) {
try { const b = await res.json(); return b.error?.message || b.message || 'Failed.'; }
catch { return `Failed (HTTP ${res.status}).`; }
}
function hexOrUndefined(id) { const v = document.getElementById(id).value.trim(); return /^#[0-9A-Fa-f]{6}$/.test(v) ? v : undefined; }
document.getElementById('branding-form').addEventListener('submit', async (e) => {
@@ -426,10 +432,14 @@
const fd = new FormData();
fd.append('logo', logoFile);
const logoRes = await Api.upload('/api/v1/org/logo', fd);
if (!logoRes.ok) { const b = await logoRes.json(); errEl.textContent = b.message || 'Failed.'; errEl.style.display = 'block'; return; }
if (!logoRes.ok) { errEl.textContent = await errMessage(logoRes); errEl.style.display = 'block'; return; }
const { data } = await logoRes.json();
const img = document.getElementById('logo-preview');
img.src = data.logoPath; img.style.display = '';
document.getElementById('logo-file').value = '';
}
const res = await Api.patch('/api/v1/org/branding', brandFields);
if (!res.ok) { const b = await res.json(); errEl.textContent = b.message || 'Failed.'; errEl.style.display = 'block'; return; }
if (!res.ok) { errEl.textContent = await errMessage(res); errEl.style.display = 'block'; return; }
toast('Branding updated.', 'success');
Branding.load();
} catch { errEl.textContent = 'Network error.'; errEl.style.display = 'block'; }