Added download option for assignment cards
Export PDF Download to hook Prevented some NaN's
This commit is contained in:
@@ -22,22 +22,23 @@ export const getRadialProgressPNG = (
|
||||
// calculate the percentage of the score
|
||||
// and round it to the closest available image
|
||||
const percent = (score / total) * 100;
|
||||
if (isNaN(percent)) return `public/radial_progress/${color}_0.png`;
|
||||
const remainder = percent % 10;
|
||||
const roundedPercent = percent - remainder;
|
||||
return `public/radial_progress/${color}_${roundedPercent}.png`;
|
||||
};
|
||||
|
||||
export const streamToBuffer = async (
|
||||
stream: NodeJS.ReadableStream
|
||||
): Promise<Buffer> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const chunks: Buffer[] = [];
|
||||
stream.on("data", (data) => {
|
||||
chunks.push(data);
|
||||
});
|
||||
stream.on("end", () => {
|
||||
resolve(Buffer.concat(chunks));
|
||||
});
|
||||
stream.on("error", reject);
|
||||
stream: NodeJS.ReadableStream
|
||||
): Promise<Buffer> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const chunks: Buffer[] = [];
|
||||
stream.on("data", (data) => {
|
||||
chunks.push(data);
|
||||
});
|
||||
};
|
||||
stream.on("end", () => {
|
||||
resolve(Buffer.concat(chunks));
|
||||
});
|
||||
stream.on("error", reject);
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user