import { UserRole } from '@/shared/types/app';

export interface BackendRole {
  readonly id?: string;
  readonly name?: string;
  readonly scope?: string | null;
  readonly globalAccess?: boolean;
}

export interface BackendOrganization {
  readonly id: string;
  readonly name?: string;
  readonly logo?: string | null;
}

/** Minimal tenant identity (school/class) for the active-scope badge + selectors. */
export interface BackendTenant {
  readonly id: string;
  readonly name?: string | null;
  readonly logo?: string | null;
}

export interface BackendCampus {
  readonly id: string;
  readonly name?: string;
  readonly code?: string;
}

export interface CurrentUser {
  readonly id: string;
  readonly email: string;
  /** Honorific title (e.g. `dr`); rendered before the name. */
  readonly name_prefix?: string | null;
  readonly firstName?: string | null;
  readonly lastName?: string | null;
  readonly phoneNumber?: string | null;
  /** Avatar file private URL (served via the file download endpoint). */
  readonly avatar?: string | null;
  readonly app_role?: BackendRole | null;
  readonly organizations?: BackendOrganization | null;
  readonly organizationId?: string | null;
  readonly campus?: BackendCampus | null;
  readonly campusId?: string | null;
  readonly school?: BackendTenant | null;
  readonly schoolId?: string | null;
  readonly classRoom?: BackendTenant | null;
  readonly classId?: string | null;
  readonly permissions?: readonly string[];
}

export interface SignInRequest {
  readonly email: string;
  readonly password: string;
}

export interface SignUpRequest extends SignInRequest {
  readonly fullName: string;
  readonly role: UserRole;
  readonly campus: string;
}
