Skip to content

Commit

Permalink
Add artefact due date filters (#190)
Browse files Browse the repository at this point in the history
* Add artefact due date filters

* Rewording and removing a useless filter option
  • Loading branch information
omar-selo committed Jul 17, 2024
1 parent 76289a1 commit 0a7c0a8
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions frontend/lib/models/filters.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,20 @@ final emptyArtefactFilters = Filters<Artefact>(
name: 'Status',
extractOption: (artefact) => artefact.status.name,
),
Filter<Artefact>(
name: 'Due date',
extractOption: (artefact) {
final now = DateTime.now();
final dueDate = artefact.dueDate;

if (dueDate == null) return 'No due date';
if (dueDate.isBefore(now)) return 'Overdue';

final daysDueIn = now.difference(dueDate).inDays;
if (daysDueIn >= 7) return 'More than a week';
return 'Within a week';
},
),
],
);

Expand Down

0 comments on commit 0a7c0a8

Please sign in to comment.