Rev 3527 | Rev 3661 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
import React from 'react';
import { useParams } from 'react-router-dom';
import { Doughnut } from 'react-chartjs-2';
import { Box, Grid, Typography } from '@mui/material';
import { useFetch } from '@shared/hooks';
import { Spinner } from '@shared/components';
export function ProgressPage() {
const { uuid } = useParams();
const { data, loading } = useFetch(`/microlearning/progress/${uuid}`);
const chartOptions = {
maintainAspectRatio: true,
responsive: true,
plugins: {
legend: {
display: false
}
}
};
if (loading || !data) {
return <Spinner />;
}
return (
<Grid container spacing={1}>
<Grid item xs={12} md={6}>
<Typography variant='h1'>Cápsulas</Typography>
<Box mx='auto' mt={2} maxWidth={400}>
<Doughnut
data={{
labels: ['Completado', 'Por completar'],
datasets: [
{
data: [data?.percentCompleted, data?.percentIncompleted],
backgroundColor: ['#16283c99', '#36a2eb99']
}
]
}}
options={chartOptions}
/>
</Box>
<Box display='flex' gap={2} justifyContent='center' alignItems='baseline' mt={1}>
<Typography variant='caption'>{data?.capsuleTotal} Total</Typography>
<Typography variant='caption'>{data?.capsuleStarted} Iniciadas</Typography>
<Typography variant='caption'>{data?.capsuleToStart} Por realizar</Typography>
<Typography variant='caption'>{data?.capsuleCompleted} Completadas</Typography>
</Box>
</Grid>
<Grid item xs={12} md={6}>
<Typography variant='h1'>Retorno</Typography>
<Box mx='auto' mt={2} maxWidth={400}>
<Doughnut
data={{
labels: ['Con retorno', 'Sin retorno'],
datasets: [
{
data: [data?.capsuleWithReturning, data?.capsuleWithoutReturning],
backgroundColor: ['#16283c99', '#36a2eb99']
}
]
}}
options={chartOptions}
/>
</Box>
</Grid>
</Grid>
);
}