Skip to content

Commit 06ff1de

Browse files
committed
feat(ideaStatusReason): modify the interface of ideabox
1 parent 0b845ab commit 06ff1de

File tree

10 files changed

+264
-25
lines changed

10 files changed

+264
-25
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
*.swp
88
.DS_Store
99
.atom/
10+
.build/
1011
.buildlog/
1112
.history
1213
.svn/
14+
.swiftpm/
1315
migrate_working_dir/
1416

1517
# IntelliJ related

lib/data/entities/idea_box/idea_entity.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ abstract class IdeaEntity with _$IdeaEntity {
1010
required String id,
1111
required String description,
1212
required String context,
13+
String? author,
14+
String? reason,
1315
@JsonKey(name: 'created_at') required DateTime createdAt,
1416
required String status,
1517
}) = _IdeaEntity;

lib/data/entities/idea_box/idea_entity.freezed.dart

Lines changed: 69 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/data/entities/idea_box/idea_entity.g.dart

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/data/service/idea_service.dart

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,16 @@ class IdeaService {
5555
}
5656
}
5757

58-
Future<void> updateIdeaStatus(String id, String newStatus) async {
59-
final response = await _api.updateIdeaStatus(id, {'status': newStatus});
58+
Future<void> updateIdeaStatus(String id, String newStatus,
59+
{String? reason}) async {
60+
final body = <String, dynamic>{'status': newStatus};
61+
final trimmedReason = reason?.trim();
62+
63+
if (trimmedReason != null && trimmedReason.isNotEmpty) {
64+
body['reason'] = trimmedReason;
65+
}
66+
67+
final response = await _api.updateIdeaStatus(id, body);
6068
if (response.response.statusCode != 204) {
6169
throw Exception('Erreur lors de la mise à jour du statut de l\'idée');
6270
}

lib/presentation/pages/idea_box/content/idea_box_content_ideas.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,12 @@ class IdeaBoxContentIdeasState extends ConsumerState<IdeaBoxContentIdeas> {
161161
...ideas.map((idea) {
162162
return IdeaCard(
163163
idea: idea,
164-
onStatusChanged: (newStatus) async {
164+
onStatusChanged: (newStatus, reason) async {
165165
try {
166166
await ref.read(ideaUpdateStatusProvider({
167167
'id': idea.id,
168168
'status': newStatus,
169+
'reason': reason,
169170
}).future);
170171
ref.invalidate(ideasProvider);
171172

0 commit comments

Comments
 (0)