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.
42 lines
1.1 KiB
Dart
42 lines
1.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import 'app.dart';
|
|
import 'core/api.dart';
|
|
import 'core/config.dart';
|
|
import 'core/format.dart';
|
|
import 'core/http_api.dart';
|
|
import 'core/providers.dart';
|
|
|
|
Future<void> main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
if (AppConfig.unconfigured) debugPrint('SRS: ${AppConfig.setupHint}');
|
|
final Api api = HttpApi(
|
|
baseUrl: AppConfig.apiBaseUrl,
|
|
prefs: await SharedPreferences.getInstance(),
|
|
);
|
|
|
|
final user = await api.restore();
|
|
final start = user == null ? dateOnly(api.now) : await _latestOrToday(api);
|
|
|
|
runApp(
|
|
ProviderScope(
|
|
overrides: [
|
|
apiProvider.overrideWithValue(api),
|
|
startDateProvider.overrideWithValue(start),
|
|
sessionProvider.overrideWith(() => SessionNotifier(user)),
|
|
],
|
|
child: const SrsApp(),
|
|
),
|
|
);
|
|
}
|
|
|
|
Future<DateTime> _latestOrToday(Api api) async {
|
|
try {
|
|
return await api.latestDrawDate();
|
|
} on ApiException {
|
|
return dateOnly(api.now);
|
|
}
|
|
}
|