diff --git a/lib/function/device_checkout_ledger_controller.dart b/lib/function/device_checkout_ledger_controller.dart index 3184651..d66237a 100644 --- a/lib/function/device_checkout_ledger_controller.dart +++ b/lib/function/device_checkout_ledger_controller.dart @@ -67,6 +67,11 @@ class DeviceCheckoutLedgerController extends ChangeNotifier { return _postAction('/api/device-checkout/reject', {"requestId": requestId}); } + // πŸ–οΈ [ν•˜λ“œμ›¨μ–΄ μžλ™ 감지 μ „κΉŒμ§€ μž„μ‹œ] μ„ μƒλ‹˜μ΄ κΈ°κΈ°λ₯Ό μ‹€μ œλ‘œ λŒλ €λ°›μ•˜μ„ λ•Œ λˆ„λ₯΄λŠ” λ²„νŠΌ. + Future<(bool success, String message)> confirmReturn(int requestId) async { + return _postAction('/api/device-checkout/return', {"requestId": requestId}); + } + Future<(bool success, String message)> _postAction( String path, Map body, diff --git a/lib/ui/device_checkout_ledger_page.dart b/lib/ui/device_checkout_ledger_page.dart index d4d8597..f2401e5 100644 --- a/lib/ui/device_checkout_ledger_page.dart +++ b/lib/ui/device_checkout_ledger_page.dart @@ -50,12 +50,23 @@ class _DeviceCheckoutLedgerPageState extends State { ).showSnackBar(SnackBar(content: Text(message))); } + // πŸ–οΈ [ν•˜λ“œμ›¨μ–΄ μžλ™ 감지 μ „κΉŒμ§€ μž„μ‹œ] κΈ°κΈ°λ₯Ό μ‹€μ œλ‘œ λŒλ €λ°›μ•˜μ„ λ•Œ λˆ„λ₯΄λŠ” λ²„νŠΌ. + Future _confirmReturn(int id) async { + final (_, message) = await _controller.confirmReturn(id); + if (!mounted) return; + ScaffoldMessenger.of( + context, + ).showSnackBar(SnackBar(content: Text(message))); + } + ({Color color, String label}) _statusInfo(String status) { switch (status) { case 'PENDING': return (color: Colors.orange, label: '⏳ λŒ€κΈ°μ€‘'); case 'APPROVED': return (color: Colors.blue, label: 'βœ… 승인됨'); + case 'RETURNED': + return (color: Colors.grey, label: '↩️ λ°˜λ‚©μ™„λ£Œ'); case 'REJECTED': return (color: Colors.red, label: '🚫 거절됨'); default: @@ -262,6 +273,31 @@ class _DeviceCheckoutLedgerPageState extends State { ], ), ], + if (status == 'APPROVED') ...[ + const SizedBox(height: 12), + SizedBox( + width: double.infinity, + child: OutlinedButton.icon( + onPressed: _controller.isWorking + ? null + : () => + _confirmReturn(r['id']), + style: OutlinedButton.styleFrom( + foregroundColor: + Colors.grey[800], + side: BorderSide( + color: Colors.grey[400]!, + ), + ), + icon: const Icon( + Icons + .assignment_turned_in_outlined, + size: 18, + ), + label: const Text('κΈ°κΈ° λ°˜λ‚© 확인'), + ), + ), + ], ], ), ),