import { apiGet, apiPost } from './http'
import type { User } from '@/types/api'

export interface LoginPayload {
  email: string
  password: string
}

export interface LoginResult {
  token: string
  token_type: string
  expires_in: number
  user: User
}

export function login(payload: LoginPayload) {
  return apiPost<LoginResult>('/api/auth/login', payload)
}

export function register(payload: {
  name: string
  email: string
  password: string
  password_confirmation: string
  invite_code: string
}) {
  return apiPost<LoginResult>('/api/auth/register', payload)
}

export function me() {
  return apiGet<User>('/api/auth/me')
}
