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
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 8m28s
This commit is contained in:
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user