feat: integrate hospital management module with advanced UI styling and analytics components
This commit is contained in:
@@ -25,60 +25,9 @@ export const apiClient = {
|
||||
defaultHeaders['Authorization'] = `Bearer ${authToken}`;
|
||||
}
|
||||
|
||||
// --- MOCK BYPASS FOR DEMO SESSIONS ---
|
||||
if (authToken && (
|
||||
authToken.startsWith('mock-') ||
|
||||
authToken.startsWith('dev-token-') ||
|
||||
authToken === 'dev-super-token-2026'
|
||||
)) {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
if (endpoint.includes('/v1/incidents')) {
|
||||
resolve({
|
||||
status: 200,
|
||||
data: [
|
||||
{
|
||||
id: 'INC-MOCK-001',
|
||||
category: 'MEDICAL',
|
||||
severity: 'CRITICAL',
|
||||
status: 'PENDING',
|
||||
address: 'Sector 7G, Tactical Hub',
|
||||
notes: 'High-priority mock incident for system validation.',
|
||||
createdAt: new Date().toISOString(),
|
||||
gps_lat: 13.0827,
|
||||
gps_lon: 80.2707,
|
||||
patients: [{ name: 'Tactical Test', age: 34, gender: 'Male', symptoms: ['None'], triage_code: 'RED' }]
|
||||
}
|
||||
]
|
||||
});
|
||||
} else if (endpoint.includes('/v1/auth/users')) {
|
||||
resolve({
|
||||
status: 200,
|
||||
data: [
|
||||
{ id: 'u1', username: 'admin', roles: ['CURESELECT_ADMIN'], status: 'ACTIVE', email: 'admin@teleems.com' },
|
||||
{ id: 'u2', username: 'fleet_op', roles: ['FLEET_OPERATOR'], status: 'ACTIVE', email: 'fleet@teleems.com' }
|
||||
]
|
||||
});
|
||||
} else if (endpoint.includes('/v1/auth/audit-logs')) {
|
||||
resolve({
|
||||
status: 200,
|
||||
data: {
|
||||
logs: [
|
||||
{ id: 'l1', action: 'LOGIN_SUCCESS', createdAt: new Date().toISOString(), ipAddress: '127.0.0.1', user: { username: 'admin' } },
|
||||
{ id: 'l2', action: 'INCIDENT_VIEW', createdAt: new Date().toISOString(), ipAddress: '127.0.0.1', user: { username: 'admin' } }
|
||||
],
|
||||
total: 2
|
||||
}
|
||||
});
|
||||
} else {
|
||||
resolve({ status: 200, data: [] });
|
||||
}
|
||||
}, 500);
|
||||
});
|
||||
}
|
||||
|
||||
const url = endpoint.startsWith('http') ? endpoint : `${BASE_URL}${endpoint}`;
|
||||
|
||||
console.log(`[API] ${options.method || 'GET'} ${url}`);
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
headers: { ...defaultHeaders, ...headers },
|
||||
@@ -86,8 +35,8 @@ export const apiClient = {
|
||||
});
|
||||
|
||||
// Handle session expiration
|
||||
if (response.status === 401 || response.status === 403) {
|
||||
console.warn('Unauthorized request detected. Triggering auto-logout...');
|
||||
if (response.status === 401 && !url.includes('/auth/login')) {
|
||||
console.warn('Token expired or invalid. Triggering auto-logout...');
|
||||
logout();
|
||||
return null; // Return null as the app will redirect
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user