feat: made the ongoing screen... for now

This commit is contained in:
alzalia1 2025-08-14 11:19:06 +02:00
parent 099b20f805
commit e5a8745e0e
5 changed files with 119 additions and 2 deletions

View file

@ -42,6 +42,33 @@ class ApiClient {
* =================
*/
Future<Result<Bal>> stopBal(int id) async {
final client = Client();
try {
final headers = await _getHeaders();
final response = await client.post(
Uri.parse("https://$apiBasePath/bal/${id.toString()}/stop"),
headers: headers,
);
if (response.statusCode == 200) {
final json = jsonDecode(response.body);
return Result.ok(Bal.fromJSON(json));
} else if (response.statusCode == 403) {
throw "You don't own the specified BAL";
} else if (response.statusCode == 404) {
throw "No BAL with specified ID found";
} else if (response.statusCode == 409) {
throw "Selected BAL was not on ongoing state";
} else {
throw "Unknown error";
}
} catch (e) {
return Result.error(Exception(e));
} finally {
client.close();
}
}
Future<Result<Bal>> startBal(int id) async {
final client = Client();
try {