import { Document, Types } from 'mongoose';

import { IPaginateModel } from '@/shared/interfaces/model.interface';
import { AuditFields } from '@/shared/types/common';

interface IUser {
  firstName: string;
  lastName: string;
  email: string;
  _id: Types.ObjectId;
}

// Base Team Interface (Clean & concise)
export interface ITeamBase {
  name: string;
  description: string;
  members: Types.ObjectId[];
  lead: Types.ObjectId;
  companyId: Types.ObjectId;
}

// Complete Team Interface with audit fields
export interface ITeam extends ITeamBase, AuditFields {}

// Mongoose Document
export interface ITeamDoc extends ITeam, Document {}

// Mongoose Model
export interface ITeamModel extends IPaginateModel<ITeamDoc> {
  isTeamNameTaken(name: string): Promise<boolean>;
}

export interface ITeamPopulated extends Omit<ITeamBase, 'members' | 'lead'> {
  members: IUser[];
  lead: IUser | null;
}

// DTOs
export type NewCreatedTeam = ITeamBase &
  Partial<Pick<AuditFields, 'createdBy' | 'updatedBy'>>;
export type UpdateTeamBody = Partial<ITeam>;
