Skip to content

Commit

Permalink
Fix: hid view submissions button
Browse files Browse the repository at this point in the history
  • Loading branch information
Akalanka47000 committed Sep 15, 2024
1 parent a037a52 commit e7f31ed
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/components/questions/question-details/action-buttons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const ActionButtons = ({ question, className, buttonClassName }) => {
const navigate = useNavigate();
const { data: { data: authUser } = {} } = useAuthUserQuery();

if (authUser?.role !== "ADMIN") return <></>;

return (
<div className={twMerge("flex flex-col md:flex-row gap-3 mt-1", className)}>
<Button
Expand All @@ -23,16 +25,14 @@ const ActionButtons = ({ question, className, buttonClassName }) => {
>
View submissions
</Button>
{authUser?.role == "ADMIN" && (
<Button
variant="secondary"
className={twMerge("bg-transparent", buttonClassName)}
onClick={() => onEditClick(question)}
disabled={!question}
>
Edit
</Button>
)}
<Button
variant="secondary"
className={twMerge("bg-transparent", buttonClassName)}
onClick={() => onEditClick(question)}
disabled={!question}
>
Edit
</Button>
</div>
);
};
Expand Down
12 changes: 12 additions & 0 deletions src/pages/submissions.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { useState } from "react";
import { useMemo } from "react";
import { useEffect } from "react";
import { useParams } from "react-router-dom";
import { useNavigate } from "react-router-dom";
import { GradeDialog, Submission, SubmissionListSkeleton } from "@/components/submissions";
import { submissionFilters, submissionSorts } from "@/filters";
import { useTitle } from "@/hooks";
import {
useAuthUserQuery,
useGetAllSubmissionsQuery,
useGetAllUsersQuery,
useGetQuestionByIdQuery,
Expand All @@ -23,6 +26,7 @@ import { Body2 } from "@sliit-foss/bashaway-ui/typography";
import { computeFilterQuery, computeSortQuery } from "@sliit-foss/bashaway-ui/utils";

const Submissions = () => {
const navigate = useNavigate();
const { id: questionId } = useParams();

const [page, setPage] = useState(1);
Expand All @@ -35,6 +39,8 @@ const Submissions = () => {

const { data: { data: teams } = {} } = useGetAllUsersQuery({ filters: `filter[role]=GROUP` });

const { data: { data: authUser } = {} } = useAuthUserQuery();

const {
data: submissions,
isFetching,
Expand All @@ -60,6 +66,12 @@ const Submissions = () => {

useTitle("Submissions | Bashaway");

useEffect(() => {
if (authUser && authUser.role !== "ADMIN") {
navigate("/");
}
}, [authUser]);

return (
<>
<BreadCrumbs
Expand Down

0 comments on commit e7f31ed

Please sign in to comment.