Phase 3: hide mitra force-close (Akhiri) button in active sessions

Removes the Akhiri button + confirmation dialog + _endSession from the
mitra active sessions screen. Backend POST .../end-early route and the
early_end_mitra_enabled config flag are preserved — re-enable plan lives
in requirement/phase3.6.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-27 13:44:12 +08:00
parent fa7071def5
commit 3a7378d246

View File

@@ -33,34 +33,6 @@ class _ActiveSessionsScreenState extends ConsumerState<ActiveSessionsScreen> {
} }
} }
Future<void> _endSession(String sessionId) async {
final confirmed = await showDialog<bool>(
context: context,
builder: (ctx) => AlertDialog(
title: const Text('Akhiri Sesi?'),
content: const Text('Apakah kamu yakin ingin mengakhiri sesi ini?'),
actions: [
TextButton(onPressed: () => Navigator.of(ctx).pop(false), child: const Text('Batal')),
TextButton(onPressed: () => Navigator.of(ctx).pop(true), child: const Text('Ya, Akhiri')),
],
),
);
if (confirmed == true) {
try {
final apiClient = ref.read(apiClientProvider);
await apiClient.post('/api/mitra/chat-requests/sessions/$sessionId/end');
_loadSessions();
} catch (_) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Gagal mengakhiri sesi.')),
);
}
}
}
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@@ -78,10 +50,7 @@ class _ActiveSessionsScreenState extends ConsumerState<ActiveSessionsScreen> {
leading: const Icon(Icons.chat), leading: const Icon(Icons.chat),
title: Text(customerName), title: Text(customerName),
subtitle: Text('Status: ${session['status']}'), subtitle: Text('Status: ${session['status']}'),
trailing: TextButton( trailing: const Icon(Icons.chevron_right),
onPressed: () => _endSession(session['id'] as String),
child: const Text('Akhiri', style: TextStyle(color: Colors.red)),
),
onTap: () => context.push( onTap: () => context.push(
'/chat/session/${session['id']}', '/chat/session/${session['id']}',
extra: {'customerName': customerName}, extra: {'customerName': customerName},