/**
 * Tenant API Types - Mirror backend schemas
 */

import type { TenantRole } from '../../types/roles';

export interface BakeryRegistration {
  name: string;
  address: string;
  postal_code: string;
  phone: string;
  city?: string;
  business_type?: string;
  business_model?: string;
}

export interface TenantResponse {
  id: string;
  name: string;
  business_type?: string;
  description?: string;
  address?: string;
  city?: string;
  state?: string;
  country?: string;
  postal_code?: string;
  phone?: string;
  email?: string;
  website?: string;
  subdomain?: string;
  latitude?: number;
  longitude?: number;
  is_active: boolean;
  created_at: string;
  updated_at: string;
  owner_id: string;
  model_trained?: boolean;
  last_training_date?: string;
}

export interface TenantAccessResponse {
  has_access: boolean;
  role?: TenantRole;
  permissions?: string[];
  membership_id?: string;
  joined_at?: string;
}

export interface TenantUpdate {
  name?: string;
  business_type?: string;
  description?: string;
  address?: string;
  city?: string;
  state?: string;
  country?: string;
  postal_code?: string;
  phone?: string;
  email?: string;
  website?: string;
  latitude?: number;
  longitude?: number;
}

export interface TenantMemberResponse {
  id: string;
  tenant_id: string;
  user_id: string;
  role: TenantRole;
  is_active: boolean;
  joined_at: string;
  user_email?: string;
  user_full_name?: string;
}

export interface TenantSearchRequest {
  search_term: string;
  business_type?: string;
  city?: string;
  skip?: number;
  limit?: number;
}

export interface TenantStatistics {
  total_tenants: number;
  active_tenants: number;
  inactive_tenants: number;
  tenants_by_business_type: Record<string, number>;
  tenants_by_city: Record<string, number>;
  recent_registrations: TenantResponse[];
}

export interface TenantSearchParams {
  search_term?: string;
  business_type?: string;
  city?: string;
  skip?: number;
  limit?: number;
}

export interface TenantNearbyParams {
  latitude: number;
  longitude: number;
  radius_km?: number;
  limit?: number;
}