import { BaseBatchDeleteManager } from 'src/core/modules/domain/usecase/managers/base-batch-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';
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
import { Injectable } from '@nestjs/common';

@Injectable()
export class BatchDeleteTimeGroupManager extends BaseBatchDeleteManager<TimeGroupEntity> {
  async beforeProcess(): Promise<void> {
    return;
  }

  async validateData(data: TimeGroupEntity): 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,
      },
    ];
  }

  getResult(): BatchResult {
    return this.result;
  }
}
