Skip to content

Commit 6ee11dc

Browse files
committed
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
1 parent 2553081 commit 6ee11dc

5 files changed

Lines changed: 49 additions & 41 deletions

File tree

.zed/tasks.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[
2+
{
3+
"label": "Flutter Run Chrome",
4+
"command": "flutter run -d chrome",
5+
"env": {},
6+
"use_new_terminal": false,
7+
"allow_concurrent_runs": false,
8+
"reveal": "always",
9+
"hide": "never",
10+
"shell": "system",
11+
"show_summary": true,
12+
"tags": ["development", "web"]
13+
}
14+
]

lib/app/layouts/widgets/plan_sheet_widget.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ class _ShowBottomSheetState extends State<ShowBottomSheet>
450450
.toList();
451451

452452
final plan = PlanModel(
453-
userUUID: userUuid,
453+
userId: userUuid,
454454
session: formatDurationFromHmm(
455455
_dialogSessionSelectedHours,
456456
defaultText: '0m',
Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
class PlanModel {
2-
final String userUUID;
2+
final String userId;
33
final String session;
44
final String breakDuration;
55
final List<CalendarEntry> calendar;
66
final List<SubjectEntry> subjects;
77

88
PlanModel({
9-
required this.userUUID,
9+
required this.userId,
1010
required this.session,
1111
required this.breakDuration,
1212
required this.calendar,
1313
required this.subjects,
1414
});
1515

1616
PlanModel copyWith({
17-
String? userUUID,
17+
String? userId,
1818
String? session,
1919
String? breakDuration,
2020
List<CalendarEntry>? calendar,
2121
List<SubjectEntry>? subjects,
2222
}) {
2323
return PlanModel(
24-
userUUID: userUUID ?? this.userUUID,
24+
userId: userId ?? this.userId,
2525
session: session ?? this.session,
2626
breakDuration: breakDuration ?? this.breakDuration,
2727
calendar: calendar ?? this.calendar,
@@ -30,24 +30,26 @@ class PlanModel {
3030
}
3131

3232
Map<String, dynamic> toJson() => {
33-
'userUUID': userUUID,
34-
'session': session,
35-
'breakDuration': breakDuration,
36-
'calendar': calendar.map((e) => e.toJson()).toList(),
37-
'subjects': subjects.map((e) => e.toJson()).toList(),
38-
};
33+
'userId': userId,
34+
'session': session,
35+
'breakDuration': breakDuration,
36+
'calendar': calendar.map((e) => e.toJson()).toList(),
37+
'subjects': subjects.map((e) => e.toJson()).toList(),
38+
};
3939

4040
factory PlanModel.fromJson(Map<String, dynamic> json) => PlanModel(
41-
userUUID: json['userUUID'] as String? ?? '',
42-
session: json['session'] as String? ?? '',
43-
breakDuration: json['breakDuration'] as String? ?? '',
44-
calendar: (json['calendar'] as List<dynamic>? ?? [])
41+
userId: json['userId'] as String? ?? '',
42+
session: json['session'] as String? ?? '',
43+
breakDuration: json['breakDuration'] as String? ?? '',
44+
calendar:
45+
(json['calendar'] as List<dynamic>? ?? [])
4546
.map((e) => CalendarEntry.fromJson(e as Map<String, dynamic>))
4647
.toList(),
47-
subjects: (json['subjects'] as List<dynamic>? ?? [])
48+
subjects:
49+
(json['subjects'] as List<dynamic>? ?? [])
4850
.map((e) => SubjectEntry.fromJson(e as Map<String, dynamic>))
4951
.toList(),
50-
);
52+
);
5153
}
5254

5355
class CalendarEntry {
@@ -62,34 +64,28 @@ class CalendarEntry {
6264
});
6365

6466
Map<String, dynamic> toJson() => {
65-
'start_at': startAt,
66-
'end_at': endAt,
67-
'title': title,
68-
};
67+
'start_at': startAt,
68+
'end_at': endAt,
69+
'title': title,
70+
};
6971

7072
factory CalendarEntry.fromJson(Map<String, dynamic> json) => CalendarEntry(
71-
startAt: json['start_at'] as String? ?? '',
72-
endAt: json['end_at'] as String? ?? '',
73-
title: json['title'] as String? ?? '',
74-
);
73+
startAt: json['start_at'] as String? ?? '',
74+
endAt: json['end_at'] as String? ?? '',
75+
title: json['title'] as String? ?? '',
76+
);
7577
}
7678

7779
class SubjectEntry {
7880
final String subject;
7981
final String? duration;
8082

81-
SubjectEntry({
82-
required this.subject,
83-
this.duration,
84-
});
83+
SubjectEntry({required this.subject, this.duration});
8584

86-
Map<String, dynamic> toJson() => {
87-
'name': subject,
88-
'duration': duration,
89-
};
85+
Map<String, dynamic> toJson() => {'name': subject, 'duration': duration};
9086

9187
factory SubjectEntry.fromJson(Map<String, dynamic> json) => SubjectEntry(
92-
subject: json['name'] as String? ?? '',
93-
duration: json['duration'] as String?,
94-
);
88+
subject: json['name'] as String? ?? '',
89+
duration: json['duration'] as String?,
90+
);
9591
}

lib/features/plan/presentation/pages/plan_creation_loading_page.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class _PlanCreationLoadingPageState extends State<PlanCreationLoadingPage> {
3030
Future<void> _createPlanAndNavigate() async {
3131
try {
3232
await ApiService().createPlan(widget.plan);
33+
print("plan: ${widget.plan}");
3334
final api = ApiService();
3435
final tomatoes = await api.getTodaysTomatoes();
3536
if (mounted && tomatoes.isNotEmpty) {

lib/features/profile/bloc/profile_bloc.dart

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,15 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
3333
final authState = _authBloc.state;
3434
if (authState is AuthAuthenticated) {
3535
try {
36-
final userData = await _apiService.fetchData('users/${authState.id}');
36+
final userData = await _apiService.fetchData('users/@me');
3737
emit(
3838
ProfileLoaded(
3939
username: userData['username'] as String?,
40-
displayName: userData['username'] as String?,
4140
email: userData['email'] as String?,
42-
photoUrl: userData['photoUrl'] as String?,
43-
isUploadingImage: false,
44-
localPreviewFile: null,
4541
),
4642
);
4743
add(LoadAchievements());
44+
print('User: ${userData}');
4845
} catch (e) {
4946
emit(ProfileError('Errore nel caricamento profilo: ${e.toString()}'));
5047
}

0 commit comments

Comments
 (0)