feat: WebSocket temps réel + Finance Workflow + corrections
- Task #6: WebSocket /ws/dashboard + Kafka events (5 topics) * Backend: KafkaEventProducer, KafkaEventConsumer * Mobile: WebSocketService (reconnection, heartbeat, typed events) * DashboardBloc: Auto-refresh depuis WebSocket events - Finance Workflow: approbations + budgets (backend + mobile) * Backend: entities, services, resources, migrations Flyway V6 * Mobile: features finance_workflow complète avec BLoC - Corrections DI: interfaces IRepository partout * IProfileRepository, IOrganizationRepository, IMembreRepository * GetIt configuré avec @injectable - Spec-Kit: constitution + templates mis à jour * .specify/memory/constitution.md enrichie * Templates agent, plan, spec, tasks, checklist - Nettoyage: fichiers temporaires supprimés Signed-off-by: lions dev Team
This commit is contained in:
@@ -1,22 +1,69 @@
|
||||
/// BLoC pour la gestion du profil utilisateur
|
||||
library profile_bloc;
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import '../../../data/repositories/profile_repository.dart';
|
||||
import '../../domain/usecases/get_profile.dart';
|
||||
import '../../domain/usecases/update_profile.dart';
|
||||
import '../../domain/usecases/update_avatar.dart';
|
||||
import '../../domain/usecases/change_password.dart';
|
||||
import '../../domain/usecases/update_preferences.dart';
|
||||
import '../../domain/usecases/delete_account.dart';
|
||||
import '../../domain/repositories/profile_repository.dart';
|
||||
import '../../../members/data/models/membre_complete_model.dart';
|
||||
|
||||
part 'profile_event.dart';
|
||||
part 'profile_state.dart';
|
||||
|
||||
/// BLoC pour la gestion du profil (Clean Architecture)
|
||||
@injectable
|
||||
class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
|
||||
final ProfileRepository _repository;
|
||||
final GetProfile _getProfile;
|
||||
final UpdateProfile _updateProfile;
|
||||
final UpdateAvatar _updateAvatar;
|
||||
final ChangePassword _changePassword;
|
||||
final UpdatePreferences _updatePreferences;
|
||||
final DeleteAccount _deleteAccount;
|
||||
final IProfileRepository _repository; // Pour méthodes non-couvertes (getProfileByEmail)
|
||||
|
||||
ProfileBloc(this._repository) : super(const ProfileInitial()) {
|
||||
ProfileBloc(
|
||||
this._getProfile,
|
||||
this._updateProfile,
|
||||
this._updateAvatar,
|
||||
this._changePassword,
|
||||
this._updatePreferences,
|
||||
this._deleteAccount,
|
||||
this._repository,
|
||||
) : super(const ProfileInitial()) {
|
||||
on<LoadMe>(_onLoadMe);
|
||||
on<LoadMyProfile>(_onLoadMyProfile);
|
||||
on<UpdateMyProfile>(_onUpdateMyProfile);
|
||||
}
|
||||
|
||||
/// Charge le profil du membre connecté
|
||||
Future<void> _onLoadMe(
|
||||
LoadMe event,
|
||||
Emitter<ProfileState> emit,
|
||||
) async {
|
||||
try {
|
||||
emit(const ProfileLoading());
|
||||
final membre = await _getProfile();
|
||||
if (membre != null) {
|
||||
emit(ProfileLoaded(membre));
|
||||
} else {
|
||||
emit(const ProfileNotFound());
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
emit(ProfileError(_networkErrorMessage(e)));
|
||||
} catch (e) {
|
||||
emit(ProfileError('Erreur lors du chargement du profil : $e'));
|
||||
}
|
||||
}
|
||||
|
||||
/// Charge le profil par email (recherche)
|
||||
/// Note: Cette méthode utilise directement le repository car elle n'a pas de use case dédié
|
||||
Future<void> _onLoadMyProfile(
|
||||
LoadMyProfile event,
|
||||
Emitter<ProfileState> emit,
|
||||
@@ -36,6 +83,7 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Met à jour le profil
|
||||
Future<void> _onUpdateMyProfile(
|
||||
UpdateMyProfile event,
|
||||
Emitter<ProfileState> emit,
|
||||
@@ -45,7 +93,7 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
|
||||
if (currentState is ProfileLoaded) {
|
||||
emit(ProfileUpdating(currentState.membre));
|
||||
}
|
||||
final updated = await _repository.updateProfile(event.membreId, event.membre);
|
||||
final updated = await _updateProfile(event.membreId, event.membre);
|
||||
emit(ProfileUpdated(updated));
|
||||
} on DioException catch (e) {
|
||||
if (currentState is ProfileLoaded) {
|
||||
|
||||
Reference in New Issue
Block a user