Skip to content

Commit ed6b383

Browse files
committed
feat:관리자 페이지 검열관리 필터링 기능 개발중(검열 단어 추가 구현중)
1 parent 0bcc25c commit ed6b383

File tree

8 files changed

+117
-43
lines changed

8 files changed

+117
-43
lines changed

src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import useViewport from './hooks/useViewport';
44
import Layout from './layouts/Layout';
55
import MobileLayout from './layouts/MobileLayout';
66
import AdminPage from './pages/Admin';
7+
import BadWordsManage from './pages/Admin/BadWords';
78
import ReportManage from './pages/Admin/Report';
89
import Home from './pages/Home';
910
import Landing from './pages/Landing';
@@ -57,6 +58,7 @@ const App = () => {
5758

5859
<Route path="admin" element={<AdminPage />}>
5960
<Route path="report" element={<ReportManage />} />
61+
<Route path="badwords" element={<BadWordsManage />} />
6062
</Route>
6163
</Routes>
6264
);

src/assets/icons/add.svg

Lines changed: 3 additions & 0 deletions
Loading

src/assets/icons/cancel.svg

Lines changed: 3 additions & 0 deletions
Loading

src/assets/icons/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import AddIcon from './add.svg?react';
12
import AlarmIcon from './alarm.svg?react';
23
import ArrowDownIcon from './arrow-down.svg?react';
34
import ArrowLeftIcon from './arrow-left.svg?react';
45
import BoardIcon from './board.svg?react';
6+
import CancelIcon from './cancel.svg?react';
57
import CheckIcon from './check.svg?react';
68
import CloudIcon from './cloud.svg?react';
79
import DeleteIcon from './delete.svg?react';
@@ -24,6 +26,7 @@ import ThermostatIcon from './thermostat.svg?react';
2426
import WarmIcon from './warm.svg?react';
2527

2628
export {
29+
AddIcon,
2730
NaverIcon,
2831
KakaoIcon,
2932
GoogleIcon,
@@ -48,4 +51,5 @@ export {
4851
LikeFilledIcon,
4952
LikeOutlinedIcon,
5053
DeleteIcon,
54+
CancelIcon,
5155
};

src/pages/Admin/BadWords.tsx

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { useEffect, useState } from 'react';
2+
3+
import { getBadWords } from '@/apis/admin';
4+
import { AddIcon, AlarmIcon, CancelIcon } from '@/assets/icons';
5+
6+
import AddInputButton from './components/AddInputButton';
7+
import WrapperFrame from './components/WrapperFrame';
8+
import WrapperTitle from './components/WrapperTitle';
9+
10+
const BadWordsManage = () => {
11+
const [badWords, setBadWords] = useState<BadWords[]>([]);
12+
const [addInputShow, setAddInputShow] = useState<boolean>(false);
13+
14+
useEffect(() => {
15+
getBadWords(setBadWords);
16+
}, []);
17+
return (
18+
<WrapperFrame>
19+
<WrapperTitle title="필터링 단어 설정" Icon={AlarmIcon} />
20+
<div className="mt-5 flex w-full flex-wrap gap-4">
21+
{badWords.map((badWord, idx) => {
22+
return (
23+
<span
24+
key={idx}
25+
className="flex items-center gap-1.5 rounded-2xl bg-[#C1C1C1] px-4 py-1.5"
26+
>
27+
{badWord.word}
28+
<button>
29+
<CancelIcon className="h-4 w-4" />
30+
</button>
31+
</span>
32+
);
33+
})}
34+
{addInputShow ? (
35+
<AddInputButton setAddInputShow={setAddInputShow} />
36+
) : (
37+
<span className="flex items-center gap-1.5 rounded-2xl bg-[#C1C1C1] px-4 py-1.5">
38+
추가하기
39+
<button
40+
onClick={() => {
41+
setAddInputShow(true);
42+
}}
43+
>
44+
<AddIcon className="h-4 w-4" />
45+
</button>
46+
</span>
47+
)}
48+
</div>
49+
</WrapperFrame>
50+
);
51+
};
52+
53+
export default BadWordsManage;
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { useEffect, useRef } from 'react';
2+
3+
import { AddIcon } from '@/assets/icons';
4+
5+
export default function AddInputButton({
6+
setAddInputShow,
7+
}: {
8+
setAddInputShow: React.Dispatch<React.SetStateAction<boolean>>;
9+
}) {
10+
const inputRef = useRef<HTMLInputElement>(null);
11+
const handleInputWidth = (event: Event) => {
12+
const target = event.target as HTMLInputElement;
13+
target.style.width = '50px';
14+
target.style.width = `${target.scrollWidth}px`;
15+
};
16+
17+
useEffect(() => {
18+
const inputElement = inputRef.current;
19+
if (inputElement) {
20+
inputElement.addEventListener('input', handleInputWidth);
21+
inputElement.focus();
22+
}
23+
24+
return () => {
25+
if (inputElement) {
26+
inputElement.removeEventListener('input', handleInputWidth);
27+
}
28+
};
29+
}, []);
30+
31+
return (
32+
<span className="flex items-center gap-1.5 rounded-2xl bg-[#C1C1C1] px-4 py-1.5">
33+
<input
34+
ref={inputRef}
35+
type="text"
36+
className="w-10 min-w-10"
37+
onKeyDown={(e) => {
38+
if (e.key === 'Enter') {
39+
setAddInputShow(false);
40+
}
41+
}}
42+
/>
43+
<button
44+
onClick={() => {
45+
setAddInputShow(false);
46+
}}
47+
>
48+
<AddIcon className="h-4 w-4" />
49+
</button>
50+
</span>
51+
);
52+
}

src/pages/Admin/components/ListItem.tsx

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/pages/Admin/constants/index.ts

Whitespace-only changes.

0 commit comments

Comments
 (0)