Browse Source

fix(api): update cintas summary ordering to sort by weekId descending

Changed the ordering of cintas summaries from ascending week to descending weekId in both the existing summary retrieval and newly generated summary endpoints. This ensures the most recent weeks appear first in the response.

Also added import ID display to the cintas calendar summary page for better debugging and tracking purposes.
vtugulan 6 months ago
parent
commit
7adba1d7a7
2 changed files with 5 additions and 2 deletions
  1. 2 2
      app/api/imports/[id]/summary/route.ts
  2. 3 0
      app/cintas-calendar-summary/page.tsx

+ 2 - 2
app/api/imports/[id]/summary/route.ts

@@ -108,7 +108,7 @@ export async function POST(
             // Return existing summary
             const cintasSummaries = await prisma.cintasSummary.findMany({
                 where: { importId },
-                orderBy: { week: 'asc' }
+                orderBy: { weekId: 'desc' }
             });
 
             return NextResponse.json({
@@ -133,7 +133,7 @@ export async function POST(
         // Fetch the newly generated summary
         const cintasSummaries = await prisma.cintasSummary.findMany({
             where: { importId },
-            orderBy: { week: 'asc' }
+            orderBy: { weekId: 'desc' }
         });
 
         return NextResponse.json({

+ 3 - 0
app/cintas-calendar-summary/page.tsx

@@ -316,6 +316,9 @@ export default function CintasCalendarSummaryPage() {
             </CardHeader>
             <CardContent>
               <div className="space-y-4">
+                <p className="text-sm text-muted-foreground">
+                  Import ID: {importRecord?.id}
+                </p>
                 <Button
                   onClick={handleGenerateSummary}
                   disabled={isProcessing}