// externalSupabase.ts
// Conector para o Supabase fechado (empresa)

import { createClient, SupabaseClient } from "@supabase/supabase-js";

// Configuração do Supabase fechado
const SUPABASE_URL =
  process.env.EXTERNAL_SUPABASE_URL ||
  "https://etblfypcxxtvvuqjkrgd.supabase.co";
const SUPABASE_KEY =
  process.env.EXTERNAL_SUPABASE_KEY || "<service_key_ou_anon_key_aqui>";

export const externalSupabase: SupabaseClient = createClient(
  SUPABASE_URL,
  SUPABASE_KEY
);

// Funções CRUD reexportadas (exemplo)
export async function getPatients() {
  return externalSupabase.from("patients").select("*");
}

export async function getDoctors() {
  return externalSupabase.from("doctors").select("*");
}

export async function getAppointments() {
  return externalSupabase.from("appointments").select("*");
}

export async function createAppointment(data: any) {
  return externalSupabase.from("appointments").insert([data]);
}

// Adicione aqui outras funções antigas conforme necessário
// Exemplo: getAvailableSlots, createPatient, createDoctor, etc.

// Para funções antigas, basta importar e reexportar do serviço original
// Exemplo:
// export { login, logout, resetPassword } from './auth/authService';
// Reexportação dos serviços antigos do Supabase fechado
export { authService } from "./auth/authService";
export { assignmentService } from "./assignments/assignmentService";
export { avatarService } from "./avatars/avatarService";
export { doctorService } from "./doctors/doctorService";
export { patientService } from "./patients/patientService";
export { profileService } from "./profiles/profileService";
export { reportService } from "./reports/reportService";
export { userService } from "./users/userService";
export { smsService } from "./sms/smsService";
export { appointmentService } from "./appointments/appointmentService";
export { availabilityService } from "./availability/availabilityService";
export { apiClient } from "./api/client";
export { API_CONFIG } from "./api/config";
export { messageService } from "./messages/messageService";
export { waitlistService } from "./waitlist/waitlistService";
export { notificationService } from "./notifications/notificationService";
export { analyticsService } from "./analytics/analyticsService";
