Added final touches
This commit is contained in:
@@ -34,7 +34,7 @@ import {
|
||||
streamToBuffer,
|
||||
} from "@/utils/pdf";
|
||||
import moment from "moment-timezone";
|
||||
|
||||
import { getCorporateNameForStudent } from "@/utils/groups.be";
|
||||
const db = getFirestore(app);
|
||||
|
||||
export default withIronSessionApiRoute(handler, sessionOptions);
|
||||
@@ -325,14 +325,14 @@ async function post(req: NextApiRequest, res: NextApiResponse) {
|
||||
}
|
||||
const userId = stats[statIndex].user;
|
||||
|
||||
// if (hasPDF) {
|
||||
// // if it does, return the pdf url
|
||||
// const fileRef = ref(storage, hasPDF.pdf!.path);
|
||||
// const url = await getDownloadURL(fileRef);
|
||||
if (hasPDF) {
|
||||
// if it does, return the pdf url
|
||||
const fileRef = ref(storage, hasPDF.pdf!.path);
|
||||
const url = await getDownloadURL(fileRef);
|
||||
|
||||
// res.status(200).end(url);
|
||||
// return;
|
||||
// }
|
||||
res.status(200).end(url);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// generate the pdf report
|
||||
@@ -355,7 +355,7 @@ async function post(req: NextApiRequest, res: NextApiResponse) {
|
||||
stats.reduce((accm, s: Stat) => accm + (s.timeSpent || 0), 0) / 60
|
||||
} minutes`;
|
||||
const score = stats.reduce((accm, s) => accm + s.score.correct, 0);
|
||||
|
||||
const corporateName = await getCorporateNameForStudent(userId);
|
||||
const pdfStream = await ReactPDF.renderToStream(
|
||||
<LevelTestReport
|
||||
date={moment.max(dates).format("DD/MM/YYYY")}
|
||||
@@ -364,7 +364,7 @@ async function post(req: NextApiRequest, res: NextApiResponse) {
|
||||
id={stat.exam}
|
||||
gender={user.demographicInformation?.gender || ""}
|
||||
passportId={user.demographicInformation?.passport_id || ""}
|
||||
corporateName="TODO"
|
||||
corporateName={corporateName}
|
||||
downloadDate={moment().format("DD/MM/YYYY")}
|
||||
userId={userId}
|
||||
uniqueExercises={uniqueExercises}
|
||||
@@ -376,8 +376,6 @@ async function post(req: NextApiRequest, res: NextApiResponse) {
|
||||
const url = await getPdfUrl(pdfStream, docsSnap);
|
||||
res.status(200).end(url);
|
||||
return;
|
||||
|
||||
return;
|
||||
}
|
||||
const user = docUser.data() as User;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user