diff --git a/components/admin/announcement/AnnounceList.tsx b/components/admin/announcement/AnnounceList.tsx
index 5d28753dd..ee5484fa4 100644
--- a/components/admin/announcement/AnnounceList.tsx
+++ b/components/admin/announcement/AnnounceList.tsx
@@ -24,20 +24,20 @@ const Quill = dynamic(() => import('react-quill'), {
const tableTitle: { [key: string]: string } = {
content: '내용',
- createdTime: '생성일',
+ createdAt: '생성일',
creatorIntraId: '생성한 사람',
- deletedTime: '삭제일',
+ deletedAt: '삭제일',
deleterIntraId: '삭제한 사람',
- isDel: '삭제 여부',
+ modifiedAt: '수정 여부',
};
interface IAnnouncement {
content: string;
creatorIntraId: string;
deleterIntraId: string;
- deletedTime: Date;
- createdTime: Date;
- isDel: boolean;
+ deletedAt: Date;
+ createdAt: Date;
+ modifiedAt: Date;
}
interface IAnnouncementTable {
@@ -59,7 +59,7 @@ export default function AnnounceList() {
const res = await instanceInManage.get(
`/announcement?page=${currentPage}&size=5`
);
- setAnnouncementInfo({ ...res.data });
+ setAnnouncementInfo({ ...res.data, currentPage: currentPage });
} catch (e) {
console.error('MS01');
}
@@ -109,8 +109,9 @@ export default function AnnounceList() {
className={styles.tableBodyItem}
key={index}
>
- {columnName === 'createdTime' ||
- columnName === 'deletedTime'
+ {columnName === 'createdAt' ||
+ columnName === 'deletedAt' ||
+ columnName === 'modifiedAt'
? announcement[columnName as keyof IAnnouncement]
?.toString()
.replace('T', ' ')
diff --git a/components/admin/common/AdminSearchBar.tsx b/components/admin/common/AdminSearchBar.tsx
index f3d7f4884..fa1f75137 100644
--- a/components/admin/common/AdminSearchBar.tsx
+++ b/components/admin/common/AdminSearchBar.tsx
@@ -1,12 +1,7 @@
-import { useEffect, useState, useRef, useCallback } from 'react';
-import { useSetRecoilState } from 'recoil';
-import { instance } from 'utils/axios';
-import { errorState } from 'utils/recoil/error';
import { GoSearch } from 'react-icons/go';
import { IoIosCloseCircle } from 'react-icons/io';
import styles from 'styles/admin/common/AdminSearchBar.module.scss';
-
-let timer: ReturnType;
+import useSearchBar from 'hooks/useSearchBar';
const MAX_SEARCH_LENGTH = 15;
@@ -15,48 +10,24 @@ export default function AdminSearchBar({
}: {
initSearch: (intraId?: string) => void;
}) {
- const [keyword, setKeyword] = useState('');
- const [showDropDown, setShowDropDown] = useState(false);
- const [searchResult, setSearchResult] = useState([]);
- const setError = useSetRecoilState(errorState);
- const searchBarRef = useRef(null);
-
- const getSearchResultHandler = useCallback(async () => {
- try {
- const res = await instance.get(`/pingpong/users/searches?q=${keyword}`);
- setSearchResult(res?.data.users);
- } catch (e) {
- setError('MS02');
- }
- }, [keyword, setError]);
+ const {
+ keyword,
+ setKeyword,
+ keywordHandler,
+ showDropDown,
+ setShowDropDown,
+ searchResult,
+ searchBarRef,
+ } = useSearchBar();
- useEffect(() => {
- const checkId = /^[a-z|A-Z|0-9|-]+$/;
- if (keyword === '' || (keyword.length && !checkId.test(keyword))) {
- clearTimeout(timer);
- setSearchResult([]);
- } else if (checkId.test(keyword)) {
- debounce(getSearchResultHandler, 500)();
+ const adminhandleKeyDown = (event: React.KeyboardEvent) => {
+ if (event.key === 'Enter') {
+ if (keyword === searchResult[0]) {
+ setShowDropDown(false);
+ event.currentTarget.blur();
+ initSearch(keyword);
+ }
}
- }, [keyword, getSearchResultHandler]);
-
- useEffect(() => {
- document.addEventListener('mousedown', handleClickOutside);
- return () => {
- document.removeEventListener('mousedown', handleClickOutside);
- };
- }, []);
-
- const handleClickOutside = (event: MouseEvent) => {
- if (
- searchBarRef.current &&
- !searchBarRef.current.contains(event.target as Node)
- )
- setShowDropDown(false);
- };
-
- const keywordHandler = (event: React.ChangeEvent) => {
- setKeyword(event.target.value);
};
return (
@@ -64,6 +35,7 @@ export default function AdminSearchBar({
setShowDropDown(true)}
placeholder='유저 검색하기'
maxLength={MAX_SEARCH_LENGTH}
@@ -114,12 +86,3 @@ export default function AdminSearchBar({
);
}
-
-function debounce(callback: () => void, timeout: number) {
- return () => {
- clearTimeout(timer);
- timer = setTimeout(() => {
- callback();
- }, timeout);
- };
-}
diff --git a/components/admin/feedback/FeedbackTable.tsx b/components/admin/feedback/FeedbackTable.tsx
index e135097be..11f19700d 100644
--- a/components/admin/feedback/FeedbackTable.tsx
+++ b/components/admin/feedback/FeedbackTable.tsx
@@ -22,7 +22,7 @@ const tableTitle: { [key: string]: string } = {
intraId: 'intra ID',
category: '종류',
content: '내용',
- createdTime: '생성일',
+ createdAt: '생성일',
isSolved: '해결 여부',
};
@@ -31,7 +31,7 @@ export interface IFeedback {
intraId: string;
category: number; // 1: bug, 2: suggestion, 3: question
content: string;
- createdTime: Date;
+ createdAt: Date;
isSolved: boolean;
}
@@ -56,21 +56,21 @@ export default function FeedbackTable() {
const getUserFeedbacks = useCallback(async () => {
try {
const res = await instanceInManage.get(
- `/feedback/users?q=${intraId}&page=${currentPage}&size=10`
+ `/feedback?intraId=${intraId}&page=${currentPage}&size=10`
);
setIntraId(intraId);
setFeedbackInfo({
feedbackList: res.data.feedbackList.map((feedback: IFeedback) => {
const { year, month, date, hour, min } = getFormattedDateToString(
- new Date(feedback.createdTime)
+ new Date(feedback.createdAt)
);
return {
...feedback,
- createdTime: `${year}-${month}-${date} ${hour}:${min}`,
+ createdAt: `${year}-${month}-${date} ${hour}:${min}`,
};
}),
totalPage: res.data.totalPage,
- currentPage: res.data.currentPage,
+ currentPage: currentPage,
});
} catch (e) {
console.error('MS04');
@@ -85,15 +85,15 @@ export default function FeedbackTable() {
setFeedbackInfo({
feedbackList: res.data.feedbackList.map((feedback: IFeedback) => {
const { year, month, date, hour, min } = getFormattedDateToString(
- new Date(feedback.createdTime)
+ new Date(feedback.createdAt)
);
return {
...feedback,
- createdTime: `${year}-${month}-${date} ${hour}:${min}`,
+ createdAt: `${year}-${month}-${date} ${hour}:${min}`,
};
}),
totalPage: res.data.totalPage,
- currentPage: res.data.currentPage,
+ currentPage: currentPage,
});
} catch (e) {
console.error('MS03');
@@ -165,9 +165,13 @@ export default function FeedbackTable() {
- ) : value.toString().length > MAX_CONTENT_LENGTH ? (
+ ) : (value?.toString() || '').length >
+ MAX_CONTENT_LENGTH ? (
- {value.toString().slice(0, MAX_CONTENT_LENGTH)}
+ {(value?.toString() || '').slice(
+ 0,
+ MAX_CONTENT_LENGTH
+ )}
openDetailModal(feedback)}
@@ -176,7 +180,7 @@ export default function FeedbackTable() {
) : (
- value.toString()
+ value?.toString() || ''
)}
);
diff --git a/components/admin/games/GamesTable.tsx b/components/admin/games/GamesTable.tsx
index fa4af7d2b..6044b6607 100644
--- a/components/admin/games/GamesTable.tsx
+++ b/components/admin/games/GamesTable.tsx
@@ -2,9 +2,10 @@ import { useCallback, useEffect, useState } from 'react';
import PageNation from 'components/Pagination';
import { IGames, IGameLog } from 'types/admin/gameLogTypes';
import { instanceInManage } from 'utils/axios';
-import { getFormattedDateToString } from 'utils/handleTime';
+import { getFormattedDateToString, gameTimeToString } from 'utils/handleTime';
import AdminSearchBar from '../common/AdminSearchBar';
import styles from 'styles/admin/games/GamesTable.module.scss';
+import ModifyScoreForm from './ModifyScoreForm';
export default function GamesTable() {
const [currentPage, setCurrentPage] = useState
(1);
@@ -12,7 +13,6 @@ export default function GamesTable() {
const [gameInfo, setGameInfo] = useState({
gameLog: [],
totalPage: 1,
- currentPage: 1,
});
const initSearch = useCallback((intraId?: string) => {
@@ -23,7 +23,7 @@ export default function GamesTable() {
const getAllGames = useCallback(async () => {
try {
const res = await instanceInManage.get(
- `/games?season=0&page=${currentPage}&size=5`
+ `/games?page=${currentPage}&size=4`
);
setGameInfo({
@@ -37,7 +37,6 @@ export default function GamesTable() {
};
}),
totalPage: res.data.totalPage,
- currentPage: res.data.currentPage,
});
} catch (e) {
console.error('MS07');
@@ -47,7 +46,7 @@ export default function GamesTable() {
const getUserGames = useCallback(async () => {
try {
const res = await instanceInManage.get(
- `/games/users?q=${intraId}&page=${currentPage}&size=5`
+ `/games/users?intraId=${intraId}&page=${currentPage}&size=4`
);
setGameInfo({
gameLog: res.data.gameLogList.map((game: IGameLog) => {
@@ -60,7 +59,6 @@ export default function GamesTable() {
};
}),
totalPage: res.data.totalPage,
- currentPage: res.data.currentPage,
});
} catch (e) {
console.error('MS08');
@@ -80,6 +78,8 @@ export default function GamesTable() {