import axiosInstance from "@/config/axios";

export interface EmailSuggestion {
  address: string;
  name: string;
  frequency: number;
  lastUsed: string;
}

export interface EmailSuggestionsResponse {
  suggestions: EmailSuggestion[];
  total: number;
  query: string;
}

export interface GetEmailSuggestionsParams {
  query?: string;
  limit?: number;
}

export const EmailSuggestionsService = {
  async getSuggestions(
    params?: GetEmailSuggestionsParams
  ): Promise<EmailSuggestionsResponse> {
    const response = await axiosInstance.get("/email/suggestions", {
      params: {
        query: params?.query || "",
        limit: params?.limit || 5,
      },
    });
    return response.data.data; // API returns wrapped response
  },
};
