| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- import 'package:flutter_riverpod/flutter_riverpod.dart';
- import '../../app.dart';
- class HomeSummary {
- final int expensePending;
- final int overtimePending;
- final int vehiclePending;
- final int logCount;
- final int announcementCount;
- final int announcementUnread;
- final int totalCount;
- const HomeSummary({
- required this.expensePending,
- required this.overtimePending,
- required this.vehiclePending,
- required this.logCount,
- required this.announcementCount,
- this.announcementUnread = 0,
- required this.totalCount,
- });
- factory HomeSummary.fromJson(dynamic json) {
- final map = json as Map<String, dynamic>;
- return HomeSummary(
- expensePending: map['expensePending'] as int? ?? 0,
- overtimePending: map['overtimePending'] as int? ?? 0,
- vehiclePending: map['vehiclePending'] as int? ?? 0,
- logCount: map['logCount'] as int? ?? 0,
- announcementCount: map['announcementCount'] as int? ?? 0,
- announcementUnread: map['announcementUnread'] as int? ?? 0,
- totalCount: map['totalCount'] as int? ?? 0,
- );
- }
- }
- final homeSummaryProvider = FutureProvider<HomeSummary>((ref) async {
- final client = ref.read(apiClientProvider);
- final response =
- await client.get('/home/summary', fromJsonT: HomeSummary.fromJson);
- return response.data!;
- });
|