import 'package:flutter/material.dart';
import 'package:superport/screens/company/widgets/contact_info_widget.dart';

/// 담당자 정보 폼
///
/// 회사 등록 및 수정 화면에서 사용되는 담당자 정보 입력 폼
/// 내부적으로 공통 ContactInfoWidget을 사용하여 코드 재사용성 확보
class ContactInfoForm extends StatelessWidget {
  final TextEditingController contactNameController;
  final TextEditingController contactPositionController;
  final TextEditingController contactPhoneController;
  final TextEditingController contactEmailController;
  final List<String> positions;
  final String selectedPhonePrefix;
  final List<String> phonePrefixes;
  final ValueChanged<String> onPhonePrefixChanged;
  final ValueChanged<String?> onNameSaved;
  final ValueChanged<String?> onPositionSaved;
  final ValueChanged<String?> onPhoneSaved;
  final ValueChanged<String?> onEmailSaved;

  const ContactInfoForm({
    Key? key,
    required this.contactNameController,
    required this.contactPositionController,
    required this.contactPhoneController,
    required this.contactEmailController,
    required this.positions,
    required this.selectedPhonePrefix,
    required this.phonePrefixes,
    required this.onPhonePrefixChanged,
    required this.onNameSaved,
    required this.onPositionSaved,
    required this.onPhoneSaved,
    required this.onEmailSaved,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    // ContactInfoWidget을 사용하여 담당자 정보 UI 구성
    return ContactInfoWidget(
      contactNameController: contactNameController,
      contactPositionController: contactPositionController,
      contactPhoneController: contactPhoneController,
      contactEmailController: contactEmailController,
      positions: positions,
      selectedPhonePrefix: selectedPhonePrefix,
      phonePrefixes: phonePrefixes,
      onPhonePrefixChanged: onPhonePrefixChanged,

      // 각 콜백 함수를 ContactInfoWidget의 onChanged 콜백과 연결
      onContactNameChanged: (value) => onNameSaved?.call(value),
      onContactPositionChanged: (value) => onPositionSaved?.call(value),
      onContactPhoneChanged: (value) => onPhoneSaved?.call(value),
      onContactEmailChanged: (value) => onEmailSaved?.call(value),
    );
  }
}
