import { Injectable } from '@nestjs/common';
import { BaseDetailManager } from 'src/core/modules/domain/usecase/managers/base-detail.manager';
import { ItemEntity } from '../../entities/item.entity';
import { RelationParam } from 'src/core/modules/domain/entities/base-filter.entity';

@Injectable()
export class DetailItemManager extends BaseDetailManager<ItemEntity> {
  async prepareData(): Promise<void> {
    return;
  }

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

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

  get relations(): RelationParam {
    return {
      // relation only join (for query purpose)
      joinRelations: [],

      // relation join and select (relasi yang ingin ditampilkan),
      selectRelations: [
        'item_category',
        'bundling_items',
        'bundling_items.time_group bundling_time_groups',
        'tenant',
        'time_group',
      ],

      // relation yang hanya ingin dihitung (akan return number)
      countRelations: [],
    };
  }

  get selects(): string[] {
    return [
      `${this.tableName}.id`,
      `${this.tableName}.image_url`,
      `${this.tableName}.video_url`,
      `${this.tableName}.created_at`,
      `${this.tableName}.status`,
      `${this.tableName}.item_type`,
      `${this.tableName}.name`,
      `${this.tableName}.limit_type`,
      `${this.tableName}.limit_value`,
      `${this.tableName}.hpp`,
      `${this.tableName}.sales_margin`,
      `${this.tableName}.share_profit`,
      `${this.tableName}.total_price`,
      `${this.tableName}.base_price`,
      `${this.tableName}.use_queue`,
      `${this.tableName}.usage_type`,
      `${this.tableName}.show_to_booking`,
      `${this.tableName}.breakdown_bundling`,
      `${this.tableName}.play_estimation`,
      `${this.tableName}.booking_description`,

      `item_category.id`,
      `item_category.name`,

      'bundling_items.id',
      'bundling_items.name',
      'bundling_items.hpp',
      'bundling_items.base_price',

      'bundling_time_groups.id',
      'bundling_time_groups.name',

      'tenant.id',
      'tenant.name',

      'time_group.id',
      'time_group.name',
    ];
  }

  get setFindProperties(): any {
    return {
      id: this.dataId,
    };
  }
}
