import { apiClient } from './api-client';

export interface UserProfile {
  id: string;
  email: string | null;
  phone: string;
  fullName: string;
  avatarUrl: string | null;
  role: string;
  kycStatus: string;
  isActive: boolean;
  createdAt: string;
}

export interface RegisterPayload {
  phone: string;
  password: string;
  fullName: string;
  email?: string;
}

export interface LoginPayload {
  phone: string;
  password: string;
}

export const authApi = {
  register: (data: RegisterPayload) =>
    apiClient.post<{ message: string }>('/auth/register', data),

  login: (data: LoginPayload) =>
    apiClient.post<{ message: string }>('/auth/login', data),

  refresh: () =>
    apiClient.post<{ message: string }>('/auth/refresh'),

  logout: () =>
    apiClient.post<{ message: string }>('/auth/logout'),

  exchangeToken: (accessToken: string, refreshToken: string, expiresIn?: number) =>
    apiClient.post<{ message: string }>('/auth/exchange-token', {
      accessToken,
      refreshToken,
      expiresIn,
    }),

  getProfile: () => apiClient.get<UserProfile>('/auth/profile'),
};
