fixed title on test page

This commit is contained in:
David Katrinka 2026-01-17 20:44:39 +01:00
parent b6bab996e5
commit fc601b765a
2 changed files with 7 additions and 3 deletions

2
.env
View File

@ -1 +1 @@
VITE_API_URL=http://192.168.0.11:8000 VITE_API_URL=https://lycoreco.stud.vts.su.ac.rs

View File

@ -10,6 +10,7 @@ import LearningAnswers from "../../components/Answers/Answers";
import { formatDate } from "../../utils/functions"; import { formatDate } from "../../utils/functions";
import NotFoundPage from "../NotFoundPage/NotFoundPage"; import NotFoundPage from "../NotFoundPage/NotFoundPage";
import { useAuth } from "../../context/AuthContext"; import { useAuth } from "../../context/AuthContext";
import { useGetTestById } from "../../hooks/tests/useGetTestById";
export const TestPage = () => { export const TestPage = () => {
const { id } = useParams(); const { id } = useParams();
@ -19,6 +20,7 @@ export const TestPage = () => {
const submitAnswerMutation = useSubmitAnswer(); const submitAnswerMutation = useSubmitAnswer();
const completeTestMutation = useCompleteTest(); const completeTestMutation = useCompleteTest();
const allAnswered = test?.answers?.every((ans) => ans.answer !== null); const allAnswered = test?.answers?.every((ans) => ans.answer !== null);
const { data: createdTest } = useGetTestById(test?.test_id ?? undefined);
const handleCompleteTest = () => { const handleCompleteTest = () => {
if (test) completeTestMutation.mutate(test.id); if (test) completeTestMutation.mutate(test.id);
@ -37,7 +39,7 @@ export const TestPage = () => {
if (!test) return <NotFoundPage />; if (!test) return <NotFoundPage />;
if (!test.is_available && !test.is_completed && user?.type == 'user') if (!test.is_available && !test.is_completed && user?.type == "user")
return ( return (
<Container> <Container>
<Typography variant="h6" color="textSecondary"> <Typography variant="h6" color="textSecondary">
@ -87,7 +89,9 @@ export const TestPage = () => {
mb: 4, mb: 4,
}} }}
> >
<Typography variant="h2">{test.test?.title ?? "User Test"}</Typography> <Typography variant="h2">
{createdTest?.title ?? "User Test"}
</Typography>
<Typography variant="subtitle1"> <Typography variant="subtitle1">
Expires at: {test.closed_at ? formatDate(test.closed_at) : "N/A"} Expires at: {test.closed_at ? formatDate(test.closed_at) : "N/A"}
</Typography> </Typography>