Skip to content

Commit 3e274f3

Browse files
authored
Merge pull request #224 from SystemConsultantGroup/develop
[HOTFIX] 토큰 문제에 대한 로그아웃 대응, 댓글 익명이름 수정, 외부인 핸들링
2 parents dcaddd0 + 651b039 commit 3e274f3

File tree

5 files changed

+14
-22
lines changed

5 files changed

+14
-22
lines changed

src/components/common/CommentBox/CommentBox.tsx

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1+
import { CheckBox } from "@/components/common/CheckBox/CheckBox";
12
import React, { useState } from "react";
23
import classes from "./CommentBox.module.css";
3-
import { CheckBox } from "@/components/common/CheckBox/CheckBox";
4-
54
interface CommentBoxProps {
65
onSubmit?: (comment: string, isAnonymous: boolean) => void;
76
commentList?: Comment[];
@@ -17,10 +16,6 @@ export const CommentBox: React.FC<CommentBoxProps> = ({ onSubmit, commentList =
1716
const [comment, setComment] = useState("");
1817
const [isAnonymous, setIsAnonymous] = useState<boolean>(true);
1918

20-
// 익명 번호 매핑을 위한 Map 객체
21-
const anonymousMap = new Map<string, number>();
22-
let anonymousCounter = 1;
23-
2419
const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
2520
setComment(e.target.value);
2621
};
@@ -59,29 +54,18 @@ export const CommentBox: React.FC<CommentBoxProps> = ({ onSubmit, commentList =
5954
</div>
6055
<CheckBox
6156
label="익명으로 작성"
62-
checked={true}
57+
checked={isAnonymous}
6358
onChange={(status) => setIsAnonymous(status)}
6459
/>
6560
</form>
6661
<div className={classes.divider}></div>
6762
<div className={classes.commentsList}>
6863
{commentList.map((commentItem, index) => {
69-
let displayAuthor = commentItem.author;
70-
71-
if (commentItem.isAnonymous) {
72-
// 익명 댓글일 경우
73-
if (!anonymousMap.has(commentItem.author)) {
74-
// 익명 번호가 없는 경우 새 번호 부여
75-
anonymousMap.set(commentItem.author, anonymousCounter++);
76-
}
77-
displayAuthor = `익명${anonymousMap.get(commentItem.author)}`;
78-
}
64+
// 익명이라면 "익명", 아니라면 author 표시
65+
const displayAuthor = commentItem.isAnonymous ? "익명" : commentItem.author;
7966

8067
return (
8168
<div key={index} className={classes.commentItem}>
82-
{/* <div className={classes.commentAuthor}>
83-
{commentItem.isAnonymous ? `익명${anonymousIndex}` : commentItem.author}
84-
</div> */}
8569
<div className={classes.commentAuthor}>{displayAuthor}</div>
8670
<div className={classes.commentContent}>{commentItem.content}</div>
8771
</div>

src/components/common/Header/Header.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { useAuth } from "../Auth";
1313

1414
export function Header() {
1515
const [isOpen, setIsOpen] = useState(false);
16-
const { isLoggedIn } = useAuth();
16+
const { isLoggedIn, logout } = useAuth(); // Destructure logout here
1717
const router = useRouter();
1818
const pathname = usePathname(); // 현재 경로 가져오기
1919

@@ -28,6 +28,11 @@ export function Header() {
2828
if (error.response?.data?.code === 4001) {
2929
router.push("/register");
3030
}
31+
32+
// 예: code 4000, 4002이 응답되면 로그아웃 수행
33+
if (error.response?.data?.code === 4000 || error.response?.data?.code === 4002) {
34+
logout();
35+
}
3136
});
3237
}
3338
}, [isLoggedIn, router, pathname]);

src/constants/LookupTables.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Role } from "@/types/user";
21
import { ProjectAwardStatus } from "@/types/project";
2+
import { Role } from "@/types/user";
33

44
export const USER_TYPE_LOOKUP_TABLE: Record<Role, string> = {
55
STUDENT: "학생",
@@ -9,6 +9,7 @@ export const USER_TYPE_LOOKUP_TABLE: Record<Role, string> = {
99
INACTIVE_PROFESSOR: "미승인 교수",
1010
INACTIVE_COMPANY: "미승인 기업관계자",
1111
OTHERS: "기타",
12+
EXTERNAL: "외부인",
1213
TEMP: "임시",
1314
};
1415

src/constants/LookupTables/USER_TYPE_LOOKUP_TABLE.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ export const USER_TYPE_LOOKUP_TABLE: Record<Role, string> = {
88
INACTIVE_PROFESSOR: "미승인 교수",
99
INACTIVE_COMPANY: "미승인 기업관계자",
1010
OTHERS: "기타",
11+
EXTERNAL: "외부인",
1112
TEMP: "임시",
1213
};

src/types/user.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export type Role =
66
| "INACTIVE_PROFESSOR"
77
| "INACTIVE_COMPANY"
88
| "OTHERS"
9+
| "EXTERNAL"
910
| "TEMP";
1011

1112
export interface IUser {

0 commit comments

Comments
 (0)