import { IsIn, IsInt, IsOptional } from 'class-validator';
import { TeamRolesEnum } from '../../team-roles/team-roles.enum';

const VALID_ROLES = [
  TeamRolesEnum.player,
  TeamRolesEnum.scnd_treasurer,
  TeamRolesEnum.captain,
  TeamRolesEnum.treasurer,
  TeamRolesEnum.coach,
];

export class UpdateTeamPermissionsDto {
  @IsOptional()
  @IsInt()
  @IsIn(VALID_ROLES)
  transactionCreateMinRole?: TeamRolesEnum;

  @IsOptional()
  @IsInt()
  @IsIn(VALID_ROLES)
  transactionReverseMinRole?: TeamRolesEnum;

  @IsOptional()
  @IsInt()
  @IsIn(VALID_ROLES)
  inviteMinRole?: TeamRolesEnum;

  @IsOptional()
  @IsInt()
  @IsIn(VALID_ROLES)
  memberManageMinRole?: TeamRolesEnum;

  @IsOptional()
  @IsInt()
  @IsIn(VALID_ROLES)
  penaltyManageMinRole?: TeamRolesEnum;

  @IsOptional()
  @IsInt()
  @IsIn(VALID_ROLES)
  publicAccessManageMinRole?: TeamRolesEnum;
}

export interface TeamPermissionsDto {
  transactionCreateMinRole: number;
  transactionReverseMinRole: number;
  inviteMinRole: number;
  memberManageMinRole: number;
  penaltyManageMinRole: number;
  publicAccessManageMinRole: number;
}
