-
Notifications
You must be signed in to change notification settings - Fork 2
feat:관리자 페이지 1차 기능 구현 #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0bcc25c
feat:관리자 페이지 신고기능 구현완료(페이지네이션 제외)
wldnjs990 ed6b383
feat:관리자 페이지 검열관리 필터링 기능 개발중(검열 단어 추가 구현중)
wldnjs990 61b58f3
feat:필터링 단어 추가기능 목api연결 완료(단어 삭제는 목api가 안만들어짐) + 차단 편지목록 퍼블리싱
wldnjs990 380de17
chore:badwords, filteredLetter 라우팅 분리 + 사이드바 버튼에 라우팅 연결
wldnjs990 9426fa7
Merge branch 'develop' of https://github.com/prgrms-web-devcourse-fin…
wldnjs990 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import client from './client'; | ||
|
|
||
| const getReports = async ( | ||
| setReports: React.Dispatch<React.SetStateAction<Report[]>>, | ||
| queryString: string = '', | ||
| callBack?: () => void, | ||
| ) => { | ||
| try { | ||
| const res = await client.get(`/api/reports${queryString}`); | ||
| setReports(res.data.data); | ||
| if (callBack) callBack(); | ||
| console.log(res.data.data); | ||
| } catch (error) { | ||
| console.error(error); | ||
| } | ||
| }; | ||
|
|
||
| const patchReport = async (reportId: number, reportRequest: ReportRequest) => { | ||
| try { | ||
| console.log(`/api/reports/${reportId}`, reportRequest); | ||
| const res = await client.patch(`/api/reports/${reportId}`, reportRequest); | ||
| console.log(res); | ||
| } catch (error) { | ||
| console.error(error); | ||
| } | ||
| }; | ||
|
|
||
| // badwords | ||
| const getBadWords = async (setBadWords: React.Dispatch<React.SetStateAction<BadWords[]>>) => { | ||
| try { | ||
| const res = await client.get('/api/bad-words'); | ||
| setBadWords(res.data.data); | ||
| console.log(res); | ||
| } catch (error) { | ||
| console.error(error); | ||
| } | ||
| }; | ||
|
|
||
| const postBadWords = async (badWordsRequest: BadWords, callBack?: () => void) => { | ||
| try { | ||
| const res = await client.post('/api/bad-words', badWordsRequest); | ||
| if (callBack) callBack(); | ||
| console.log(res); | ||
| } catch (error) { | ||
| console.error(error); | ||
| } | ||
| }; | ||
|
|
||
| // 내 상상대로 만든 필터링 단어 취소 버튼 | ||
| const patchBadWords = async ( | ||
| badWordId: number, | ||
| badWordsRequest: BadWords, | ||
| callBack?: () => void, | ||
| ) => { | ||
| try { | ||
| const res = await client.patch(`/api/bad-words/${badWordId}/status`, badWordsRequest); | ||
| if (callBack) callBack(); | ||
| console.log(res); | ||
| } catch (error) { | ||
| console.error(error); | ||
| } | ||
| }; | ||
|
|
||
| export { getReports, patchReport, getBadWords, postBadWords, patchBadWords }; | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import { AlarmIcon } from '@/assets/icons'; | ||
|
|
||
| import FilteredLetterListItem from './components/FilteredLetterListItem'; | ||
| import ListHeaderFrame from './components/ListHeaderFrame'; | ||
| import WrapperFrame from './components/WrapperFrame'; | ||
| import WrapperTitle from './components/WrapperTitle'; | ||
|
|
||
| export default function FilteredLetterManage() { | ||
| const arr = new Array(10).fill(null); | ||
| return ( | ||
| <WrapperFrame> | ||
| <WrapperTitle title="필터링 단어로 차단된 편지 목록" Icon={AlarmIcon} /> | ||
| <section className="mt-5 flex flex-col"> | ||
| <ListHeaderFrame> | ||
| <span className="admin-list-set basis-1/10">ID</span> | ||
| <span className="admin-list-set basis-2/10">제보자 이메일</span> | ||
| <span className="admin-list-set basis-2/10">작성자 이메일</span> | ||
| <span className="admin-list-set basis-2/10">차단 일자</span> | ||
| <span className="admin-list-set basis-2/10">포함된 단어</span> | ||
| </ListHeaderFrame> | ||
| {arr.map((_, idx) => { | ||
| return <FilteredLetterListItem key={idx} />; | ||
| })} | ||
| </section> | ||
| </WrapperFrame> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import { useEffect, useState } from 'react'; | ||
|
|
||
| import { getBadWords } from '@/apis/admin'; | ||
| import { AddIcon, AlarmIcon, CancelIcon } from '@/assets/icons'; | ||
|
|
||
| import AddInputButton from './components/AddInputButton'; | ||
| import WrapperFrame from './components/WrapperFrame'; | ||
| import WrapperTitle from './components/WrapperTitle'; | ||
|
|
||
| export default function FilteringManage() { | ||
| const [badWords, setBadWords] = useState<BadWords[]>([]); | ||
| const [addInputShow, setAddInputShow] = useState<boolean>(false); | ||
|
|
||
| useEffect(() => { | ||
| getBadWords(setBadWords); | ||
| }, []); | ||
| return ( | ||
| <WrapperFrame> | ||
| <WrapperTitle title="필터링 단어 설정" Icon={AlarmIcon} /> | ||
| <div className="mt-5 flex w-full flex-wrap gap-4"> | ||
| {badWords.map((badWord, idx) => { | ||
| return ( | ||
| <span | ||
| key={idx} | ||
| className="flex items-center gap-1.5 rounded-2xl bg-[#C1C1C1] px-4 py-1.5" | ||
| > | ||
| {badWord.word} | ||
| <button> | ||
| <CancelIcon className="h-4 w-4" /> | ||
| </button> | ||
| </span> | ||
| ); | ||
| })} | ||
| {addInputShow ? ( | ||
| <AddInputButton setAddInputShow={setAddInputShow} setBadWords={setBadWords} /> | ||
| ) : ( | ||
| <span className="flex items-center gap-1.5 rounded-2xl bg-[#C1C1C1] px-4 py-1.5"> | ||
| 추가하기 | ||
| <button | ||
| onClick={() => { | ||
| setAddInputShow(true); | ||
| }} | ||
| > | ||
| <AddIcon className="h-4 w-4" /> | ||
| </button> | ||
| </span> | ||
| )} | ||
| </div> | ||
| </WrapperFrame> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,138 +1,58 @@ | ||
| import { useEffect, useState } from 'react'; | ||
|
|
||
| import client from '@/apis/client'; | ||
| import { getReports } from '@/apis/admin'; | ||
| import { AlarmIcon } from '@/assets/icons'; | ||
|
|
||
| import DetailFrame from './components/DetailFrame'; | ||
| import ListItem from './components/ListItem'; | ||
| import ListHeaderFrame from './components/ListHeaderFrame'; | ||
| import ReportDetailModal from './components/ReportDetailModal'; | ||
| import ReportHandlingModal from './components/ReportHandlingModal'; | ||
| import ReportListItem from './components/ReportListItem'; | ||
| import WrapperFrame from './components/WrapperFrame'; | ||
| import WrapperTitle from './components/WrapperTitle'; | ||
|
|
||
| export default function ReportManage() { | ||
| const [detailModalOpen, setDetailModalOpen] = useState<boolean>(false); | ||
| // { | ||
| // id: '001', | ||
| // reporterEmail: '[email protected]', | ||
| // targetEmail: '[email protected]', | ||
| // reportedAt: new Date(2025, 1, 20), | ||
| // letterId:2001, | ||
| // sharePostId:null, | ||
| // eventId:null, | ||
| // reportType:'LETTER', | ||
| // reason:"ABUSE", | ||
| // reasonDetail:null, | ||
| // status: 'PENDING', | ||
| // }, | ||
| const DUMMY = [ | ||
| { | ||
| id: '001', | ||
| reporterEmail: '[email protected]', | ||
| targetEmail: '[email protected]', | ||
| reportedAt: new Date(2020, 12, 4), | ||
| reason: '욕설', | ||
| }, | ||
| { | ||
| id: '002', | ||
| reporterEmail: '[email protected]', | ||
| targetEmail: '[email protected]', | ||
| reportedAt: new Date(2020, 12, 4), | ||
| reason: '욕설', | ||
| }, | ||
| { | ||
| id: '003', | ||
| reporterEmail: '[email protected]', | ||
| targetEmail: '[email protected]', | ||
| reportedAt: new Date(2000, 6, 23), | ||
| reason: '욕설', | ||
| }, | ||
| { | ||
| id: '004', | ||
| reporterEmail: '[email protected]', | ||
| targetEmail: '[email protected]', | ||
| reportedAt: new Date(1080, 11, 5), | ||
| reason: '욕설', | ||
| }, | ||
| { | ||
| id: '005', | ||
| reporterEmail: '[email protected]', | ||
| targetEmail: '[email protected]', | ||
| reportedAt: new Date(2040, 1, 2), | ||
| reason: '욕설', | ||
| }, | ||
| { | ||
| id: '006', | ||
| reporterEmail: '[email protected]', | ||
| targetEmail: '[email protected]', | ||
| reportedAt: new Date(2025, 1, 23), | ||
| reason: '욕설', | ||
| }, | ||
| ]; | ||
| const modalContents = [ | ||
| { | ||
| title: '신고 목록 삭제', | ||
| onClick: () => { | ||
| console.log('삭제'); | ||
| }, | ||
| }, | ||
| { | ||
| title: '작성자 활동 정지', | ||
| onClick: () => { | ||
| console.log('정지'); | ||
| }, | ||
| }, | ||
| ]; | ||
| const [handleModalOpen, setHandleModalOpen] = useState<boolean>(false); | ||
| const [reports, setReports] = useState<Report[]>([]); | ||
| const [selectedReport, setSelectReport] = useState<Report | null>(null); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. null보다 빈값이 낫지 않을까요?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 빈값으로 두니깐 Report | undefined로 타입이 잡히고 있어서 일단 null로 사용하고 있습니다! |
||
| const [selectedReportId, setSelectedReportId] = useState<number | null>(null); | ||
|
|
||
| // const [allReports, setAllReports] = useState(); | ||
| useEffect(() => { | ||
| const getAllReports = async () => { | ||
| const res = await client.get('/api/reports'); | ||
| console.log(res); | ||
| }; | ||
| getAllReports(); | ||
| const getReportDetail = async () => { | ||
| const res = await client.get('/api/reports/2'); | ||
| console.log(res); | ||
| }; | ||
| getReportDetail(); | ||
| const postReport = async () => { | ||
| const res = await client.post('/api/reports', { | ||
| letterId: 2010, | ||
| reportType: 'POST', | ||
| reason: 'HARASSMENT', | ||
| reasonDetail: '테스트용', | ||
| }); | ||
| console.log(res); | ||
| }; | ||
| postReport(); | ||
| getReports(setReports, '?status=PENDING'); | ||
| }, []); | ||
| return ( | ||
| <WrapperFrame> | ||
| <span className="h3-sb flex items-center gap-4.5"> | ||
| <AlarmIcon className="h-9 w-9"></AlarmIcon> 신고 편지 목록 | ||
| </span> | ||
| <WrapperTitle title="신고 편지 목록" Icon={AlarmIcon} /> | ||
|
|
||
| <section className="mt-5 flex flex-col"> | ||
| <div className="bg-primary-3 flex w-full border-b px-6 py-4"> | ||
| <div className="flex w-[80%] items-center"> | ||
| <span className="ml-4 flex basis-1/10 overflow-ellipsis">ID</span> | ||
| <span className="ml-4 flex basis-2/10">제보자 이메일</span> | ||
| <span className="ml-4 flex basis-2/10">작성자 이메일</span> | ||
| <span className="ml-4 flex basis-2/10">제보 일자</span> | ||
| <span className="ml-4 flex basis-3/10">제보 사유</span> | ||
| </div> | ||
| </div> | ||
| {DUMMY.map((data, idx) => ( | ||
| <ListItem | ||
| data={data} | ||
| modalContents={modalContents} | ||
| <ListHeaderFrame> | ||
| <span className="admin-list-set basis-1/10 overflow-ellipsis">ID</span> | ||
| <span className="admin-list-set basis-2/10">제보자 이메일</span> | ||
| <span className="admin-list-set basis-2/10">작성자 이메일</span> | ||
| <span className="admin-list-set basis-2/10">제보 일자</span> | ||
| <span className="admin-list-set basis-3/10">제보 사유</span> | ||
| </ListHeaderFrame> | ||
| {reports.map((data, idx) => ( | ||
| <ReportListItem | ||
| key={idx} | ||
| report={data} | ||
| setDetailModalOpen={setDetailModalOpen} | ||
| setSelectedReportId={setSelectedReportId} | ||
| setHandleModalOpen={setHandleModalOpen} | ||
| setSelectReport={setSelectReport} | ||
| /> | ||
| ))} | ||
| </section> | ||
| {detailModalOpen && ( | ||
| <DetailFrame closeEvent={setDetailModalOpen}> | ||
| <> | ||
| <span className="h2-sb">제보 편지 상세 조회</span> | ||
| </> | ||
| </DetailFrame> | ||
| <ReportDetailModal selectedReport={selectedReport} closeEvent={setDetailModalOpen} /> | ||
| )} | ||
| {handleModalOpen && ( | ||
| <ReportHandlingModal | ||
| setReports={setReports} | ||
| setHandleModalOpen={setHandleModalOpen} | ||
| selectedReportId={selectedReportId} | ||
| /> | ||
| )} | ||
| </WrapperFrame> | ||
| ); | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ㅋㅋㅋㅋㅋ 아직 필터링 단어 취소 API가 안만들어졌나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
무한 대기중입니다 ㅎㅎ