diff --git a/.gitignore b/.gitignore index 4264223f..bcd4b1cb 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,5 @@ yarn-debug.log* yarn-error.log* .idea +public/data/제목-없는-디자인.png +src/lib/utils/seeders.js diff --git a/src/components/admin/AdminMember/AdminMember.jsx b/src/components/admin/AdminMember/AdminMember.jsx index bea31569..6dd398f1 100644 --- a/src/components/admin/AdminMember/AdminMember.jsx +++ b/src/components/admin/AdminMember/AdminMember.jsx @@ -4,6 +4,7 @@ import { MENU } from '../../../constants/menus'; import useInput from '../../../hooks/useInput'; import { notEmptyValidation } from '../../../lib/utils/validation'; import { WhiteNarrowBlock } from '../../../styles/common/Block.styles'; +import { StyledDeleteButton } from '../../activity/ActivityCard/ActivityCard.styles'; import Input from '../../common/Input/Input'; import { StyledSearchActionButton } from '../AdminProjectForm/AdminProjectForm.styles'; import { @@ -145,6 +146,7 @@ const AdminMember = ({ onUpdateMemberRole, onSearchMember, searchMembers, + onDeleteUnacceptedMembers, roles, history, }) => { @@ -154,18 +156,32 @@ const AdminMember = ({ e.preventDefault(); onWithdrawMember(loginID); }; + const handleAcceptMember = (e, loginID) => { e.preventDefault(); onAcceptMember(loginID); }; + const handleToggleAdmin = (e, loginID, isAdmin) => { e.preventDefault(); onToggleAdmin({ loginID, isAdmin }); }; + const handleUpdateMemberRole = (e, loginID, role) => { e.preventDefault(); onUpdateMemberRole({ loginID, role }); }; + + const handleDeleteUnacceptedMembers = (e) => { + e.preventDefault(); + let result = window.confirm( + `[주의] 승인 전 회원들을 모두 탈퇴 처리 하시겠습니까? 정보는 모두 DB에서 삭제되며 복구할 수 없습니다.`, + ); + if (result) { + onDeleteUnacceptedMembers(); + } + } + const onClickSearch = (e) => { e.preventDefault(); onSearchMember(searchMember); @@ -173,6 +189,7 @@ const AdminMember = ({ onChangeSearchMember(e); }; + return ( 회원 관리 @@ -211,7 +228,7 @@ const AdminMember = ({ )} - 승인 전 회원 목록 + 승인 전 회원 목록전체 삭제 diff --git a/src/constants/statusCode.js b/src/constants/statusCode.js index 1972f510..88d2090b 100644 --- a/src/constants/statusCode.js +++ b/src/constants/statusCode.js @@ -1,11 +1,12 @@ export const SUCCESS = { - OK: 200, + OK: 200, + ACCEPTED: 202 }; export const CLIENT_ERROR = { - BAD_REQUEST: 400, - UNAUTHORIZED: 401, - FORBIDDEN: 403, - NOT_FOUND: 404, - CONFLICT: 409, -}; + BAD_REQUEST: 400, + UNAUTHORIZED: 401, + FORBIDDEN: 403, + NOT_FOUND: 404, + CONFLICT: 409, +}; \ No newline at end of file diff --git a/src/containers/admin/AdminMemberContainer/AdminMemberContainer.jsx b/src/containers/admin/AdminMemberContainer/AdminMemberContainer.jsx index 1158f441..b76cb87c 100644 --- a/src/containers/admin/AdminMemberContainer/AdminMemberContainer.jsx +++ b/src/containers/admin/AdminMemberContainer/AdminMemberContainer.jsx @@ -2,7 +2,8 @@ import AdminMember from '../../../components/admin/AdminMember/AdminMember'; import React, { useEffect, useState } from 'react'; import * as memberAPI from '../../../lib/api/member'; import Spinner from '../../../components/common/Spinner/Spinner'; -import { SUCCESS } from '../../../constants/statusCode'; +import { CLIENT_ERROR, SUCCESS } from '../../../constants/statusCode'; +import { MEMBER_ROLE } from '../../../constants/memberRoles'; const AdminMemberContainer = ({ history }) => { const [memberLoading, setMemberLoading] = useState(true); @@ -108,6 +109,23 @@ const AdminMemberContainer = ({ history }) => { }); }; + const onDeleteUnacceptedMembers = () => { + memberAPI.deleteUnacceptedMembers().then((res) => { + if (res.status === SUCCESS.OK) { + alert('승인 전 회원들을 모두 탈퇴 처리 하였습니다.'); + setMembers( + members.filter(m => m.role !== MEMBER_ROLE.UNACCEPTED) + ); + } else if (res.status === CLIENT_ERROR.FORBIDDEN) { + alert('권한이 없습니다.'); + } else { + alert('오류가 발생하여 요청을 수행할 수 없습니다.'); + } + }); + }; + + + const onSearchMember = (name) => { setSearchMembers(members.filter((member) => member.name.includes(name))); }; @@ -128,6 +146,7 @@ const AdminMemberContainer = ({ history }) => { onUpdateMemberRole={onUpdateMemberRole} onSearchMember={onSearchMember} searchMembers={searchMembers} + onDeleteUnacceptedMembers={onDeleteUnacceptedMembers} roles={roles} /> )} diff --git a/src/containers/auth/RegisterFormContainer/RegisterFormContainer.jsx b/src/containers/auth/RegisterFormContainer/RegisterFormContainer.jsx index c249ee69..be9ce6a8 100644 --- a/src/containers/auth/RegisterFormContainer/RegisterFormContainer.jsx +++ b/src/containers/auth/RegisterFormContainer/RegisterFormContainer.jsx @@ -3,7 +3,7 @@ import React, { useEffect, useState } from 'react'; import { withRouter } from 'react-router-dom'; import * as authAPI from '../../../lib/api/auth'; import { removeHeaderAccessToken } from '../../../lib/utils/axiosUtil'; -import { SUCCESS } from '../../../constants/statusCode'; +import { CLIENT_ERROR, SUCCESS } from '../../../constants/statusCode'; const RegisterFormContainer = ({ location, history }) => { const [message, setMessage] = useState(null); @@ -46,20 +46,20 @@ const RegisterFormContainer = ({ location, history }) => { }); response .then((res) => { - if (res.status === SUCCESS.OK) { + if (res.status === SUCCESS.ACCEPTED) { setMessage(null); history.push('/register/success'); } }) .catch((e) => { console.error(e); - if (e.response.status === 409) { + if (e.response.status === CLIENT_ERROR.CONFLICT) { setMessage('이미 가입된 아이디/이메일/학번입니다.'); handleModalOpen(); return; } - if (e.response.status === 400) { + if (e.response.status === CLIENT_ERROR.BAD_REQUEST) { setMessage('모든 값을 올바르게 입력해주세요.'); handleModalOpen(); return; diff --git a/src/lib/api/member.js b/src/lib/api/member.js index b101f5a6..fe9258e0 100644 --- a/src/lib/api/member.js +++ b/src/lib/api/member.js @@ -1,7 +1,7 @@ import client from './client'; export const searchMember = ({ name }) => - client.get(`/member/name?name=${name}`); + client.get(`/member/name?name=${name}`); export const getMembers = () => client.get('/member'); @@ -10,20 +10,22 @@ export const getMember = (loginID) => client.get(`/member/${loginID}`); export const getMemberActivityHours = () => client.get(`/member/hour`); export const acceptMember = (loginID) => - client.put(`/member/activate/${loginID}`); + client.put(`/member/activate/${loginID}`); export const withdrawMember = (loginID) => client.delete(`/member/${loginID}`); export const toggleAdmin = ({ loginID, isAdmin }) => - client.put(`/member/admin/${loginID}`, { toAdmin: !isAdmin }); + client.put(`/member/admin/${loginID}`, { toAdmin: !isAdmin }); export const updateMemberRole = ({ loginID, role }) => - client.put(`/member/role/${loginID}`, { role }); + client.put(`/member/role/${loginID}`, { role }); export const updateMemberRoleBySelf = ({ role }) => - client.put('/member/role', { role }); + client.put('/member/role', { role }); export const getMemberRole = () => client.get('/member/role'); export const updateMemberIsExcepted = (loginId) => - client.put(`/member/excepted/${loginId}`); + client.put(`/member/excepted/${loginId}`); + +export const deleteUnacceptedMembers = () => client.delete('/member/unaccepted'); \ No newline at end of file