import { api } from "./client";

export type ActiveTenant = { id: number; name: string } | null;

export type ActiveMembership = {
  tenant_id: number;
  status: "invited" | "active" | "suspended";
  is_owner: boolean;
  role_ids: number[];
} | null;

export type Me = {
  id: number;
  username: string;
  email: string;
  first_name: string;
  last_name: string;
  is_superuser: boolean;
  is_staff: boolean;
  is_active: boolean;
  must_change_password?: boolean;

  active_tenant?: ActiveTenant;
  active_membership?: ActiveMembership;
};

export async function fetchMe() {
  return api.request<Me>("/auth/me/", { method: "GET" });
}
