import { Column, Entity, PrimaryColumn } from 'typeorm';

@Entity({ name: 'racing_teams' })
export class TeamOrmEntity {
  @PrimaryColumn({ type: 'uuid' })
  id!: string;

  @Column({ type: 'text' })
  name!: string;

  @Column({ type: 'text' })
  tag!: string;

  @Column({ type: 'text' })
  description!: string;

  @Column({ type: 'uuid' })
  ownerId!: string;

  @Column({ type: 'uuid', array: true })
  leagues!: string[];

  @Column({ type: 'text', nullable: true })
  category!: string | null;

  @Column({ type: 'boolean', default: false })
  isRecruiting!: boolean;

  @Column({ type: 'timestamptz' })
  createdAt!: Date;

  @Column({ type: 'jsonb', nullable: true })
  logoRef!: Record<string, unknown> | null;
}

@Entity({ name: 'racing_team_memberships' })
export class TeamMembershipOrmEntity {
  @PrimaryColumn({ type: 'uuid' })
  teamId!: string;

  @PrimaryColumn({ type: 'uuid' })
  driverId!: string;

  @Column({ type: 'text' })
  role!: string;

  @Column({ type: 'text' })
  status!: string;

  @Column({ type: 'timestamptz' })
  joinedAt!: Date;
}

@Entity({ name: 'racing_team_join_requests' })
export class TeamJoinRequestOrmEntity {
  @PrimaryColumn({ type: 'text' })
  id!: string;

  @Column({ type: 'uuid' })
  teamId!: string;

  @Column({ type: 'uuid' })
  driverId!: string;

  @Column({ type: 'timestamptz' })
  requestedAt!: Date;

  @Column({ type: 'text', nullable: true })
  message!: string | null;
}