added guardian login with views for their assigned childs
This commit is contained in:
@@ -5,6 +5,8 @@ import 'package:hydrated_bloc/hydrated_bloc.dart';
|
||||
import '../../../../../api/demo/data/demo_capabilities.dart';
|
||||
import '../../../../../api/demo/demo_mode.dart';
|
||||
import '../../../../../api/marianumconnect/queries/get_capabilities/get_capabilities.dart';
|
||||
import '../../../../../session/session.dart';
|
||||
import '../../../../../session/session_manager.dart';
|
||||
import 'capabilities_state.dart';
|
||||
|
||||
/// Holds the current user's mobile capability flags. Hydrated so the last
|
||||
@@ -21,17 +23,17 @@ class CapabilitiesCubit extends HydratedCubit<CapabilitiesState> {
|
||||
|
||||
int? get timetableFutureDays => state.timetableFutureDays;
|
||||
|
||||
/// Teacher accounts get the class shown on timetable tiles instead of their
|
||||
/// own name (see TimetableAppointmentFactory.showClassInsteadOfTeacher).
|
||||
bool get isTeacher => state.userType == 'TEACHER';
|
||||
|
||||
/// Refreshes capabilities from the server. On any failure (endpoint not yet
|
||||
/// live, network error, 4xx) the previously hydrated flags are kept but the
|
||||
/// state is marked `loaded` — a failed fetch never silently grants a
|
||||
/// capability, and an offline launch keeps whatever was cached.
|
||||
Future<void> load() async {
|
||||
if (DemoMode.active) {
|
||||
emit(DemoCapabilities.state());
|
||||
emit(
|
||||
SessionManager().current is GuardianSession
|
||||
? DemoCapabilities.guardianState()
|
||||
: DemoCapabilities.state(),
|
||||
);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
@@ -43,6 +45,7 @@ class CapabilitiesCubit extends HydratedCubit<CapabilitiesState> {
|
||||
timetablePastDays: response.timetablePastDays,
|
||||
timetableFutureDays: response.timetableFutureDays,
|
||||
userType: response.userType,
|
||||
children: response.children,
|
||||
loaded: true,
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user