Added PNGs with partial radial progress
BIN
public/radial_progress/azul_0.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
public/radial_progress/azul_10.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
public/radial_progress/azul_100.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
public/radial_progress/azul_20.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
public/radial_progress/azul_30.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
public/radial_progress/azul_40.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
public/radial_progress/azul_50.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
public/radial_progress/azul_60.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
public/radial_progress/azul_70.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
public/radial_progress/azul_80.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
public/radial_progress/azul_90.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
public/radial_progress/laranja_0.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
public/radial_progress/laranja_10.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
public/radial_progress/laranja_100.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
public/radial_progress/laranja_20.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
public/radial_progress/laranja_30.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
public/radial_progress/laranja_40.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
public/radial_progress/laranja_50.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
public/radial_progress/laranja_60.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
public/radial_progress/laranja_70.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
public/radial_progress/laranja_80.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
public/radial_progress/laranja_90.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
@@ -1,36 +1,50 @@
|
||||
/* eslint-disable jsx-a11y/alt-text */
|
||||
import React from "react";
|
||||
import {
|
||||
Document,
|
||||
Page,
|
||||
View,
|
||||
Text,
|
||||
StyleSheet,
|
||||
Image,
|
||||
} from "@react-pdf/renderer";
|
||||
import { styles } from "../styles";
|
||||
import { ModuleScore } from "@/interfaces/module.scores";
|
||||
|
||||
export const RadialResult = ({ module, score, total }: ModuleScore) => (
|
||||
export const RadialResult = ({ module, score, total, png }: ModuleScore) => (
|
||||
<View
|
||||
key="module"
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
gap: 8,
|
||||
}}
|
||||
style={[
|
||||
styles.textFont,
|
||||
{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
gap: 4,
|
||||
position: "relative",
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Text
|
||||
style={[
|
||||
styles.textFont,
|
||||
styles.textColor,
|
||||
styles.textBold,
|
||||
{ fontSize: 10 },
|
||||
]}
|
||||
>
|
||||
<Text style={[styles.textColor, styles.textBold, { fontSize: 10 }]}>
|
||||
{module}
|
||||
</Text>
|
||||
<Text>{score}</Text>
|
||||
<Text>Out of {total}</Text>
|
||||
<Image src={png} style={{ height: "64px", width: "64px" }}></Image>
|
||||
<View
|
||||
style={[
|
||||
styles.textColor,
|
||||
{
|
||||
display: "flex",
|
||||
position: "absolute",
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
fontSize: 10,
|
||||
gap: 8,
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Text style={styles.textBold}>{score}</Text>
|
||||
<Text style={{ fontSize: 8 }}>out of {total}</Text>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
|
||||
@@ -5,4 +5,5 @@ export interface ModuleScore {
|
||||
total: number;
|
||||
module: Module | 'Overall';
|
||||
feedback?: string,
|
||||
png?: string,
|
||||
}
|
||||
@@ -125,6 +125,15 @@ const generateQRCode = async (link: string) => {
|
||||
}
|
||||
};
|
||||
|
||||
type RADIAL_PROGRESS_COLOR = 'laranja' | 'azul';
|
||||
|
||||
const getRadialProgressPNG = (color: RADIAL_PROGRESS_COLOR, score: number, total: number) => {
|
||||
const percent = (score / total) * 100;
|
||||
const remainder = percent % 10;
|
||||
const roundedPercent = percent - remainder;
|
||||
return `public/radial_progress/${color}_${roundedPercent}.png`;
|
||||
}
|
||||
|
||||
async function post(req: NextApiRequest, res: NextApiResponse) {
|
||||
if (req.session.user) {
|
||||
const { id } = req.query as { id: string };
|
||||
@@ -154,7 +163,7 @@ async function post(req: NextApiRequest, res: NextApiResponse) {
|
||||
const user = docUser.data() as User;
|
||||
|
||||
const stats = docsSnap.docs.map((d) => d.data());
|
||||
const results = stats.reduce((accm: ModuleScore[], { module, score }) => {
|
||||
const results = (stats.reduce((accm: ModuleScore[], { module, score }) => {
|
||||
const fixedModuleStr = module[0].toUpperCase() + module.substring(1);
|
||||
if (accm.find((e: ModuleScore) => e.module === fixedModuleStr)) {
|
||||
return accm.map((e: ModuleScore) => {
|
||||
@@ -179,7 +188,13 @@ async function post(req: NextApiRequest, res: NextApiResponse) {
|
||||
feedback: getFeedback(module),
|
||||
},
|
||||
];
|
||||
}, []) as ModuleScore[];
|
||||
}, []) as ModuleScore[]).map((moduleScore) => {
|
||||
const { score, total } = moduleScore;
|
||||
return {
|
||||
...moduleScore,
|
||||
png: getRadialProgressPNG('azul', score, total),
|
||||
}
|
||||
});
|
||||
|
||||
const [stat] = stats as Stat[];
|
||||
|
||||
@@ -196,6 +211,7 @@ async function post(req: NextApiRequest, res: NextApiResponse) {
|
||||
module: "Overall",
|
||||
score: overallScore,
|
||||
total: overallTotal,
|
||||
png: getRadialProgressPNG('laranja', overallScore, overallTotal),
|
||||
} as ModuleScore;
|
||||
const testDetails = [overallDetail, ...results];
|
||||
const renderDetails = () => {
|
||||
|
||||