ADD ALOT OF POLISHING AND UPDATES...
This commit is contained in:
@@ -5,6 +5,7 @@ import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import '../../app/injection_container.dart';
|
||||
import '../../core/errors/friendly_error.dart';
|
||||
import '../../core/network/api_client.dart';
|
||||
import '../../core/theme/app_colors.dart';
|
||||
|
||||
@@ -44,26 +45,22 @@ class _ActivityLogScreenState extends State<ActivityLogScreen> {
|
||||
_loading = true;
|
||||
_error = null;
|
||||
});
|
||||
try {
|
||||
final res = await _api
|
||||
.get('/user/activity-logs')
|
||||
.timeout(const Duration(seconds: 10));
|
||||
final list = _extractList(res.data);
|
||||
final items = list.map(_LogItem.fromJson).toList();
|
||||
setState(() {
|
||||
_items = items;
|
||||
_applyFilter(_selectedFilter);
|
||||
});
|
||||
} on DioException catch (e) {
|
||||
setState(() {
|
||||
_error = e.response?.data?['message']?.toString() ??
|
||||
'Gagal memuat activity log.';
|
||||
});
|
||||
} catch (e) {
|
||||
setState(() => _error = 'Timeout / error: $e');
|
||||
} finally {
|
||||
if (mounted) setState(() => _loading = false);
|
||||
}
|
||||
await runFriendlyAction(
|
||||
() async {
|
||||
final res = await _api
|
||||
.get('/user/activity-logs')
|
||||
.timeout(const Duration(seconds: 10));
|
||||
final list = _extractList(res.data);
|
||||
final items = list.map(_LogItem.fromJson).toList();
|
||||
setState(() {
|
||||
_items = items;
|
||||
_applyFilter(_selectedFilter);
|
||||
});
|
||||
},
|
||||
onError: (message) => setState(() => _error = message),
|
||||
fallback: 'Gagal memuat activity log. Coba refresh lagi.',
|
||||
);
|
||||
if (mounted) setState(() => _loading = false);
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> _extractList(dynamic responseBody) {
|
||||
|
||||
Reference in New Issue
Block a user