import { ChangeDetectionStrategy, Component, input } from '@angular/core';
import { SkeletonLoaderDirective } from '@isa/ui/skeleton-loader';

/**
 * Displays and computes stock information for a product.
 *
 * ## Inputs
 * - `availableStock`: Current available stock after removals.
 * - `stockToRemit`: Remission quantity.
 * - `targetStock`: Remaining stock after predefined return.
 * - `zob`: Min Stock Category Management Information (from InStock Request, maps to `stockInfo.minStockCategoryManagement`).
 *
 * @remarks
 * Implements OnPush change detection for performance.
 */
@Component({
  selector: 'remi-product-stock-info',
  templateUrl: './product-stock-info.component.html',
  styleUrls: ['./product-stock-info.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [SkeletonLoaderDirective],
})
export class ProductStockInfoComponent {
  /**
   * InputSignal indicating whether the stock information is currently being fetched.
   * Used to show loading states in the UI.
   * @default false
   *
   */
  stockFetching = input<boolean>(false);

  /**
   * Current available stock after removals.
   */
  availableStock = input<number>(0);

  /**
   * Remission quantity.
   */
  stockToRemit = input<number>(0);

  /**
   * Remaining stock after predefined return.
   */
  targetStock = input<number>(0);

  /**
   * Min Stock Category Management Information.
   * (InStock Request) → stockInfo.minStockCategoryManagement
   */
  zob = input<number>(0);
}
