Add SRS app: results, shops, orders and users, wired to srs-api
Flutter web/PWA for the lottery agency, built on Riverpod and go_router,
talking to srs-api over HTTP (HttpApi, token kept in SharedPreferences).
- Results, Shops, Orders and Users tabs (Users for admins only), with
phone, tablet and desktop layouts and shared widgets and theme tokens
- Users: list with search and Active/Inactive filters; user detail with
shops, sign-in details, and an Access card
- WhatsApp results switch on each user (sendResults on
PATCH /api/users/:id). Shows the WhatsApp logo (Simple Icons, CC0,
drawn with flutter_svg), green only when results will really go out.
Can't be turned on without a phone number ("Add a phone number first"
opens the phone sheet), and is paused while the user is inactive. The
users list marks people who get results with the logo.
- Each Access switch has a one-line description; the explanation
paragraphs are gone
- Remove demo mode: the app always uses the real AP
test/support and is used only by tests.
54 lines
1.5 KiB
Dart
54 lines
1.5 KiB
Dart
import 'models.dart';
|
|
|
|
class ApiException implements Exception {
|
|
ApiException(this.message);
|
|
final String message;
|
|
@override
|
|
String toString() => message;
|
|
}
|
|
|
|
abstract class Api {
|
|
DateTime get now;
|
|
Stream<void> get sessionEnded;
|
|
Future<DateTime> latestDrawDate();
|
|
Future<AppUser> login(String username, String password);
|
|
Future<AppUser?> restore();
|
|
void logout();
|
|
|
|
Future<List<DrawInfo>> month(int year, int month);
|
|
Future<DrawResults> results(DateTime date);
|
|
|
|
Future<List<ShopDay>> shops(DateTime date);
|
|
Future<ShopDetail> shopDetail(int shopId, DateTime date);
|
|
Future<List<Shop>> activeShops();
|
|
Future<Shop> createShop(String name, String code);
|
|
Future<void> renameShop(int shopId, String name);
|
|
Future<void> setShopActive(int shopId, bool active);
|
|
|
|
Future<List<Order>> orders(DateTime date);
|
|
Future<Order> order(int orderId);
|
|
Future<void> setLineQty(int orderId, String ending, int qty);
|
|
Future<void> removeLine(int orderId, String ending);
|
|
Future<void> cancelOrder(int orderId);
|
|
|
|
Future<List<AppUser>> users();
|
|
Future<AppUser> user(int id);
|
|
Future<AppUser> createUser({
|
|
required String username,
|
|
String? phone,
|
|
required String password,
|
|
required List<int> shopIds,
|
|
});
|
|
Future<void> updateUser(
|
|
int id, {
|
|
String? username,
|
|
String? phone,
|
|
bool clearPhone = false,
|
|
String? password,
|
|
bool? active,
|
|
bool? sendResults,
|
|
});
|
|
Future<void> setUserShops(int id, List<int> shopIds);
|
|
Future<void> deleteUser(int id);
|
|
}
|