refactor: 회사 폼 UI 개선 및 코드 정리
- 담당자 연락처 필드를 드롭다운 + 입력 방식으로 분리 - 사용자 폼과 동일한 전화번호 UI 패턴 적용 - 미사용 위젯 파일 4개 정리 (branch_card, contact_info_* 등) - 파일명 통일성 확보 (branch_edit_screen → branch_form, company_form_simplified → company_form) - 네이밍 일관성 개선으로 유지보수성 향상
This commit is contained in:
@@ -15,6 +15,7 @@ import 'package:superport/models/company_model.dart';
|
||||
// import 'package:superport/services/mock_data_service.dart'; // Mock 서비스 제거
|
||||
import 'package:superport/services/company_service.dart';
|
||||
import 'package:superport/core/errors/failures.dart';
|
||||
import 'package:superport/utils/phone_utils.dart';
|
||||
import 'dart:async';
|
||||
import 'branch_form_controller.dart'; // 분리된 지점 컨트롤러 import
|
||||
|
||||
@@ -109,7 +110,10 @@ class CompanyFormController {
|
||||
|
||||
// 회사 데이터 로드 (수정 모드)
|
||||
Future<void> loadCompanyData() async {
|
||||
if (companyId == null) return;
|
||||
if (companyId == null) {
|
||||
debugPrint('❌ companyId가 null입니다');
|
||||
return;
|
||||
}
|
||||
|
||||
debugPrint('📝 loadCompanyData 시작 - ID: $companyId');
|
||||
|
||||
@@ -119,12 +123,18 @@ class CompanyFormController {
|
||||
if (_useApi) {
|
||||
debugPrint('📝 API에서 회사 정보 로드 중...');
|
||||
company = await _companyService.getCompanyDetail(companyId!);
|
||||
debugPrint('📝 API 응답 받음: ${company != null ? "성공" : "null"}');
|
||||
} else {
|
||||
debugPrint('📝 API만 사용 가능');
|
||||
throw Exception('API를 통해만 데이터를 로드할 수 있습니다');
|
||||
}
|
||||
|
||||
debugPrint('📝 로드된 회사: $company');
|
||||
debugPrint('📝 로드된 회사 정보:');
|
||||
debugPrint(' - ID: ${company?.id}');
|
||||
debugPrint(' - 이름: ${company?.name}');
|
||||
debugPrint(' - 담당자: ${company?.contactName}');
|
||||
debugPrint(' - 연락처: ${company?.contactPhone}');
|
||||
debugPrint(' - 이메일: ${company?.contactEmail}');
|
||||
|
||||
if (company != null) {
|
||||
// 폼 필드에 데이터 설정
|
||||
@@ -157,10 +167,12 @@ class CompanyFormController {
|
||||
company.contactPhone!,
|
||||
phonePrefixes,
|
||||
);
|
||||
debugPrint('📝 전화번호 설정: $selectedPhonePrefix-${contactPhoneController.text}');
|
||||
}
|
||||
|
||||
// 회사 유형 설정
|
||||
selectedCompanyTypes = company.companyTypes;
|
||||
selectedCompanyTypes = List.from(company.companyTypes);
|
||||
debugPrint('📝 회사 유형 설정: $selectedCompanyTypes');
|
||||
|
||||
// 지점 정보 설정
|
||||
if (company.branches != null && company.branches!.isNotEmpty) {
|
||||
@@ -174,16 +186,33 @@ class CompanyFormController {
|
||||
),
|
||||
);
|
||||
}
|
||||
debugPrint('📝 지점 설정 완료: ${branchControllers.length}개');
|
||||
}
|
||||
|
||||
debugPrint('📝 폼 필드 설정 완료:');
|
||||
debugPrint(' - 회사명: ${nameController.text}');
|
||||
debugPrint(' - 담당자: ${contactNameController.text}');
|
||||
debugPrint(' - 이메일: ${contactEmailController.text}');
|
||||
debugPrint(' - 회사명: "${nameController.text}"');
|
||||
debugPrint(' - 담당자: "${contactNameController.text}"');
|
||||
debugPrint(' - 이메일: "${contactEmailController.text}"');
|
||||
debugPrint(' - 전화번호: "$selectedPhonePrefix-${contactPhoneController.text}"');
|
||||
debugPrint(' - 지점 수: ${branchControllers.length}');
|
||||
debugPrint(' - 회사 유형: $selectedCompanyTypes');
|
||||
|
||||
// 강제로 TextEditingController 리스너 트리거
|
||||
nameController.notifyListeners();
|
||||
contactNameController.notifyListeners();
|
||||
contactPositionController.notifyListeners();
|
||||
contactEmailController.notifyListeners();
|
||||
contactPhoneController.notifyListeners();
|
||||
remarkController.notifyListeners();
|
||||
|
||||
debugPrint('✅ 폼 데이터 로드 완료');
|
||||
} else {
|
||||
debugPrint('❌ 회사 정보가 null입니다');
|
||||
}
|
||||
} catch (e) {
|
||||
} catch (e, stackTrace) {
|
||||
debugPrint('❌ 회사 정보 로드 실패: $e');
|
||||
debugPrint('❌ 스택 트레이스: $stackTrace');
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,6 +354,8 @@ class CompanyFormController {
|
||||
? null
|
||||
: branchControllers.map((c) => c.branch).toList(),
|
||||
companyTypes: List.from(selectedCompanyTypes), // 복수 유형 저장
|
||||
isPartner: selectedCompanyTypes.contains(CompanyType.partner),
|
||||
isCustomer: selectedCompanyTypes.contains(CompanyType.customer),
|
||||
);
|
||||
|
||||
if (_useApi) {
|
||||
|
||||
Reference in New Issue
Block a user