Removed the exercises and exams tab from the sidebar for owners and corporate
This commit is contained in:
@@ -33,7 +33,7 @@ export default function Layout({user, children, className, navDisabled = false,
|
|||||||
focusMode={focusMode}
|
focusMode={focusMode}
|
||||||
onFocusLayerMouseEnter={onFocusLayerMouseEnter}
|
onFocusLayerMouseEnter={onFocusLayerMouseEnter}
|
||||||
className="-md:hidden"
|
className="-md:hidden"
|
||||||
showAdmin={user.type !== "student"}
|
userType={user.type}
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
className={clsx(
|
className={clsx(
|
||||||
|
|||||||
@@ -66,6 +66,8 @@ export default function MobileMenu({isOpen, onClose, path, user}: Props) {
|
|||||||
)}>
|
)}>
|
||||||
Dashboard
|
Dashboard
|
||||||
</Link>
|
</Link>
|
||||||
|
{(user.type === "student" || user.type === "teacher" || user.type === "developer") && (
|
||||||
|
<>
|
||||||
<Link
|
<Link
|
||||||
href="/exam"
|
href="/exam"
|
||||||
className={clsx(
|
className={clsx(
|
||||||
@@ -78,10 +80,13 @@ export default function MobileMenu({isOpen, onClose, path, user}: Props) {
|
|||||||
href="/exercises"
|
href="/exercises"
|
||||||
className={clsx(
|
className={clsx(
|
||||||
"transition ease-in-out duration-300 w-fit",
|
"transition ease-in-out duration-300 w-fit",
|
||||||
path === "/exercises" && "text-mti-purple-light font-semibold border-b-2 border-b-mti-purple-light ",
|
path === "/exercises" &&
|
||||||
|
"text-mti-purple-light font-semibold border-b-2 border-b-mti-purple-light ",
|
||||||
)}>
|
)}>
|
||||||
Exercises
|
Exercises
|
||||||
</Link>
|
</Link>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<Link
|
<Link
|
||||||
href="/stats"
|
href="/stats"
|
||||||
className={clsx(
|
className={clsx(
|
||||||
|
|||||||
@@ -12,13 +12,14 @@ import FocusLayer from "@/components/FocusLayer";
|
|||||||
import {preventNavigation} from "@/utils/navigation.disabled";
|
import {preventNavigation} from "@/utils/navigation.disabled";
|
||||||
import {useState} from "react";
|
import {useState} from "react";
|
||||||
import usePreferencesStore from "@/stores/preferencesStore";
|
import usePreferencesStore from "@/stores/preferencesStore";
|
||||||
|
import {Type} from "@/interfaces/user";
|
||||||
interface Props {
|
interface Props {
|
||||||
path: string;
|
path: string;
|
||||||
navDisabled?: boolean;
|
navDisabled?: boolean;
|
||||||
focusMode?: boolean;
|
focusMode?: boolean;
|
||||||
onFocusLayerMouseEnter?: () => void;
|
onFocusLayerMouseEnter?: () => void;
|
||||||
className?: string;
|
className?: string;
|
||||||
showAdmin?: boolean;
|
userType?: Type;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface NavProps {
|
interface NavProps {
|
||||||
@@ -44,7 +45,7 @@ const Nav = ({Icon, label, path, keyPath, disabled = false, isMinimized = false}
|
|||||||
</Link>
|
</Link>
|
||||||
);
|
);
|
||||||
|
|
||||||
export default function Sidebar({path, navDisabled = false, focusMode = false, showAdmin = false, onFocusLayerMouseEnter, className}: Props) {
|
export default function Sidebar({path, navDisabled = false, focusMode = false, userType, onFocusLayerMouseEnter, className}: Props) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const [isMinimized, toggleMinimize] = usePreferencesStore((state) => [state.isSidebarMinimized, state.toggleSidebarMinimized]);
|
const [isMinimized, toggleMinimize] = usePreferencesStore((state) => [state.isSidebarMinimized, state.toggleSidebarMinimized]);
|
||||||
@@ -66,11 +67,29 @@ export default function Sidebar({path, navDisabled = false, focusMode = false, s
|
|||||||
)}>
|
)}>
|
||||||
<div className="xl:flex -xl:hidden flex-col gap-3">
|
<div className="xl:flex -xl:hidden flex-col gap-3">
|
||||||
<Nav disabled={disableNavigation} Icon={MdSpaceDashboard} label="Dashboard" path={path} keyPath="/" isMinimized={isMinimized} />
|
<Nav disabled={disableNavigation} Icon={MdSpaceDashboard} label="Dashboard" path={path} keyPath="/" isMinimized={isMinimized} />
|
||||||
<Nav disabled={disableNavigation} Icon={BsFileEarmarkText} label="Exams" path={path} keyPath="/exam" isMinimized={isMinimized} />
|
{(userType === "student" || userType === "teacher" || userType === "developer") && (
|
||||||
<Nav disabled={disableNavigation} Icon={BsPencil} label="Exercises" path={path} keyPath="/exercises" isMinimized={isMinimized} />
|
<>
|
||||||
|
<Nav
|
||||||
|
disabled={disableNavigation}
|
||||||
|
Icon={BsFileEarmarkText}
|
||||||
|
label="Exams"
|
||||||
|
path={path}
|
||||||
|
keyPath="/exam"
|
||||||
|
isMinimized={isMinimized}
|
||||||
|
/>
|
||||||
|
<Nav
|
||||||
|
disabled={disableNavigation}
|
||||||
|
Icon={BsPencil}
|
||||||
|
label="Exercises"
|
||||||
|
path={path}
|
||||||
|
keyPath="/exercises"
|
||||||
|
isMinimized={isMinimized}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<Nav disabled={disableNavigation} Icon={BsGraphUp} label="Stats" path={path} keyPath="/stats" isMinimized={isMinimized} />
|
<Nav disabled={disableNavigation} Icon={BsGraphUp} label="Stats" path={path} keyPath="/stats" isMinimized={isMinimized} />
|
||||||
<Nav disabled={disableNavigation} Icon={BsClockHistory} label="Record" path={path} keyPath="/record" isMinimized={isMinimized} />
|
<Nav disabled={disableNavigation} Icon={BsClockHistory} label="Record" path={path} keyPath="/record" isMinimized={isMinimized} />
|
||||||
{showAdmin && (
|
{userType !== "student" && (
|
||||||
<Nav disabled={disableNavigation} Icon={BsShieldFill} label="Admin" path={path} keyPath="/admin" isMinimized={isMinimized} />
|
<Nav disabled={disableNavigation} Icon={BsShieldFill} label="Admin" path={path} keyPath="/admin" isMinimized={isMinimized} />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -80,7 +99,9 @@ export default function Sidebar({path, navDisabled = false, focusMode = false, s
|
|||||||
<Nav disabled={disableNavigation} Icon={BsPencil} label="Exercises" path={path} keyPath="/exercises" isMinimized={true} />
|
<Nav disabled={disableNavigation} Icon={BsPencil} label="Exercises" path={path} keyPath="/exercises" isMinimized={true} />
|
||||||
<Nav disabled={disableNavigation} Icon={BsGraphUp} label="Stats" path={path} keyPath="/stats" isMinimized={true} />
|
<Nav disabled={disableNavigation} Icon={BsGraphUp} label="Stats" path={path} keyPath="/stats" isMinimized={true} />
|
||||||
<Nav disabled={disableNavigation} Icon={BsClockHistory} label="Record" path={path} keyPath="/record" isMinimized={true} />
|
<Nav disabled={disableNavigation} Icon={BsClockHistory} label="Record" path={path} keyPath="/record" isMinimized={true} />
|
||||||
{showAdmin && <Nav disabled={disableNavigation} Icon={BsShieldFill} label="Admin" path={path} keyPath="/admin" isMinimized={true} />}
|
{userType !== "student" && (
|
||||||
|
<Nav disabled={disableNavigation} Icon={BsShieldFill} label="Admin" path={path} keyPath="/admin" isMinimized={true} />
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-col gap-0 absolute bottom-12">
|
<div className="flex flex-col gap-0 absolute bottom-12">
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import Button from "@/components/Low/Button";
|
import Button from "@/components/Low/Button";
|
||||||
import Input from "@/components/Low/Input";
|
import Input from "@/components/Low/Input";
|
||||||
|
import useUsers from "@/hooks/useUsers";
|
||||||
import {User} from "@/interfaces/user";
|
import {User} from "@/interfaces/user";
|
||||||
import {sendEmailVerification} from "@/utils/email";
|
import {sendEmailVerification} from "@/utils/email";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
@@ -24,6 +25,8 @@ export default function RegisterCorporate({isLoading, setIsLoading, mutateUser,
|
|||||||
const [companyName, setCompanyName] = useState("");
|
const [companyName, setCompanyName] = useState("");
|
||||||
const [companyUsers, setCompanyUsers] = useState(0);
|
const [companyUsers, setCompanyUsers] = useState(0);
|
||||||
|
|
||||||
|
const {users} = useUsers();
|
||||||
|
|
||||||
const onSuccess = () => toast.success("An e-mail has been sent, please make sure to check your spam folder!");
|
const onSuccess = () => toast.success("An e-mail has been sent, please make sure to check your spam folder!");
|
||||||
|
|
||||||
const onError = (e: Error) => {
|
const onError = (e: Error) => {
|
||||||
@@ -101,6 +104,7 @@ export default function RegisterCorporate({isLoading, setIsLoading, mutateUser,
|
|||||||
|
|
||||||
<Divider className="w-full !my-2" />
|
<Divider className="w-full !my-2" />
|
||||||
|
|
||||||
|
<div className="w-full flex gap-4">
|
||||||
<Input
|
<Input
|
||||||
type="text"
|
type="text"
|
||||||
name="companyName"
|
name="companyName"
|
||||||
@@ -113,10 +117,11 @@ export default function RegisterCorporate({isLoading, setIsLoading, mutateUser,
|
|||||||
type="number"
|
type="number"
|
||||||
name="companyUsers"
|
name="companyUsers"
|
||||||
onChange={(e) => setCompanyUsers(parseInt(e))}
|
onChange={(e) => setCompanyUsers(parseInt(e))}
|
||||||
placeholder="Institution name"
|
label="Amount of users"
|
||||||
defaultValue={companyUsers}
|
defaultValue={companyUsers}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
className="lg:mt-8 w-full"
|
className="lg:mt-8 w-full"
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import RegisterIndividual from "./(register)/RegisterIndividual";
|
|||||||
import RegisterCorporate from "./(register)/RegisterCorporate";
|
import RegisterCorporate from "./(register)/RegisterCorporate";
|
||||||
import EmailVerification from "./(auth)/EmailVerification";
|
import EmailVerification from "./(auth)/EmailVerification";
|
||||||
import {sendEmailVerification} from "@/utils/email";
|
import {sendEmailVerification} from "@/utils/email";
|
||||||
|
import useUsers from "@/hooks/useUsers";
|
||||||
|
|
||||||
export const getServerSideProps = (context: any) => {
|
export const getServerSideProps = (context: any) => {
|
||||||
const {code} = context.query;
|
const {code} = context.query;
|
||||||
|
|||||||
Reference in New Issue
Block a user