Skip to content

Commit 6e898e6

Browse files
committed
Sort session dates
1 parent 7f7011a commit 6e898e6

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/components/ui/dashboard/dynamic-api-select.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,18 @@ export function DynamicApiSelect<T>({
6565
filterFn: (session: CoachingSession) => boolean
6666
) => {
6767
const filteredSessions = sessions.filter(filterFn);
68+
69+
const sortedSessions = filteredSessions.sort(
70+
(a, b) =>
71+
DateTime.fromISO(a.date.toString()).toMillis() -
72+
DateTime.fromISO(b.date.toString()).toMillis()
73+
);
74+
6875
return (
69-
filteredSessions.length > 0 && (
76+
sortedSessions.length > 0 && (
7077
<SelectGroup>
7178
<SelectLabel>{label}</SelectLabel>
72-
{filteredSessions.map((session) => (
79+
{sortedSessions.map((session) => (
7380
<SelectItem value={session.id} key={session.id}>
7481
{DateTime.fromISO(session.date.toString()).toLocaleString(
7582
DateTime.DATETIME_FULL

0 commit comments

Comments
 (0)