File tree Expand file tree Collapse file tree 8 files changed +117
-43
lines changed Expand file tree Collapse file tree 8 files changed +117
-43
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import useViewport from './hooks/useViewport';
44import Layout from './layouts/Layout' ;
55import MobileLayout from './layouts/MobileLayout' ;
66import AdminPage from './pages/Admin' ;
7+ import BadWordsManage from './pages/Admin/BadWords' ;
78import ReportManage from './pages/Admin/Report' ;
89import Home from './pages/Home' ;
910import 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 ) ;
Original file line number Diff line number Diff line change 1+ import AddIcon from './add.svg?react' ;
12import AlarmIcon from './alarm.svg?react' ;
23import ArrowDownIcon from './arrow-down.svg?react' ;
34import ArrowLeftIcon from './arrow-left.svg?react' ;
45import BoardIcon from './board.svg?react' ;
6+ import CancelIcon from './cancel.svg?react' ;
57import CheckIcon from './check.svg?react' ;
68import CloudIcon from './cloud.svg?react' ;
79import DeleteIcon from './delete.svg?react' ;
@@ -24,6 +26,7 @@ import ThermostatIcon from './thermostat.svg?react';
2426import WarmIcon from './warm.svg?react' ;
2527
2628export {
29+ AddIcon ,
2730 NaverIcon ,
2831 KakaoIcon ,
2932 GoogleIcon ,
@@ -48,4 +51,5 @@ export {
4851 LikeFilledIcon ,
4952 LikeOutlinedIcon ,
5053 DeleteIcon ,
54+ CancelIcon ,
5155} ;
Original file line number Diff line number Diff line change 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 ;
Original file line number Diff line number Diff line change 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+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments