Merged develop into bug-fixing-19-MAR

This commit is contained in:
João Ramos
2024-03-21 11:21:28 +00:00
7 changed files with 64 additions and 29 deletions

View File

@@ -1,5 +1,6 @@
import {Ticket, TicketType, TicketTypeLabel} from "@/interfaces/ticket"; import {Ticket, TicketType, TicketTypeLabel} from "@/interfaces/ticket";
import {User} from "@/interfaces/user"; import {User} from "@/interfaces/user";
import useExamStore from "@/stores/examStore";
import axios from "axios"; import axios from "axios";
import {useState} from "react"; import {useState} from "react";
import {toast} from "react-toastify"; import {toast} from "react-toastify";
@@ -20,6 +21,8 @@ export default function TicketSubmission({user, page, onClose}: Props) {
const [description, setDescription] = useState(""); const [description, setDescription] = useState("");
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
const examState = useExamStore((state) => state);
const submit = () => { const submit = () => {
if (!type) return toast.error("Please choose a type!", {toastId: "missing-type"}); if (!type) return toast.error("Please choose a type!", {toastId: "missing-type"});
if (subject.trim() === "") if (subject.trim() === "")
@@ -48,6 +51,18 @@ export default function TicketSubmission({user, page, onClose}: Props) {
type, type,
reportedFrom: page, reportedFrom: page,
description, 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 axios

View File

@@ -75,7 +75,7 @@ export default function Navbar({user, path, navDisabled = false, focusMode = fal
<button <button
className={clsx( className={clsx(
"border-mti-purple-light tooltip tooltip-bottom flex h-8 w-8 flex-col items-center justify-center rounded-full border p-1", "border-mti-purple-light tooltip tooltip-bottom flex h-8 w-8 flex-col items-center justify-center rounded-full border p-1",
"hover:bg-mti-purple-light transition duration-300 ease-in-out hover:text-white", "hover:bg-mti-purple-light transition duration-300 ease-in-out hover:text-white z-20",
)} )}
data-tip="Submit a help/feedback ticket" data-tip="Submit a help/feedback ticket"
onClick={() => setIsTicketOpen(true)}> onClick={() => setIsTicketOpen(true)}>

View File

@@ -16,6 +16,8 @@ import {
BsPencilSquare, BsPencilSquare,
BsBank, BsBank,
BsCurrencyDollar, BsCurrencyDollar,
BsLayoutWtf,
BsLayoutSidebar,
} from "react-icons/bs"; } from "react-icons/bs";
import UserCard from "@/components/UserCard"; import UserCard from "@/components/UserCard";
import useGroups from "@/hooks/useGroups"; import useGroups from "@/hooks/useGroups";
@@ -309,6 +311,12 @@ export default function AdminDashboard({user}: Props) {
value={pending.length} value={pending.length}
color="rose" color="rose"
/> />
<IconCard
onClick={() => router.push("https://cms.encoach.com/admin")}
Icon={BsLayoutSidebar}
label="Content Management System (CMS)"
color="green"
/>
</section> </section>
<section className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 w-full justify-between"> <section className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 w-full justify-between">

View File

@@ -4,8 +4,8 @@ import {IconType} from "react-icons";
interface Props { interface Props {
Icon: IconType; Icon: IconType;
label: string; label: string;
value: string | number; value?: string | number;
color: "purple" | "rose" | "red"; color: "purple" | "rose" | "red" | "green";
tooltip?: string; tooltip?: string;
onClick?: () => void; onClick?: () => void;
} }
@@ -15,6 +15,7 @@ export default function IconCard({Icon, label, value, color, tooltip, onClick}:
purple: "text-mti-purple-light", purple: "text-mti-purple-light",
red: "text-mti-red-light", red: "text-mti-red-light",
rose: "text-mti-rose-light", rose: "text-mti-rose-light",
green: "text-mti-green-light",
}; };
return ( return (

View File

@@ -1,4 +1,5 @@
import { Type } from "./user"; import {Module} from ".";
import {Type} from "./user";
export interface Ticket { export interface Ticket {
id: string; id: string;
@@ -10,6 +11,15 @@ export interface Ticket {
description: string; description: string;
subject: string; subject: string;
assignedTo?: string; assignedTo?: string;
examInformation?: {
exams: string[];
exam: string;
selectedModules: Module[];
moduleIndex: number;
partIndex: number;
exerciseIndex: number;
questionIndex: number;
};
} }
export interface TicketReporter { export interface TicketReporter {
@@ -20,14 +30,14 @@ export interface TicketReporter {
} }
export type TicketType = "feedback" | "bug" | "help"; export type TicketType = "feedback" | "bug" | "help";
export const TicketTypeLabel: { [key in TicketType]: string } = { export const TicketTypeLabel: {[key in TicketType]: string} = {
feedback: "Feedback", feedback: "Feedback",
bug: "Bug", bug: "Bug",
help: "Help", help: "Help",
}; };
export type TicketStatus = "submitted" | "in-progress" | "completed"; export type TicketStatus = "submitted" | "in-progress" | "completed";
export const TicketStatusLabel: { [key in TicketStatus]: string } = { export const TicketStatusLabel: {[key in TicketStatus]: string} = {
submitted: "Submitted", submitted: "Submitted",
"in-progress": "In Progress", "in-progress": "In Progress",
completed: "Completed", completed: "Completed",

View File

@@ -41,7 +41,7 @@ export const getServerSideProps = withIronSessionSsr(({req, res}) => {
redirect: { redirect: {
destination: "/login", destination: "/login",
permanent: false, permanent: false,
} },
}; };
} }
@@ -50,7 +50,7 @@ export const getServerSideProps = withIronSessionSsr(({req, res}) => {
redirect: { redirect: {
destination: "/", destination: "/",
permanent: false, permanent: false,
} },
}; };
} }

View File

@@ -179,6 +179,7 @@ export default function Tickets() {
<> <>
<Modal <Modal
isOpen={!!selectedTicket} isOpen={!!selectedTicket}
title={selectedTicket ? selectedTicket.id : undefined}
onClose={() => { onClose={() => {
reload(); reload();
setSelectedTicket(undefined); setSelectedTicket(undefined);