backup: 사용하지 않는 파일 삭제 전 복구 지점
- 전체 371개 파일 중 82개 미사용 파일 식별 - Phase 1: 33개 파일 삭제 예정 (100% 안전) - Phase 2: 30개 파일 삭제 검토 예정 - Phase 3: 19개 파일 수동 검토 예정 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
|
||||
import '../../data/models/rent_dto.dart';
|
||||
import '../equipment/controllers/equipment_history_controller.dart';
|
||||
|
||||
class RentFormDialog extends StatefulWidget {
|
||||
final RentDto? rent;
|
||||
@@ -19,6 +21,7 @@ class RentFormDialog extends StatefulWidget {
|
||||
|
||||
class _RentFormDialogState extends State<RentFormDialog> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
late final EquipmentHistoryController _historyController;
|
||||
|
||||
// 백엔드 스키마에 맞는 필드만 유지
|
||||
int? _selectedEquipmentHistoryId;
|
||||
@@ -26,13 +29,43 @@ class _RentFormDialogState extends State<RentFormDialog> {
|
||||
DateTime? _endDate;
|
||||
|
||||
bool _isLoading = false;
|
||||
bool _isLoadingHistories = false;
|
||||
String? _historiesError;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_historyController = GetIt.instance<EquipmentHistoryController>();
|
||||
|
||||
if (widget.rent != null) {
|
||||
_initializeForm(widget.rent!);
|
||||
}
|
||||
|
||||
_loadEquipmentHistories();
|
||||
}
|
||||
|
||||
Future<void> _loadEquipmentHistories() async {
|
||||
setState(() {
|
||||
_isLoadingHistories = true;
|
||||
_historiesError = null; // 오류 상태 초기화
|
||||
});
|
||||
|
||||
try {
|
||||
await _historyController.loadHistory();
|
||||
setState(() => _historiesError = null); // 성공 시 오류 상태 클리어
|
||||
} catch (e) {
|
||||
debugPrint('장비 이력 로딩 실패: $e');
|
||||
setState(() => _historiesError = '장비 이력을 불러오는 중 오류가 발생했습니다: ${e.toString()}');
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() => _isLoadingHistories = false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 재시도 기능 추가 (UserForm 패턴과 동일)
|
||||
void _retryLoadHistories() {
|
||||
_loadEquipmentHistories();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -132,26 +165,109 @@ class _RentFormDialogState extends State<RentFormDialog> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 장비 이력 ID (백엔드 필수 필드)
|
||||
TextFormField(
|
||||
decoration: const InputDecoration(
|
||||
labelText: '장비 이력 ID *',
|
||||
border: OutlineInputBorder(),
|
||||
helperText: '임대할 장비의 이력 ID를 입력하세요',
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return '장비 이력 ID는 필수입니다';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
onChanged: (value) {
|
||||
_selectedEquipmentHistoryId = int.tryParse(value);
|
||||
},
|
||||
initialValue: _selectedEquipmentHistoryId?.toString(),
|
||||
),
|
||||
// 장비 이력 선택 (백엔드 필수 필드)
|
||||
Text('장비 선택 *', style: Theme.of(context).textTheme.titleMedium),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// 3단계 상태 처리 (UserForm 패턴 적용)
|
||||
_isLoadingHistories
|
||||
? const SizedBox(
|
||||
height: 56,
|
||||
child: Center(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
ShadProgress(),
|
||||
SizedBox(width: 8),
|
||||
Text('장비 이력을 불러오는 중...'),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
// 오류 발생 시 오류 컨테이너 표시
|
||||
: _historiesError != null
|
||||
? Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red.shade50,
|
||||
border: Border.all(color: Colors.red.shade200),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.error, color: Colors.red.shade600, size: 20),
|
||||
const SizedBox(width: 8),
|
||||
const Text('장비 이력 로딩 실패', style: TextStyle(fontWeight: FontWeight.w500)),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
_historiesError!,
|
||||
style: TextStyle(color: Colors.red.shade700, fontSize: 14),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
ShadButton(
|
||||
onPressed: _retryLoadHistories,
|
||||
child: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.refresh, size: 16),
|
||||
SizedBox(width: 4),
|
||||
Text('다시 시도'),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
// 정상 상태: 드롭다운 표시
|
||||
: ShadSelect<int>(
|
||||
placeholder: const Text('장비를 선택하세요'),
|
||||
options: _historyController.historyList.map((history) {
|
||||
return ShadOption(
|
||||
value: history.id!,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'${history.equipment?.serialNumber ?? "Serial N/A"} - ${history.equipment?.modelName ?? "Model N/A"}',
|
||||
style: const TextStyle(fontWeight: FontWeight.w500),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
Text(
|
||||
'거래: ${history.transactionType} | 수량: ${history.quantity} | ${history.transactedAt.toString().split(' ')[0]}',
|
||||
style: const TextStyle(fontSize: 12, color: Colors.grey),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
selectedOptionBuilder: (context, value) {
|
||||
final selectedHistory = _historyController.historyList
|
||||
.firstWhere((h) => h.id == value);
|
||||
return Text(
|
||||
'${selectedHistory.equipment?.serialNumber ?? "Serial N/A"} - ${selectedHistory.equipment?.modelName ?? "Model N/A"}',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
);
|
||||
},
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_selectedEquipmentHistoryId = value;
|
||||
});
|
||||
},
|
||||
initialValue: _selectedEquipmentHistoryId,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// 임대 기간 (백엔드 필수 필드)
|
||||
|
||||
Reference in New Issue
Block a user