import { Injectable } from '@nestjs/common';
import { BaseDeleteManager } from 'src/core/modules/domain/usecase/managers/base-delete.manager';
import { TimeGroupEntity } from '../../entities/time-group.entity';
import {
  EventTopics,
  validateRelations,
} from 'src/core/strings/constants/interface.constants';
import { TimeGroupModel } from '../../../data/models/time-group.model';
import { TimeGroupDeletedEvent } from '../../entities/event/time-group-deleted.event';

@Injectable()
export class DeleteTimeGroupManager extends BaseDeleteManager<TimeGroupEntity> {
  getResult(): string {
    return `Success`;
  }

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

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

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

  get validateRelations(): validateRelations[] {
    return [
      {
        relation: 'items',
        message:
          'Gagal! tidak dapat menghapus time group karena sudah berelasi dengan item',
      },
    ];
  }

  get entityTarget(): any {
    return TimeGroupModel;
  }

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