From 06684a4900ac16e6d307b28818c08eb32a2fdc77 Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Wed, 20 Mar 2024 21:24:09 +0000 Subject: [PATCH] Added the exam information to the ticket submission --- src/components/High/TicketSubmission.tsx | 15 ++++++ src/components/Navbar.tsx | 2 +- src/interfaces/ticket.ts | 58 ++++++++++++++---------- src/pages/tickets.tsx | 1 + 4 files changed, 51 insertions(+), 25 deletions(-) diff --git a/src/components/High/TicketSubmission.tsx b/src/components/High/TicketSubmission.tsx index 5671e738..3ff0ccb3 100644 --- a/src/components/High/TicketSubmission.tsx +++ b/src/components/High/TicketSubmission.tsx @@ -1,5 +1,6 @@ import {Ticket, TicketType, TicketTypeLabel} from "@/interfaces/ticket"; import {User} from "@/interfaces/user"; +import useExamStore from "@/stores/examStore"; import axios from "axios"; import {useState} from "react"; import {toast} from "react-toastify"; @@ -20,6 +21,8 @@ export default function TicketSubmission({user, page, onClose}: Props) { const [description, setDescription] = useState(""); const [isLoading, setIsLoading] = useState(false); + const examState = useExamStore((state) => state); + const submit = () => { if (!type) return toast.error("Please choose a type!", {toastId: "missing-type"}); if (subject.trim() === "") @@ -48,6 +51,18 @@ export default function TicketSubmission({user, page, onClose}: Props) { type, reportedFrom: page, description, + examInformation: + page.includes("exam") || page.includes("exercises") + ? { + exam: examState.exam?.id || "", + exams: examState.exams.map((x) => x.id), + exerciseIndex: examState.exerciseIndex, + moduleIndex: examState.moduleIndex, + partIndex: examState.partIndex, + questionIndex: examState.questionIndex, + selectedModules: examState.selectedModules, + } + : undefined, }; axios diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index 103d772f..243746b6 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -75,7 +75,7 @@ export default function Navbar({user, path, navDisabled = false, focusMode = fal