jServicesOfClient function
- @Riverpod(keepAlive: true)
- Ref<
Object?> ref, - ClientService clientService
Return ServiceOfJournal grouped by type for ClientService.
Implementation
@Riverpod(keepAlive: true)
Map<ServiceState, List<ServiceOfJournal>> jServicesOfClient(
Ref ref,
ClientService clientService,
// AppState archive,
) {
// if (archive.isArchive) {
//
// } else {
final journal = ref.watch(journalProvider(clientService.apiKey));
final groups = ref.watch(servicesOfJournalProvider(journal));
final res = groups.map(
(key, value) => MapEntry(
key,
value
.where((e) =>
e.contractId == clientService.contractId &&
e.servId == clientService.servId)
.toList(growable: false),
),
);
// make sure it is not contains null
ServiceState.values.forEach((state) {
if (!res.containsKey(state)) {
res[state] = [];
}
});
return res;
}