fixed guardian login edge cases and misleading placeholders on failed loads
This commit is contained in:
@@ -5,6 +5,8 @@ import '../api/marianumconnect/queries/get_capabilities/guardian_child.dart';
|
||||
import '../state/app/modules/capabilities/bloc/capabilities_cubit.dart';
|
||||
import '../state/app/modules/children/child_selection_cubit.dart';
|
||||
import '../utils/haptics.dart';
|
||||
import 'app_progress_indicator.dart';
|
||||
import 'async_action_button.dart';
|
||||
import 'centered_leading.dart';
|
||||
import 'details_bottom_sheet.dart';
|
||||
import 'placeholder_view.dart';
|
||||
@@ -71,15 +73,37 @@ class ChildTile extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/// Shown by per-child modules while a guardian has no linked child.
|
||||
/// Shown by per-child modules while a guardian has no linked child. The
|
||||
/// children come from `me/capabilities`, so a failed or pending load must not
|
||||
/// be presented as "no child assigned" — that sends parents to the secretariat
|
||||
/// over a network error.
|
||||
class NoChildrenPlaceholder extends StatelessWidget {
|
||||
const NoChildrenPlaceholder({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => const PlaceholderView(
|
||||
icon: Icons.family_restroom_outlined,
|
||||
text:
|
||||
'Deinem Konto ist noch kein Kind zugeordnet. Bitte wende dich an '
|
||||
'das Sekretariat.',
|
||||
);
|
||||
Widget build(BuildContext context) {
|
||||
final capabilities = context.watch<CapabilitiesCubit>().state;
|
||||
if (!capabilities.loaded) {
|
||||
return const Center(child: AppProgressIndicator.large());
|
||||
}
|
||||
if (capabilities.loadFailed) {
|
||||
return PlaceholderView(
|
||||
icon: Icons.cloud_off_outlined,
|
||||
text:
|
||||
'Die zugeordneten Kinder konnten nicht geladen werden. Bitte '
|
||||
'prüfe deine Internetverbindung.',
|
||||
button: AsyncActionButton(
|
||||
icon: Icons.refresh,
|
||||
onPressed: context.read<CapabilitiesCubit>().load,
|
||||
child: const Text('Erneut versuchen'),
|
||||
),
|
||||
);
|
||||
}
|
||||
return const PlaceholderView(
|
||||
icon: Icons.family_restroom_outlined,
|
||||
text:
|
||||
'Deinem Konto ist noch kein Kind zugeordnet. Bitte wende dich an '
|
||||
'das Sekretariat.',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user