diff --git a/index.html b/index.html
index caabf63..eee5c8f 100644
--- a/index.html
+++ b/index.html
@@ -5,10 +5,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
= ({ user }) => {
Hello, {user.username}
{
(user.role === "admin" || user.role === "moderator") &&
- [{user.role}]
+ [{user.role}]
}
diff --git a/src/hocs/withAuth.tsx b/src/hocs/withAuth.tsx
index bcab672..b01fbdd 100644
--- a/src/hocs/withAuth.tsx
+++ b/src/hocs/withAuth.tsx
@@ -1,8 +1,8 @@
-import { UserToken } from "@/models/AuthModels/userToken";
+import { role, UserToken } from "@/models/AuthModels/userToken";
import React, { useEffect, useState, ComponentType } from "react";
import { useNavigate } from "react-router-dom";
-const withAuth = (WrappedComponent: ComponentType
, requiredRole?: "admin") => {
+const withAuth =
(WrappedComponent: ComponentType
, requiredRole?: role) => {
const ComponentWithAuth: React.FC
= (props) => {
const navigate = useNavigate();
const [isAuthenticated, setIsAuthenticated] = useState(false);
@@ -23,7 +23,7 @@ const withAuth = (WrappedComponent: ComponentType
, required
return null;
}
- if (requiredRole && user.role !== requiredRole) {
+ if (user.role !== "admin" && user.role !== requiredRole) {
navigate("/unauthorized");
return null;
}
diff --git a/src/modals/EditQuest/EditQuest.tsx b/src/modals/EditQuest/EditQuest.tsx
index f99c6e0..8392fb3 100644
--- a/src/modals/EditQuest/EditQuest.tsx
+++ b/src/modals/EditQuest/EditQuest.tsx
@@ -7,7 +7,7 @@ import { DEFAULT_IMG_URL } from '@/constants';
interface ModalProps {
onClose: () => void;
- onDeleteQuest: () => void;
+ onDeleteQuest?: () => void;
onEditQuest: (newQuest: EditQuestRequest) => void;
quest: Quest;
categories: Category[];
@@ -153,12 +153,15 @@ const EditQuest: React.FC = (props) => {
onClick={onClose}>
close
-
+ {
+ onDeleteQuest &&
+
+ }
-
+ {
+ onDeleteSuggestion &&
+
+ }
@@ -169,6 +176,7 @@ const EditSuggestion: React.FC
= (props) => {
onCreateQuest &&