Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .zed/tasks.json
Original file line number Diff line number Diff line change
@@ -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"]
}
]
2 changes: 1 addition & 1 deletion lib/app/layouts/widgets/plan_sheet_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ class _ShowBottomSheetState extends State<ShowBottomSheet>
.toList();

final plan = PlanModel(
userUUID: userUuid,
userId: userUuid,
session: formatDurationFromHmm(
_dialogSessionSelectedHours,
defaultText: '0m',
Expand Down
66 changes: 31 additions & 35 deletions lib/features/plan/models/plan_model.dart
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
class PlanModel {
final String userUUID;
final String userId;
final String session;
final String breakDuration;
final List<CalendarEntry> calendar;
final List<SubjectEntry> subjects;

PlanModel({
required this.userUUID,
required this.userId,
required this.session,
required this.breakDuration,
required this.calendar,
required this.subjects,
});

PlanModel copyWith({
String? userUUID,
String? userId,
String? session,
String? breakDuration,
List<CalendarEntry>? calendar,
List<SubjectEntry>? subjects,
}) {
return PlanModel(
userUUID: userUUID ?? this.userUUID,
userId: userId ?? this.userId,
session: session ?? this.session,
breakDuration: breakDuration ?? this.breakDuration,
calendar: calendar ?? this.calendar,
Expand All @@ -30,24 +30,26 @@ class PlanModel {
}

Map<String, dynamic> 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<String, dynamic> json) => PlanModel(
userUUID: json['userUUID'] as String? ?? '',
session: json['session'] as String? ?? '',
breakDuration: json['breakDuration'] as String? ?? '',
calendar: (json['calendar'] as List<dynamic>? ?? [])
userId: json['userId'] as String? ?? '',
session: json['session'] as String? ?? '',
breakDuration: json['breakDuration'] as String? ?? '',
calendar:
(json['calendar'] as List<dynamic>? ?? [])
.map((e) => CalendarEntry.fromJson(e as Map<String, dynamic>))
.toList(),
subjects: (json['subjects'] as List<dynamic>? ?? [])
subjects:
(json['subjects'] as List<dynamic>? ?? [])
.map((e) => SubjectEntry.fromJson(e as Map<String, dynamic>))
.toList(),
);
);
}

class CalendarEntry {
Expand All @@ -62,34 +64,28 @@ class CalendarEntry {
});

Map<String, dynamic> toJson() => {
'start_at': startAt,
'end_at': endAt,
'title': title,
};
'start_at': startAt,
'end_at': endAt,
'title': title,
};

factory CalendarEntry.fromJson(Map<String, dynamic> 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<String, dynamic> toJson() => {
'name': subject,
'duration': duration,
};
Map<String, dynamic> toJson() => {'name': subject, 'duration': duration};

factory SubjectEntry.fromJson(Map<String, dynamic> json) => SubjectEntry(
subject: json['name'] as String? ?? '',
duration: json['duration'] as String?,
);
subject: json['name'] as String? ?? '',
duration: json['duration'] as String?,
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class _PlanCreationLoadingPageState extends State<PlanCreationLoadingPage> {
Future<void> _createPlanAndNavigate() async {
try {
await ApiService().createPlan(widget.plan);
print("plan: ${widget.plan}");
final api = ApiService();
final tomatoes = await api.getTodaysTomatoes();
if (mounted && tomatoes.isNotEmpty) {
Expand Down
7 changes: 2 additions & 5 deletions lib/features/profile/bloc/profile_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,15 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
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()}'));
}
Expand Down
Loading