pretty it up
This commit is contained in:
@@ -5,7 +5,7 @@ export const runtime = "nodejs";
|
||||
import { getServerSession } from "next-auth/next";
|
||||
import { authOptions } from "@/lib/auth";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { uploadToDrive, updateDriveFile, generateReportMarkdown, getGoogleAuth } from "@/lib/google-drive";
|
||||
import { uploadToDrive, updateDriveFile, generateReportHTML, getGoogleAuth } from "@/lib/google-drive";
|
||||
|
||||
export async function POST(
|
||||
req: Request,
|
||||
@@ -35,7 +35,7 @@ export async function POST(
|
||||
return NextResponse.json({ error: "Report not found" }, { status: 404 });
|
||||
}
|
||||
|
||||
const markdown = generateReportMarkdown(report);
|
||||
const htmlContent = generateReportHTML(report);
|
||||
const fileName = `WFH_Report_${new Date(report.date).toISOString().split('T')[0]}_${report.user.name}`;
|
||||
|
||||
// Fetch designated folder ID from settings
|
||||
@@ -48,10 +48,10 @@ export async function POST(
|
||||
|
||||
if (report.driveFileId) {
|
||||
// Update the existing Drive file in place
|
||||
driveFile = await updateDriveFile(auth, report.driveFileId, markdown);
|
||||
driveFile = await updateDriveFile(auth, report.driveFileId, htmlContent);
|
||||
} else {
|
||||
// First export — create a new Drive file and store its ID
|
||||
driveFile = await uploadToDrive(auth, fileName, markdown, folderSetting?.value);
|
||||
driveFile = await uploadToDrive(auth, fileName, htmlContent, folderSetting?.value);
|
||||
await prisma.report.update({
|
||||
where: { id },
|
||||
data: { driveFileId: driveFile.id },
|
||||
|
||||
Reference in New Issue
Block a user