import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
import { ItemEntity } from '../../entities/item.entity';
import {
  EventTopics,
  validateRelations,
} from 'src/core/strings/constants/interface.constants';
import { ItemModel } from '../../../data/models/item.model';
import { ItemChangeStatusEvent } from '../../entities/event/item-change-status.event';
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
import { Injectable } from '@nestjs/common';
import { STATUS } from 'src/core/strings/constants/base.constants';

@Injectable()
export class BatchActiveItemManager extends BaseBatchUpdateStatusManager<ItemEntity> {
  validateData(data: ItemEntity): Promise<void> {
    return;
  }

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

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

  get validateRelations(): validateRelations[] {
    return [
      {
        relation: 'tenant',
        singleQuery: ['status', '!=', STATUS.ACTIVE],
        message: `Gagal! tenant tidak aktif`,
      },
      {
        relation: 'bundling_items',
        singleQuery: ['status', '!=', STATUS.ACTIVE],
        message: `Gagal! Terdapat item yang belum aktif`,
      },
    ];
  }

  get entityTarget(): any {
    return ItemModel;
  }

  get eventTopics(): EventTopics[] {
    return [
      {
        topic: ItemChangeStatusEvent,
      },
    ];
  }

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