import 'package:flutter/material.dart';
import 'package:superport/utils/constants.dart';

// 장비 상태에 따라 칩(Chip) 위젯을 반환하는 함수형 위젯
class EquipmentStatusChip extends StatelessWidget {
  final String status;

  const EquipmentStatusChip({super.key, required this.status});

  @override
  Widget build(BuildContext context) {
    // 상태별 칩 색상 및 텍스트 지정
    Color backgroundColor;
    String statusText;

    switch (status) {
      case EquipmentStatus.in_:
        backgroundColor = Colors.green;
        statusText = '입고';
        break;
      case EquipmentStatus.out:
        backgroundColor = Colors.orange;
        statusText = '출고';
        break;
      case EquipmentStatus.rent:
        backgroundColor = Colors.blue;
        statusText = '대여';
        break;
      case EquipmentStatus.repair:
        backgroundColor = Colors.blue;
        statusText = '수리중';
        break;
      case EquipmentStatus.damaged:
        backgroundColor = Colors.red;
        statusText = '손상';
        break;
      case EquipmentStatus.lost:
        backgroundColor = Colors.purple;
        statusText = '분실';
        break;
      case EquipmentStatus.etc:
        backgroundColor = Colors.grey;
        statusText = '기타';
        break;
      default:
        backgroundColor = Colors.grey;
        statusText = '알 수 없음';
    }

    // 칩 위젯 반환
    return Chip(
      label: Text(
        statusText,
        style: const TextStyle(color: Colors.white, fontSize: 12),
      ),
      backgroundColor: backgroundColor,
      visualDensity: VisualDensity.compact,
      padding: const EdgeInsets.symmetric(horizontal: 5),
    );
  }
}
