refactor: 회사 폼 UI 개선 및 코드 정리
- 담당자 연락처 필드를 드롭다운 + 입력 방식으로 분리 - 사용자 폼과 동일한 전화번호 UI 패턴 적용 - 미사용 위젯 파일 4개 정리 (branch_card, contact_info_* 등) - 파일명 통일성 확보 (branch_edit_screen → branch_form, company_form_simplified → company_form) - 네이밍 일관성 개선으로 유지보수성 향상
This commit is contained in:
@@ -62,6 +62,8 @@ class CompanyService {
|
||||
contactPhone: company.contactPhone ?? '',
|
||||
contactEmail: company.contactEmail ?? '',
|
||||
companyTypes: company.companyTypes.map((e) => e.toString().split('.').last).toList(),
|
||||
isPartner: company.isPartner,
|
||||
isCustomer: company.isCustomer,
|
||||
remark: company.remark,
|
||||
);
|
||||
|
||||
@@ -117,6 +119,8 @@ class CompanyService {
|
||||
contactPhone: company.contactPhone,
|
||||
contactEmail: company.contactEmail,
|
||||
companyTypes: company.companyTypes.map((e) => e.toString().split('.').last).toList(),
|
||||
isPartner: company.isPartner,
|
||||
isCustomer: company.isCustomer,
|
||||
remark: company.remark,
|
||||
);
|
||||
|
||||
@@ -374,8 +378,16 @@ class CompanyService {
|
||||
name: dto.name,
|
||||
address: Address.fromFullAddress(dto.address ?? ''),
|
||||
contactName: dto.contactName,
|
||||
contactPosition: null, // CompanyListDto에는 position이 없음
|
||||
contactPhone: dto.contactPhone,
|
||||
contactEmail: dto.contactEmail,
|
||||
companyTypes: companyTypes,
|
||||
remark: null, // CompanyListDto에는 remark이 없음
|
||||
isActive: dto.isActive,
|
||||
isPartner: dto.isPartner,
|
||||
isCustomer: dto.isCustomer,
|
||||
createdAt: dto.createdAt,
|
||||
updatedAt: null, // CompanyListDto에는 updatedAt이 없음
|
||||
branches: [], // branches는 빈 배열로 초기화
|
||||
);
|
||||
}
|
||||
@@ -386,8 +398,11 @@ class CompanyService {
|
||||
// 1. company_types 필드가 있으면 우선 사용 (하위 호환성)
|
||||
if (dto.companyTypes.isNotEmpty) {
|
||||
companyTypes = dto.companyTypes.map((typeStr) {
|
||||
if (typeStr.toLowerCase().contains('partner')) return CompanyType.partner;
|
||||
return CompanyType.customer;
|
||||
final normalized = typeStr.toLowerCase();
|
||||
if (normalized.contains('partner')) return CompanyType.partner;
|
||||
if (normalized.contains('customer')) return CompanyType.customer;
|
||||
if (normalized == 'other') return CompanyType.customer; // "Other"는 고객사로 매핑
|
||||
return CompanyType.customer; // 기본값
|
||||
}).toSet().toList(); // 중복 제거
|
||||
}
|
||||
// 2. company_types가 없으면 is_partner, is_customer 사용
|
||||
@@ -401,13 +416,18 @@ class CompanyService {
|
||||
return Company(
|
||||
id: dto.id,
|
||||
name: dto.name,
|
||||
address: Address.fromFullAddress(dto.address),
|
||||
address: dto.address != null ? Address.fromFullAddress(dto.address!) : const Address(),
|
||||
contactName: dto.contactName,
|
||||
contactPosition: dto.contactPosition,
|
||||
contactPhone: dto.contactPhone,
|
||||
contactEmail: dto.contactEmail,
|
||||
companyTypes: companyTypes,
|
||||
remark: dto.remark,
|
||||
isActive: dto.isActive,
|
||||
isPartner: dto.isPartner,
|
||||
isCustomer: dto.isCustomer,
|
||||
createdAt: dto.createdAt,
|
||||
updatedAt: dto.updatedAt,
|
||||
branches: [], // branches는 빈 배열로 초기화
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import 'package:superport/core/errors/failures.dart';
|
||||
import 'package:superport/data/datasources/remote/warehouse_remote_datasource.dart';
|
||||
import 'package:superport/data/models/common/paginated_response.dart';
|
||||
import 'package:superport/data/models/warehouse/warehouse_dto.dart';
|
||||
import 'package:superport/models/address_model.dart';
|
||||
import 'package:superport/models/warehouse_location_model.dart';
|
||||
|
||||
@lazySingleton
|
||||
@@ -66,10 +65,10 @@ class WarehouseService {
|
||||
try {
|
||||
final request = CreateWarehouseLocationRequest(
|
||||
name: location.name,
|
||||
address: location.address.detailAddress,
|
||||
city: location.address.region,
|
||||
postalCode: location.address.zipCode,
|
||||
country: 'KR', // 기본값
|
||||
address: location.address, // 단일 문자열 주소
|
||||
managerName: location.managerName,
|
||||
managerPhone: location.managerPhone,
|
||||
capacity: location.capacity,
|
||||
remark: location.remark,
|
||||
);
|
||||
|
||||
@@ -87,10 +86,10 @@ class WarehouseService {
|
||||
try {
|
||||
final request = UpdateWarehouseLocationRequest(
|
||||
name: location.name,
|
||||
address: location.address.detailAddress,
|
||||
city: location.address.region,
|
||||
postalCode: location.address.zipCode,
|
||||
country: 'KR', // country 필드 추가
|
||||
address: location.address, // 단일 문자열 주소
|
||||
managerName: location.managerName,
|
||||
managerPhone: location.managerPhone,
|
||||
capacity: location.capacity,
|
||||
remark: location.remark,
|
||||
);
|
||||
|
||||
@@ -167,32 +166,18 @@ class WarehouseService {
|
||||
}
|
||||
}
|
||||
|
||||
// DTO를 Flutter 모델로 변환
|
||||
// DTO를 Flutter 모델로 변환 (백엔드 API 호환)
|
||||
WarehouseLocation _convertDtoToWarehouseLocation(WarehouseLocationDto dto) {
|
||||
// API에 주소 정보가 없으므로 기본값 사용
|
||||
final address = Address(
|
||||
zipCode: dto.postalCode ?? '',
|
||||
region: dto.city ?? '',
|
||||
detailAddress: dto.address ?? '주소 정보 없음',
|
||||
);
|
||||
|
||||
// 담당자 정보 조합
|
||||
final remarkParts = <String>[];
|
||||
if (dto.code != null) {
|
||||
remarkParts.add('코드: ${dto.code}');
|
||||
}
|
||||
if (dto.managerName != null) {
|
||||
remarkParts.add('담당자: ${dto.managerName}');
|
||||
}
|
||||
if (dto.managerPhone != null) {
|
||||
remarkParts.add('연락처: ${dto.managerPhone}');
|
||||
}
|
||||
|
||||
return WarehouseLocation(
|
||||
id: dto.id,
|
||||
name: dto.name,
|
||||
address: address,
|
||||
remark: remarkParts.isNotEmpty ? remarkParts.join(', ') : null,
|
||||
address: dto.address, // 단일 문자열 주소
|
||||
managerName: dto.managerName,
|
||||
managerPhone: dto.managerPhone,
|
||||
capacity: dto.capacity,
|
||||
remark: dto.remark,
|
||||
isActive: dto.isActive,
|
||||
createdAt: dto.createdAt,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user