import { Injectable } from '@nestjs/common';
import {
  EventTopics,
  columnUniques,
  validateRelations,
} from 'src/core/strings/constants/interface.constants';
import { SeasonPeriodEntity } from '../../entities/season-period.entity';
import { SeasonPeriodModel } from '../../../data/models/season-period.model';
import { BaseCreateManager } from 'src/core/modules/domain/usecase/managers/base-create.manager';
import { SeasonPeriodCreatedEvent } from '../../entities/event/season-period-created.event';
import { ValidateSeasonPeriodHelper } from './helpers/validate.helper';

@Injectable()
export class CreateSeasonPeriodManager extends BaseCreateManager<SeasonPeriodEntity> {
  async beforeProcess(): Promise<void> {
    const priority = await ValidateSeasonPeriodHelper(
      this.dataService,
      this.data,
    );

    Object.assign(this.data, {
      priority: priority,
    });
    return;
  }

  async afterProcess(): Promise<void> {
    return;
  }

  get validateRelations(): validateRelations[] {
    return [];
  }

  get uniqueColumns(): columnUniques[] {
    return [];
  }

  get eventTopics(): EventTopics[] {
    return [
      {
        topic: SeasonPeriodCreatedEvent,
        data: {
          id: this.result.id,
          ...this.data,
        },
      },
    ];
  }

  get entityTarget(): any {
    return SeasonPeriodModel;
  }
}
