serviceState function Data Models
- Ref<
Object?> ref, - ClientService client
Model for ServiceCard and other widget.
This is mostly a view model for data from:
Implementation
@riverpod
ClientServiceState serviceState(Ref ref, ClientService client) {
final journal = ref.watch(journalProvider(client.apiKey));
final jServ = ref.watch(jServicesOfClientProvider(client));
return ClientServiceState(
client: client,
ref: ref,
isReadOnly: journal.state.isArchive,
added: jServ[ServiceState.added]!.length,
rejected: jServ[ServiceState.rejected]!.length,
left: client.plan -
client.filled -
jServ[ServiceState.added]!.length -
jServ[ServiceState.finished]!.length,
// but not outDated
done: jServ[ServiceState.finished]!.length +
jServ[ServiceState.outDated]!.length,
);
}