import { Injectable } from '@angular/core';
import axios from 'axios';

import { BASE_URL } from '../config/api.config';

export interface DoctorRegistrationRequest {
  user: {
    email: string;
    password: {
      password: string;
      confirmPassword: string;
    };
    firstName: string;
    lastName: string;
    phoneNumber: string;
  };
  medicalLicenseNumber: string;
  specialization: string;
  yearsOfExperience: number;
  biography?: string;
  consultationFee: number;
}

export interface PatientRegistrationRequest {
  user: {
    email: string;
    password: {
      password: string;
      confirmPassword: string;
    };
    firstName: string;
    lastName: string;
    phoneNumber: string;
  };
  emergencyContactName?: string;
  emergencyContactPhone?: string;
  bloodType?: string;
  allergies?: string[];
}

export interface AdminRegistrationRequest {
  email: string;
  password: {
    password: string;
    confirmPassword: string;
  };
  firstName: string;
  lastName: string;
  phoneNumber: string;
}

@Injectable({ providedIn: 'root' })
export class RegistrationService {
  async registerDoctor(data: DoctorRegistrationRequest): Promise<any> {
    const res = await axios.post(`${BASE_URL}/api/v3/users/register/doctor`, data);
    return res.data;
  }

  async registerPatient(data: PatientRegistrationRequest): Promise<any> {
    const res = await axios.post(`${BASE_URL}/api/v3/users/register/patient`, data);
    return res.data;
  }

  async registerAdmin(data: AdminRegistrationRequest): Promise<any> {
    const res = await axios.post(`${BASE_URL}/api/v3/users/register/admin`, data);
    return res.data;
  }
}

