From 6ee11dcaef5991d85f0874a4e0d373b86053abb2 Mon Sep 17 00:00:00 2001 From: Dibbiii Date: Tue, 5 Aug 2025 17:16:18 +0200 Subject: [PATCH] Rename userUUID to userId in PlanModel and related files Add Flutter Run Chrome task for Zed editor Update profile API call to use users/@me endpoint Add debug print for plan creation and user data loading --- .zed/tasks.json | 14 ++++ .../layouts/widgets/plan_sheet_widget.dart | 2 +- lib/features/plan/models/plan_model.dart | 66 +++++++++---------- .../pages/plan_creation_loading_page.dart | 1 + lib/features/profile/bloc/profile_bloc.dart | 7 +- 5 files changed, 49 insertions(+), 41 deletions(-) create mode 100644 .zed/tasks.json diff --git a/.zed/tasks.json b/.zed/tasks.json new file mode 100644 index 0000000..eccc717 --- /dev/null +++ b/.zed/tasks.json @@ -0,0 +1,14 @@ +[ + { + "label": "Flutter Run Chrome", + "command": "flutter run -d chrome", + "env": {}, + "use_new_terminal": false, + "allow_concurrent_runs": false, + "reveal": "always", + "hide": "never", + "shell": "system", + "show_summary": true, + "tags": ["development", "web"] + } +] diff --git a/lib/app/layouts/widgets/plan_sheet_widget.dart b/lib/app/layouts/widgets/plan_sheet_widget.dart index 1e74f86..2cded35 100644 --- a/lib/app/layouts/widgets/plan_sheet_widget.dart +++ b/lib/app/layouts/widgets/plan_sheet_widget.dart @@ -450,7 +450,7 @@ class _ShowBottomSheetState extends State .toList(); final plan = PlanModel( - userUUID: userUuid, + userId: userUuid, session: formatDurationFromHmm( _dialogSessionSelectedHours, defaultText: '0m', diff --git a/lib/features/plan/models/plan_model.dart b/lib/features/plan/models/plan_model.dart index d2f8783..b742c3b 100644 --- a/lib/features/plan/models/plan_model.dart +++ b/lib/features/plan/models/plan_model.dart @@ -1,12 +1,12 @@ class PlanModel { - final String userUUID; + final String userId; final String session; final String breakDuration; final List calendar; final List subjects; PlanModel({ - required this.userUUID, + required this.userId, required this.session, required this.breakDuration, required this.calendar, @@ -14,14 +14,14 @@ class PlanModel { }); PlanModel copyWith({ - String? userUUID, + String? userId, String? session, String? breakDuration, List? calendar, List? subjects, }) { return PlanModel( - userUUID: userUUID ?? this.userUUID, + userId: userId ?? this.userId, session: session ?? this.session, breakDuration: breakDuration ?? this.breakDuration, calendar: calendar ?? this.calendar, @@ -30,24 +30,26 @@ class PlanModel { } Map toJson() => { - 'userUUID': userUUID, - 'session': session, - 'breakDuration': breakDuration, - 'calendar': calendar.map((e) => e.toJson()).toList(), - 'subjects': subjects.map((e) => e.toJson()).toList(), - }; + 'userId': userId, + 'session': session, + 'breakDuration': breakDuration, + 'calendar': calendar.map((e) => e.toJson()).toList(), + 'subjects': subjects.map((e) => e.toJson()).toList(), + }; factory PlanModel.fromJson(Map json) => PlanModel( - userUUID: json['userUUID'] as String? ?? '', - session: json['session'] as String? ?? '', - breakDuration: json['breakDuration'] as String? ?? '', - calendar: (json['calendar'] as List? ?? []) + userId: json['userId'] as String? ?? '', + session: json['session'] as String? ?? '', + breakDuration: json['breakDuration'] as String? ?? '', + calendar: + (json['calendar'] as List? ?? []) .map((e) => CalendarEntry.fromJson(e as Map)) .toList(), - subjects: (json['subjects'] as List? ?? []) + subjects: + (json['subjects'] as List? ?? []) .map((e) => SubjectEntry.fromJson(e as Map)) .toList(), - ); + ); } class CalendarEntry { @@ -62,34 +64,28 @@ class CalendarEntry { }); Map toJson() => { - 'start_at': startAt, - 'end_at': endAt, - 'title': title, - }; + 'start_at': startAt, + 'end_at': endAt, + 'title': title, + }; factory CalendarEntry.fromJson(Map json) => CalendarEntry( - startAt: json['start_at'] as String? ?? '', - endAt: json['end_at'] as String? ?? '', - title: json['title'] as String? ?? '', - ); + startAt: json['start_at'] as String? ?? '', + endAt: json['end_at'] as String? ?? '', + title: json['title'] as String? ?? '', + ); } class SubjectEntry { final String subject; final String? duration; - SubjectEntry({ - required this.subject, - this.duration, - }); + SubjectEntry({required this.subject, this.duration}); - Map toJson() => { - 'name': subject, - 'duration': duration, - }; + Map toJson() => {'name': subject, 'duration': duration}; factory SubjectEntry.fromJson(Map json) => SubjectEntry( - subject: json['name'] as String? ?? '', - duration: json['duration'] as String?, - ); + subject: json['name'] as String? ?? '', + duration: json['duration'] as String?, + ); } diff --git a/lib/features/plan/presentation/pages/plan_creation_loading_page.dart b/lib/features/plan/presentation/pages/plan_creation_loading_page.dart index cb21fdc..c702d1f 100644 --- a/lib/features/plan/presentation/pages/plan_creation_loading_page.dart +++ b/lib/features/plan/presentation/pages/plan_creation_loading_page.dart @@ -30,6 +30,7 @@ class _PlanCreationLoadingPageState extends State { Future _createPlanAndNavigate() async { try { await ApiService().createPlan(widget.plan); + print("plan: ${widget.plan}"); final api = ApiService(); final tomatoes = await api.getTodaysTomatoes(); if (mounted && tomatoes.isNotEmpty) { diff --git a/lib/features/profile/bloc/profile_bloc.dart b/lib/features/profile/bloc/profile_bloc.dart index 4b91066..792a8e9 100644 --- a/lib/features/profile/bloc/profile_bloc.dart +++ b/lib/features/profile/bloc/profile_bloc.dart @@ -33,18 +33,15 @@ class ProfileBloc extends Bloc { final authState = _authBloc.state; if (authState is AuthAuthenticated) { try { - final userData = await _apiService.fetchData('users/${authState.id}'); + final userData = await _apiService.fetchData('users/@me'); emit( ProfileLoaded( username: userData['username'] as String?, - displayName: userData['username'] as String?, email: userData['email'] as String?, - photoUrl: userData['photoUrl'] as String?, - isUploadingImage: false, - localPreviewFile: null, ), ); add(LoadAchievements()); + print('User: ${userData}'); } catch (e) { emit(ProfileError('Errore nel caricamento profilo: ${e.toString()}')); }