import { http, HttpResponse } from 'msw';
import {
  patientHandlers,
  alertHandlers,
  appointmentHandlers,
  doctorHandlers,
  deviceHandlers,
  analysisHandlers,
  usageHandlers,
  pointsProductHandlers,
  pointsRuleHandlers,
  pointsOrderHandlers,
  articleHandlers,
  alertRuleHandlers,
  scheduleHandlers,
} from './healthHandlers';

const TOKEN_EXPIRES = 3600;

export const authHandlers = [
  http.post('/api/v1/auth/login', () =>
    HttpResponse.json({
      success: true,
      data: {
        access_token: 'test-access-token',
        refresh_token: 'test-refresh-token',
        expires_in: TOKEN_EXPIRES,
        user: { id: 'test-user-id', username: 'admin', tenant_id: 'test-tenant-id' },
      },
    }),
  ),

  http.post('/api/v1/auth/refresh', () =>
    HttpResponse.json({
      success: true,
      data: {
        access_token: 'test-access-token-refreshed',
        refresh_token: 'test-refresh-token-refreshed',
        expires_in: TOKEN_EXPIRES,
      },
    }),
  ),
];

export const handlers = [
  ...authHandlers,
  ...patientHandlers,
  ...alertHandlers,
  ...appointmentHandlers,
  ...doctorHandlers,
  ...deviceHandlers,
  ...analysisHandlers,
  ...usageHandlers,
  ...pointsProductHandlers,
  ...pointsRuleHandlers,
  ...pointsOrderHandlers,
  ...articleHandlers,
  ...alertRuleHandlers,
  ...scheduleHandlers,
];
