Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
feat : prevent professor delete himself
Browse files Browse the repository at this point in the history
  • Loading branch information
kasterra committed Jun 2, 2024
1 parent 8a115ac commit f42e4c6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 24 deletions.
7 changes: 2 additions & 5 deletions app/routes/_procted+/lectures+/quiz+/edit/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import TextInput from "~/components/Input/TextInput";
import styles from "../index.module.css";
import judgeStyles from "~/css/judge.module.css";
import inputStyles from "~/components/Input/input.module.css";
import formStyles from "~/components/common/form.module.css";
import { MetaFunction, useNavigate, useSearchParams } from "@remix-run/react";
import { getUsersInLecture } from "~/API/lecture";
import { ReactNode, useEffect, useState } from "react";
import { useAuth } from "~/contexts/AuthContext";
import { QuizData, UserEntity } from "~/types/APIResponse";
import { QuizData } from "~/types/APIResponse";
import TableBase from "~/components/Table/TableBase";
import plusSquare from "~/assets/plus-square.svg";
import minusSquare from "~/assets/minus-square.svg";
Expand All @@ -16,7 +13,7 @@ import fileDownloadSVG from "~/assets/fileDownload.svg";
import { createQuizResultXlsx, parseQuizResultXlsx } from "~/util/xlsx";
import pkg from "file-saver";
import toast from "react-hot-toast";
import { createNewQuiz, getAllQuizes, updateQuiz } from "~/API/practice";
import { getAllQuizes, updateQuiz } from "~/API/practice";
import { safeParseInt } from "~/util";
import { extractStudentInfo, toTableData } from "~/util/quizUtil";
const { saveAs } = pkg;
Expand Down
40 changes: 21 additions & 19 deletions app/routes/_procted+/students+/$lectureId+/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,25 +277,27 @@ const Table = () => {
>
암호 초기화
</button>
<button
className={tableStyles["out-user"]}
onClick={async () => {
if (confirm("정말로 해당 유저를 내보내시겠습니까?")) {
await toast.promise(
removeUserInLecture(lectureId, elem.id, auth.token),
{
loading: "내보내기 요청중...",
success: "성공적으로 유저를 내보냈습니다",
error: (err) =>
`Error: ${err.message} - ${err.responseMessage}`,
}
);
setIsLoading(true);
}
}}
>
회원 삭제하기
</button>
{(elem as any).lecture_role === "professor" ? null : (
<button
className={tableStyles["out-user"]}
onClick={async () => {
if (confirm("정말로 해당 유저를 내보내시겠습니까?")) {
await toast.promise(
removeUserInLecture(lectureId, elem.id, auth.token),
{
loading: "내보내기 요청중...",
success: "성공적으로 유저를 내보냈습니다",
error: (err) =>
`Error: ${err.message} - ${err.responseMessage}`,
}
);
setIsLoading(true);
}
}}
>
회원 삭제하기
</button>
)}
</>,
],
])
Expand Down

0 comments on commit f42e4c6

Please sign in to comment.