diff --git a/frontend/app_student/lib/api/users/repositories/user_repository.dart b/frontend/app_student/lib/api/users/repositories/user_repository.dart index d94e2da..ff6096c 100644 --- a/frontend/app_student/lib/api/users/repositories/user_repository.dart +++ b/frontend/app_student/lib/api/users/repositories/user_repository.dart @@ -62,4 +62,9 @@ class UserRepository { await prefs.remove('birthDate'); await prefs.remove('className'); } + + Future clearClass() async { + SharedPreferences prefs = await SharedPreferences.getInstance(); + await prefs.remove('className'); + } } diff --git a/frontend/app_student/lib/class_groups/cubit/class_group_cubit.dart b/frontend/app_student/lib/class_groups/cubit/class_group_cubit.dart index 46a4375..6b59e5c 100644 --- a/frontend/app_student/lib/class_groups/cubit/class_group_cubit.dart +++ b/frontend/app_student/lib/class_groups/cubit/class_group_cubit.dart @@ -15,7 +15,6 @@ class ClassGroupCubit extends Cubit { try { emit(ClassGroupLoading()); final classes = await classRepository.getClasses(); - emit(ClassGroupLoaded(classes)); } catch (e) { emit(ClassGroupError(e.toString())); diff --git a/frontend/app_student/lib/menu/menu_view.dart b/frontend/app_student/lib/menu/menu_view.dart index 32bf28c..9a7b4ef 100644 --- a/frontend/app_student/lib/menu/menu_view.dart +++ b/frontend/app_student/lib/menu/menu_view.dart @@ -44,7 +44,7 @@ class MenuBarViewState extends State { switch (index) { case 0: - context.read().deleteUserClass(); + context.read().deleteUser(); GoRouter.of(context).go(AppRoutes.loginPage); WidgetsBinding.instance.addPostFrameCallback((_) { Fluttertoast.showToast( diff --git a/frontend/app_student/lib/profils/views/profil.dart b/frontend/app_student/lib/profils/views/profil.dart index dd83396..573b3db 100644 --- a/frontend/app_student/lib/profils/views/profil.dart +++ b/frontend/app_student/lib/profils/views/profil.dart @@ -1,12 +1,10 @@ import 'package:app_student/menu/menu_view.dart'; import 'package:app_student/profils/views/widgets/class_group_button.dart'; import 'package:app_student/profils/views/widgets/user_class_card.dart'; -import 'package:app_student/profils/views/widgets/user_info_card.dart'; import 'package:app_student/utils/custom_layout.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; -import 'package:intl/intl.dart'; import '../../shared_components/header_logo.dart'; import '../../shared_components/header_title.dart'; @@ -21,19 +19,19 @@ class ProfilPage extends StatelessWidget { final userState = context.watch().state; String firstName = ''; String className = ''; - String ine = ''; - DateTime? birthDate; + // String ine = ''; + // DateTime? birthDate; if (userState is UserLoaded) { firstName = userState.user.entity.firstName; className = userState.user.entity.className!; - ine = userState.user.entity.ine; - birthDate = userState.user.entity.birthDate; + // ine = userState.user.entity.ine; + // birthDate = userState.user.entity.birthDate; } - String birthDateString = birthDate != null - ? DateFormat('dd/MM/yyyy').format(birthDate) - : 'error'; + // String birthDateString = birthDate != null + // ? DateFormat('dd/MM/yyyy').format(birthDate) + // : 'error'; return CustomLayout( appBar: HeaderLogo(appBarHeight: Global.screenHeight * 0.3), @@ -46,7 +44,7 @@ class ProfilPage extends StatelessWidget { ), ), UserClassCard(className: className, firstName: firstName), - UserInfoCard(ine: ine, birthDate: birthDateString), + // UserInfoCard(ine: ine, birthDate: birthDateString), ], ), bottomContent: const ClassGroupButton(), diff --git a/frontend/app_student/lib/profils/views/widgets/class_group_button.dart b/frontend/app_student/lib/profils/views/widgets/class_group_button.dart index b267197..a5e38ca 100644 --- a/frontend/app_student/lib/profils/views/widgets/class_group_button.dart +++ b/frontend/app_student/lib/profils/views/widgets/class_group_button.dart @@ -1,6 +1,8 @@ import 'package:app_student/routes.dart'; +import 'package:app_student/users/cubit/user_cubit.dart'; import 'package:app_student/utils/custom_theme.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:go_router/go_router.dart'; @@ -30,6 +32,7 @@ class ClassGroupButton extends StatelessWidget { ), ), onPressed: () { + context.read().clearUserClass(); GoRouter.of(context).go(AppRoutes.classListPage); }, child: Text(AppLocalizations.of(context)!.profilChangeClassButton, diff --git a/frontend/app_student/lib/users/cubit/user_cubit.dart b/frontend/app_student/lib/users/cubit/user_cubit.dart index 049ab7a..3350ddb 100644 --- a/frontend/app_student/lib/users/cubit/user_cubit.dart +++ b/frontend/app_student/lib/users/cubit/user_cubit.dart @@ -31,7 +31,11 @@ class UserCubit extends Cubit { emit(UserClassesSelected()); } - Future deleteUserClass() async { + Future deleteUser() async { await userRepository.delete(); } + + Future clearUserClass() async { + await userRepository.clearClass(); + } } diff --git a/frontend/app_student/pubspec.yaml b/frontend/app_student/pubspec.yaml index 667f7a7..29398f6 100644 --- a/frontend/app_student/pubspec.yaml +++ b/frontend/app_student/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.0.0+9 +version: 1.0.0+11 environment: sdk: '>=3.3.0 <4.0.0'