video preview version

This commit is contained in:
fahed
2026-02-08 22:51:42 +03:00
parent 5f7d922f92
commit 9b58e5e9aa
23 changed files with 890 additions and 544 deletions

View File

@@ -25,13 +25,18 @@ const normalize = (data) => {
const handleResponse = async (r, label) => {
if (!r.ok) {
if (r.status === 401 || r.status === 403) {
// Unauthorized - redirect to login if not already there
if (r.status === 401) {
// Unauthorized (not logged in) - redirect to login if not already there
if (!window.location.pathname.includes('/login')) {
window.location.href = '/login';
}
}
throw new Error(`${label} failed: ${r.status}`);
let serverMsg = '';
try {
const body = await r.json();
serverMsg = body.error || '';
} catch {}
throw new Error(serverMsg || `${label} failed: ${r.status}`);
}
const json = await r.json();
return normalize(json);
@@ -123,3 +128,9 @@ export const PRIORITY_CONFIG = {
high: { label: 'High', color: 'bg-orange-500' },
urgent: { label: 'Urgent', color: 'bg-red-500' },
};
// Shared helper: extract initials from a name string
export function getInitials(name) {
if (!name) return '?';
return name.split(' ').map(w => w[0]).join('').slice(0, 2).toUpperCase();
}