video preview version
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user