-
Notifications
You must be signed in to change notification settings - Fork 0
"관리자 회원 상세 조회 페이지" API 연결 ( feat/#348 ) #350
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
Changes from 7 commits
31add2f
14498eb
74f82c6
10c2177
7bf082f
821d359
c785fa4
f2aca09
dade372
8290df9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import { ApiUserApplicantsData } from '../../models/admin/userDetail/userDetail.applicants'; | ||
| import { ApiUserProjectDataResponse } from '../../models/admin/userDetail/userProjectData'; | ||
|
||
| import { httpClient } from '../http.api'; | ||
|
|
||
| export const postBanUser = async (id: string) => { | ||
| try { | ||
| await httpClient.post(`/ban/${id}`); | ||
| } catch (e) { | ||
| console.error(e); | ||
| throw e; | ||
| } | ||
| }; | ||
|
|
||
| export const postWarningUser = async (id: string) => { | ||
| try { | ||
| await httpClient.post(`/warning/${id}`); | ||
| } catch (e) { | ||
| console.error(e); | ||
| throw e; | ||
| } | ||
| }; | ||
|
|
||
| export const getUserApplicants = async ( | ||
| projectId: number, | ||
| applicantId: number | ||
| ) => { | ||
| try { | ||
| const response = await httpClient.get<ApiUserApplicantsData>( | ||
| `/admin/project/${projectId}/full?applicantId=${applicantId}` | ||
| ); | ||
| return response.data; | ||
| } catch (e) { | ||
| console.error(e); | ||
| throw e; | ||
| } | ||
| }; | ||
|
|
||
| export const getUserProjectData = async (userId: number) => { | ||
| try { | ||
| const response = await httpClient.get<ApiUserProjectDataResponse>( | ||
| `/users/${userId}/projects` | ||
| ); | ||
| return response.data.data.appliedProjects; | ||
| } catch (e) { | ||
| console.error(e); | ||
| throw e; | ||
| } | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { httpClient } from '../http.api'; | ||
| import { ApiUserActivityResponse } from '../../models/admin/userDetail/userActivity'; | ||
|
||
|
|
||
| export const getUserActivityData = async (userId: number) => { | ||
| try { | ||
| const response = await httpClient.get<ApiUserActivityResponse>( | ||
| `/users/${userId}/activities` | ||
| ); | ||
| return response.data; | ||
| } catch (e) { | ||
| console.error(e); | ||
| throw e; | ||
| } | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,14 +12,19 @@ import useGetUserInfo from '../../../hooks/admin/useGetUserInfo'; | |
| import Spinner from '../../user/mypage/Spinner'; | ||
| import Sidebar from '../../common/sidebar/Sidebar'; | ||
| import ScrollPreventor from '../../common/modal/ScrollPreventor'; | ||
|
|
||
| type TabKey = 'basic' | 'log' | 'inquiry' | 'joined' | 'created' | 'applied'; | ||
| import useGetUserProjectData from '../../../hooks/admin/useGetUserProjectData'; | ||
| import { TabKey } from '../../../models/admin/userDetail/routing'; | ||
|
||
|
|
||
| const AdminUserDetail = () => { | ||
| const { userId } = useParams(); | ||
| const { userData, isLoading, isFetching } = useGetUserInfo(Number(userId)); | ||
| const { | ||
| userData: projectData, | ||
| isLoading: projectLoading, | ||
| isFetching: projectFetching, | ||
| } = useGetUserProjectData(Number(userId)); | ||
|
|
||
| if (isLoading || isFetching) { | ||
| if (isLoading || isFetching || projectLoading || projectFetching) { | ||
| return ( | ||
| <S.Spinner> | ||
| <Spinner /> | ||
|
|
@@ -34,9 +39,9 @@ const AdminUserDetail = () => { | |
| icon: React.ReactNode; | ||
| }[] = [ | ||
| { | ||
| key: 'basic', | ||
| key: 'profile', | ||
| label: '기본 정보', | ||
| path: `/admin/users/${userId}/${ADMIN_ROUTE.basic}`, | ||
| path: `/admin/users/${userId}`, | ||
| icon: <InformationCircleIcon width='17px' height='17px' />, | ||
| }, | ||
| { | ||
|
|
@@ -46,23 +51,11 @@ const AdminUserDetail = () => { | |
| icon: <ClipboardDocumentListIcon width='17px' height='17px' />, | ||
| }, | ||
| { | ||
| key: 'joined', | ||
| label: '참여 프로젝트', | ||
| path: `/admin/users/${userId}/${ADMIN_ROUTE.joinedProject}`, | ||
| icon: <UserGroupIcon width='17px' height='17px' />, | ||
| }, | ||
| { | ||
| key: 'created', | ||
| label: '기획 프로젝트', | ||
| path: `/admin/users/${userId}/${ADMIN_ROUTE.createdProject}`, | ||
| key: 'projects', | ||
| label: '지원/참여/기획한 프로젝트', | ||
| path: `/admin/users/${userId}/${ADMIN_ROUTE.projects}`, | ||
| icon: <UserGroupIcon width='17px' height='17px' />, | ||
| }, | ||
| { | ||
| key: 'applied', | ||
| label: '지원한 프로젝트', | ||
| path: `/admin/users/${userId}/${ADMIN_ROUTE.appliedProject}`, | ||
| icon: <ClipboardDocumentListIcon width='17px' height='17px' />, | ||
| }, | ||
| ]; | ||
|
|
||
| return ( | ||
|
|
@@ -88,6 +81,7 @@ const AdminUserDetail = () => { | |
| <Outlet | ||
| context={{ | ||
| userInfoData: userData, | ||
| projectData, | ||
| }} | ||
| /> | ||
| </S.DetailContent> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,12 @@ | ||
| import { useLocation } from 'react-router-dom'; | ||
| import { | ||
| ACTIVITY_FILTER, | ||
| ACTIVITY_FILTER_ADMIN, | ||
| } from '../../../../constants/user/myPageFilter'; | ||
| import ContentTab from '../ContentTab'; | ||
| import useAuthStore from '../../../../store/authStore'; | ||
|
|
||
| export default function ActivityLog() { | ||
| const { pathname } = useLocation(); | ||
| const isAdmin = pathname.includes('/admin'); | ||
| const isAdmin = useAuthStore().userData?.admin; | ||
|
||
|
|
||
| return ( | ||
| <ContentTab | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,10 +3,18 @@ import Spinner from '../../Spinner'; | |
| import CommentActivity from './commentActivity/CommentActivity'; | ||
| import * as S from './CommentsActivity.styled'; | ||
| import NoContent from '../../../../common/noContent/NoContent'; | ||
| import { useGetMyComments } from '../../../../../hooks/user/useGetMyComments'; | ||
| import useGetUserActivity from '../../../../../hooks/admin/useGetAllUserActivity'; | ||
| import { useParams } from 'react-router-dom'; | ||
| import { MyComments } from '../../../../../models/activityLog'; | ||
| import { UserComment } from '../../../../../models/admin/userDetail/userActivity'; | ||
|
|
||
| export default function CommentsActivity() { | ||
| const { myCommentsData, isLoading } = useGetMyComments(); | ||
| const { userId } = useParams(); | ||
|
|
||
| const { userActivityData, isLoading } = useGetUserActivity( | ||
| Number(userId), | ||
| 'comments' | ||
| ); | ||
|
|
||
| if (isLoading) { | ||
| return ( | ||
|
|
@@ -16,21 +24,27 @@ export default function CommentsActivity() { | |
| ); | ||
| } | ||
|
|
||
| if (!myCommentsData || myCommentsData.length === 0) { | ||
| if ( | ||
| !userActivityData || | ||
| !Array.isArray(userActivityData) || | ||
|
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. 이거 데이터 없어도 [] 빈배열로 들어오지않나요? 그러면 이거는 항상 true 조건 아닌가요? 그래서 length로 했던것같은데 |
||
| userActivityData.length === 0 | ||
| ) { | ||
| return ( | ||
| <S.WrapperNoContentAppliedProjects data-type='noContent'> | ||
| <NoContent type='comment' /> | ||
| </S.WrapperNoContentAppliedProjects> | ||
| ); | ||
| } | ||
|
|
||
| const commentsData = userActivityData as MyComments[] | UserComment[]; | ||
|
|
||
| return ( | ||
| <S.Container> | ||
| <S.CommentsWrapper> | ||
| {myCommentsData.map((list, idx: number) => ( | ||
| {commentsData.map((list: MyComments | UserComment, idx: number) => ( | ||
| <Fragment key={list.id}> | ||
| <CommentActivity list={list} /> | ||
| {idx !== myCommentsData.length - 1 && ( | ||
| {idx !== commentsData.length - 1 && ( | ||
| <S.CommentBorder></S.CommentBorder> | ||
| )} | ||
| </Fragment> | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,12 +1,18 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||
| import { useGetMyInquiries } from '../../../../../hooks/user/useGetMyInquiries'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| import { useParams } from 'react-router-dom'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| import useGetUserActivity from '../../../../../hooks/admin/useGetAllUserActivity'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| import ContentBorder from '../../../../common/contentBorder/ContentBorder'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| import NoContent from '../../../../common/noContent/NoContent'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| import Spinner from '../../Spinner'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| import * as S from './Inquiries.styled'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| import Inquiry from './inquiry/Inquiry'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| import { MyInquiries } from '../../../../../models/activityLog'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| export default function Inquiries() { | ||||||||||||||||||||||||||||||||||||||||||||||||
| const { myInquiriesData, isLoading } = useGetMyInquiries(); | ||||||||||||||||||||||||||||||||||||||||||||||||
| const { userId } = useParams(); | ||||||||||||||||||||||||||||||||||||||||||||||||
| const { userActivityData, isLoading } = useGetUserActivity( | ||||||||||||||||||||||||||||||||||||||||||||||||
| Number(userId), | ||||||||||||||||||||||||||||||||||||||||||||||||
| 'inquiries' | ||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+11
to
+15
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. URL 파라미터 검증 누락
export default function Inquiries() {
const { userId } = useParams();
+
+ if (!userId || isNaN(Number(userId))) {
+ return (
+ <S.WrapperNoContentAppliedProjects data-type='noContent'>
+ <NoContent type='error' />
+ </S.WrapperNoContentAppliedProjects>
+ );
+ }
+
const { userActivityData, isLoading } = useGetUserActivity(
Number(userId),
'inquiries'
);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| if (isLoading) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -16,13 +22,15 @@ export default function Inquiries() { | |||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| if (!myInquiriesData || myInquiriesData?.length === 0) | ||||||||||||||||||||||||||||||||||||||||||||||||
| if (!userActivityData || userActivityData?.length === 0) | ||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||
| <S.WrapperNoContentAppliedProjects data-type='noContent'> | ||||||||||||||||||||||||||||||||||||||||||||||||
| <NoContent type='inquiries' /> | ||||||||||||||||||||||||||||||||||||||||||||||||
| </S.WrapperNoContentAppliedProjects> | ||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| const myInquiriesData = userActivityData as MyInquiries[]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||
| <S.container> | ||||||||||||||||||||||||||||||||||||||||||||||||
| <S.InquiriesContainer> | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
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.
type