Skip to content

Commit

Permalink
report.actions add allreports
Browse files Browse the repository at this point in the history
  • Loading branch information
talhathmd committed Oct 6, 2024
1 parent 73524ac commit c15be8c
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/lib/actions/report.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,28 @@ export async function createReport({
}
}

export async function fetchReport(fileId: string) {
try {
// Connect to the database
await connectToDB();

// Find the report by fileId instead of _id
const report = await Report.findOne({ fileId: fileId });

// If no report is found, throw an error
if (!report) {
throw new Error("Report not found");
}

// Return the report data
return report;
} catch (error: any) {
console.error(`Error fetching report: ${error}`);
throw new Error("Error fetching report");
}
}

// Also, make sure fetchAllReportIds is exported
export async function fetchAllReportIds() {
try {
// Connect to the database
Expand All @@ -58,5 +80,3 @@ export async function fetchAllReportIds() {
throw new Error("Error fetching report IDs");
}
}


0 comments on commit c15be8c

Please sign in to comment.