feat: add comparePeriods utility for sorting OKR periods and refactor ObjectivesPage to utilize it for improved period sorting
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 8m28s

This commit is contained in:
Julien Froidefond
2026-01-28 13:58:01 +01:00
parent e848e85b63
commit 3a2eb83197
2 changed files with 44 additions and 10 deletions

View File

@@ -4,6 +4,7 @@ import Link from 'next/link';
import { getUserOKRs } from '@/services/okrs';
import { Card } from '@/components/ui';
import { ObjectivesList } from '@/components/okrs/ObjectivesList';
import { comparePeriods } from '@/lib/okr-utils';
export default async function ObjectivesPage() {
const session = await auth();
@@ -27,16 +28,7 @@ export default async function ObjectivesPage() {
{} as Record<string, typeof okrs>
);
const periods = Object.keys(okrsByPeriod).sort((a, b) => {
// Sort periods: extract year and quarter/period
const aMatch = a.match(/(\d{4})/);
const bMatch = b.match(/(\d{4})/);
if (aMatch && bMatch) {
const yearDiff = parseInt(bMatch[1]) - parseInt(aMatch[1]);
if (yearDiff !== 0) return yearDiff;
}
return b.localeCompare(a);
});
const periods = Object.keys(okrsByPeriod).sort(comparePeriods);
return (
<main className="mx-auto max-w-7xl px-4 py-8">