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

@Injectable()
export class UpdateSeasonPeriodManager extends BaseUpdateManager<SeasonPeriodEntity> {
  async validateProcess(): Promise<void> {
    if (!this.data.isUpdatePrice) {
      const priority = await ValidateSeasonPeriodHelper(
        this.dataService,
        this.data,
      );

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

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

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

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

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

  get entityTarget(): any {
    return SeasonPeriodModel;
  }

  get eventTopics(): EventTopics[] {
    return [
      {
        topic: SeasonPeriodUpdatedEvent,
        relations: ['season_type'],
      },
    ];
  }
}
