feat: 회사 관리 API 연동 완료
- CompanyListController 생성 (ChangeNotifier 패턴) - CompanyListRedesign 화면 Provider 패턴으로 변경 - 무한 스크롤 및 실시간 검색 기능 구현 (디바운싱 적용) - 중복 회사명 체크 API 연동 - 지점 저장 로직 API 연동 (saveBranch 메서드 추가) - 에러 처리 및 로딩 상태 UI 구현 - API 통합 계획 문서 업데이트 (회사 관리 100% 완료)
This commit is contained in:
@@ -201,7 +201,42 @@ class _CompanyFormScreenState extends State<CompanyFormScreen> {
|
||||
|
||||
// 회사 저장
|
||||
Future<void> _saveCompany() async {
|
||||
final duplicateCompany = _controller.checkDuplicateCompany();
|
||||
// 지점 수정 모드일 때의 처리
|
||||
if (isBranch && branchId != null) {
|
||||
// 로딩 표시
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
|
||||
try {
|
||||
final success = await _controller.saveBranch(branchId!);
|
||||
if (mounted) {
|
||||
Navigator.pop(context); // 로딩 다이얼로그 닫기
|
||||
if (success) {
|
||||
Navigator.pop(context, true);
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('지점 저장에 실패했습니다.')),
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
Navigator.pop(context); // 로딩 다이얼로그 닫기
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('오류가 발생했습니다: $e')),
|
||||
);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 기존 회사 저장 로직
|
||||
final duplicateCompany = await _controller.checkDuplicateCompany();
|
||||
if (duplicateCompany != null) {
|
||||
DuplicateCompanyDialog.show(context, duplicateCompany);
|
||||
return;
|
||||
@@ -256,15 +291,44 @@ class _CompanyFormScreenState extends State<CompanyFormScreen> {
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Form(
|
||||
key: _controller.formKey,
|
||||
child: BranchFormWidget(
|
||||
controller: _controller.branchControllers[0],
|
||||
index: 0,
|
||||
onRemove: null,
|
||||
onAddressChanged: (address) {
|
||||
setState(() {
|
||||
_controller.updateBranchAddress(0, address);
|
||||
});
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: BranchFormWidget(
|
||||
controller: _controller.branchControllers[0],
|
||||
index: 0,
|
||||
onRemove: null,
|
||||
onAddressChanged: (address) {
|
||||
setState(() {
|
||||
_controller.updateBranchAddress(0, address);
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
// 저장 버튼
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 16.0),
|
||||
child: ElevatedButton(
|
||||
onPressed: _saveCompany,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppThemeTailwind.primary,
|
||||
minimumSize: const Size.fromHeight(48),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child: const Text(
|
||||
'수정 완료',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user