feat: compelete bal pending screen
This commit is contained in:
parent
b12809ba93
commit
618764f513
4 changed files with 72 additions and 3 deletions
|
|
@ -50,6 +50,22 @@ class BalRepository {
|
|||
}
|
||||
}
|
||||
|
||||
bool isABalOngoing() {
|
||||
return _bals?.where((bal) => bal.state == BalState.ongoing).isNotEmpty ??
|
||||
false;
|
||||
}
|
||||
|
||||
Future<Result<Bal>> startBal(int id) async {
|
||||
if (isABalOngoing()) {
|
||||
return Result.error(
|
||||
Exception("Cannot have multiple BAL ongoing at the same time !"),
|
||||
);
|
||||
}
|
||||
final result = await _apiClient.startBal(id);
|
||||
_getBalsNoCache();
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<Result<Bal>> editBal(
|
||||
int id,
|
||||
String name,
|
||||
|
|
@ -57,13 +73,13 @@ class BalRepository {
|
|||
DateTime end,
|
||||
) async {
|
||||
final result = await _apiClient.editBal(id, name, start, end);
|
||||
_getBalsNoCache();
|
||||
await _getBalsNoCache();
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<Result<void>> addBal(String name, DateTime start, DateTime end) async {
|
||||
final result = await _apiClient.addBal(name, start, end);
|
||||
_getBalsNoCache();
|
||||
await _getBalsNoCache();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue