import type { Visibility } from "@/core/module-registry/types";
import type { CompanyId } from "@/core/auth/types";

/** Default equipment types — user can add custom types dynamically */
export const DEFAULT_EQUIPMENT_TYPES = [
  "laptop",
  "desktop",
  "monitor",
  "printer",
  "phone",
  "tablet",
  "network",
  "peripheral",
  "server",
  "switch",
  "ups",
  "patch-panel",
  "other",
] as const;

/** Equipment type — string-based for dynamic types */
export type InventoryItemType =
  | (typeof DEFAULT_EQUIPMENT_TYPES)[number]
  | string;

/** Labels for default equipment types */
export const DEFAULT_TYPE_LABELS: Record<string, string> = {
  laptop: "Laptop",
  desktop: "Desktop",
  monitor: "Monitor",
  printer: "Imprimantă",
  phone: "Telefon",
  tablet: "Tabletă",
  network: "Rețea",
  peripheral: "Periferic",
  server: "Server",
  switch: "Switch",
  ups: "UPS",
  "patch-panel": "Patch Panel",
  other: "Altele",
};

/** Rack-mountable types that show rack position fields */
export const RACK_MOUNTABLE_TYPES = new Set([
  "server",
  "switch",
  "ups",
  "patch-panel",
  "network",
]);

export type InventoryItemStatus =
  | "active"
  | "in-repair"
  | "storage"
  | "rented"
  | "decommissioned";

export const STATUS_LABELS: Record<InventoryItemStatus, string> = {
  active: "Activ",
  "in-repair": "În reparație",
  storage: "Depozitat",
  rented: "Închiriat",
  decommissioned: "Dezafectat",
};

export interface InventoryItem {
  id: string;
  name: string;
  type: InventoryItemType;
  serialNumber: string;
  company: CompanyId;
  location: string;
  status: InventoryItemStatus;
  /** IP address */
  ipAddress: string;
  /** MAC address */
  macAddress: string;
  /** Rack unit start position (1-42) */
  rackPosition?: number;
  /** Size in rack units (1U, 2U, 4U) */
  rackSize?: number;
  /** Room / rack position label */
  rackLocation: string;
  /** Vendor / manufacturer */
  vendor: string;
  /** Model name/number */
  model: string;
  tags: string[];
  notes: string;
  visibility: Visibility;
  createdAt: string;
  updatedAt: string;
}
