Skip to content

Commit 13bb52f

Browse files
authored
Merge pull request #350 from devpalsPlus/feat/#348
"관리자 회원 상세 조회 페이지" API 연결 ( feat/#348 )
2 parents 453a09e + 8290df9 commit 13bb52f

File tree

35 files changed

+392
-104
lines changed

35 files changed

+392
-104
lines changed

src/api/activityLog.api.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { ApiAllInquiries } from '../models/admin/mainPreview';
21
import type { ApiMyComments, ApiMyInquiries } from './../models/activityLog';
32
import { httpClient } from './http.api';
43

src/api/admin/customerService/FAQ.api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ApiCommonBasicType } from '../../../models/apiCommon';
1+
import type { ApiCommonBasicType } from '../../../models/apiCommon';
22
import type { ApiFAQDetail, WriteBody } from '../../../models/customerService';
33
import { httpClient } from '../../http.api';
44

src/api/admin/user.api.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import type { ApiUserApplicantsData } from '../../models/admin/userDetail/userDetail.applicants';
2+
import type { ApiUserProjectDataResponse } from '../../models/admin/userDetail/userProjectData';
3+
import { httpClient } from '../http.api';
4+
5+
export const postBanUser = async (id: string) => {
6+
try {
7+
await httpClient.post(`/ban/${id}`);
8+
} catch (e) {
9+
console.error(e);
10+
throw e;
11+
}
12+
};
13+
14+
export const postWarningUser = async (id: string) => {
15+
try {
16+
await httpClient.post(`/warning/${id}`);
17+
} catch (e) {
18+
console.error(e);
19+
throw e;
20+
}
21+
};
22+
23+
export const getUserApplicants = async (
24+
projectId: number,
25+
applicantId: number
26+
) => {
27+
try {
28+
const response = await httpClient.get<ApiUserApplicantsData>(
29+
`/admin/project/${projectId}/full?applicantId=${applicantId}`
30+
);
31+
return response.data;
32+
} catch (e) {
33+
console.error(e);
34+
throw e;
35+
}
36+
};
37+
38+
export const getUserProjectData = async (userId: number) => {
39+
try {
40+
const response = await httpClient.get<ApiUserProjectDataResponse>(
41+
`/users/${userId}/projects`
42+
);
43+
return response.data.data.appliedProjects;
44+
} catch (e) {
45+
console.error(e);
46+
throw e;
47+
}
48+
};

src/api/admin/userActivity.api.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { httpClient } from '../http.api';
2+
import type { ApiUserActivityResponse } from '../../models/admin/userDetail/userActivity';
3+
4+
export const getUserActivityData = async (userId: number) => {
5+
try {
6+
const response = await httpClient.get<ApiUserActivityResponse>(
7+
`/users/${userId}/activities`
8+
);
9+
return response.data;
10+
} catch (e) {
11+
console.error(e);
12+
throw e;
13+
}
14+
};

src/api/mypage.api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export const getMyAppliedStatusList = async () => {
7272
'/user/applications'
7373
);
7474

75-
return response.data;
75+
return response.data.data;
7676
} catch (error) {
7777
console.error('내가 지원한 프로젝트 리스트: ', error);
7878
throw error;

src/components/admin/adminInquiry/AdminInquiryAnswerWrite.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useOutletContext } from 'react-router-dom';
22
import * as S from './AdminInquiryAnswerWrite.styled';
33
import React, { useEffect, useRef, useState } from 'react';
4-
import { InquiryAnswerBody } from '../../../models/inquiry';
4+
import type { InquiryAnswerBody } from '../../../models/inquiry';
55
import { UseMutationResult } from '@tanstack/react-query';
66
import { AxiosError } from 'axios';
77
import Modal from '../../common/modal/Modal';

src/components/admin/adminUserDetail/AdminUserDetail.tsx

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,19 @@ import useGetUserInfo from '../../../hooks/admin/useGetUserInfo';
1212
import Spinner from '../../user/mypage/Spinner';
1313
import Sidebar from '../../common/sidebar/Sidebar';
1414
import ScrollPreventor from '../../common/modal/ScrollPreventor';
15-
16-
type TabKey = 'basic' | 'log' | 'inquiry' | 'joined' | 'created' | 'applied';
15+
import useGetUserProjectData from '../../../hooks/admin/useGetUserProjectData';
16+
import type { TabKey } from '../../../models/admin/userDetail/routing';
1717

1818
const AdminUserDetail = () => {
1919
const { userId } = useParams();
2020
const { userData, isLoading, isFetching } = useGetUserInfo(Number(userId));
21+
const {
22+
userData: projectData,
23+
isLoading: projectLoading,
24+
isFetching: projectFetching,
25+
} = useGetUserProjectData(Number(userId));
2126

22-
if (isLoading || isFetching) {
27+
if (isLoading || isFetching || projectLoading || projectFetching) {
2328
return (
2429
<S.Spinner>
2530
<Spinner />
@@ -34,9 +39,9 @@ const AdminUserDetail = () => {
3439
icon: React.ReactNode;
3540
}[] = [
3641
{
37-
key: 'basic',
42+
key: 'profile',
3843
label: '기본 정보',
39-
path: `/admin/users/${userId}/${ADMIN_ROUTE.basic}`,
44+
path: `/admin/users/${userId}`,
4045
icon: <InformationCircleIcon width='17px' height='17px' />,
4146
},
4247
{
@@ -46,23 +51,11 @@ const AdminUserDetail = () => {
4651
icon: <ClipboardDocumentListIcon width='17px' height='17px' />,
4752
},
4853
{
49-
key: 'joined',
50-
label: '참여 프로젝트',
51-
path: `/admin/users/${userId}/${ADMIN_ROUTE.joinedProject}`,
52-
icon: <UserGroupIcon width='17px' height='17px' />,
53-
},
54-
{
55-
key: 'created',
56-
label: '기획 프로젝트',
57-
path: `/admin/users/${userId}/${ADMIN_ROUTE.createdProject}`,
54+
key: 'projects',
55+
label: '지원/참여/기획한 프로젝트',
56+
path: `/admin/users/${userId}/${ADMIN_ROUTE.projects}`,
5857
icon: <UserGroupIcon width='17px' height='17px' />,
5958
},
60-
{
61-
key: 'applied',
62-
label: '지원한 프로젝트',
63-
path: `/admin/users/${userId}/${ADMIN_ROUTE.appliedProject}`,
64-
icon: <ClipboardDocumentListIcon width='17px' height='17px' />,
65-
},
6659
];
6760

6861
return (
@@ -88,6 +81,7 @@ const AdminUserDetail = () => {
8881
<Outlet
8982
context={{
9083
userInfoData: userData,
84+
projectData,
9185
}}
9286
/>
9387
</S.DetailContent>

src/components/common/sidebar/Sidebar.styled.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import styled from 'styled-components';
22

3-
export const Container = styled.div<{ $isAdmin: boolean }>`
3+
export const Container = styled.div<{ $isAdmin: boolean | undefined }>`
44
display: flex;
55
flex-direction: column;
66
border: 2px solid #f0f0f0;

src/components/common/sidebar/Sidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ interface SidebarProps {
2222
const Sidebar = ({ menuItems, profileImage, nickname }: SidebarProps) => {
2323
const isLoggedIn = useAuthStore((state) => state.isLoggedIn);
2424
const location = useLocation();
25+
const isAdmin = location.pathname.includes('/admin');
2526
const isUserPage = location.pathname.includes('/user');
2627
const isManagePage = location.pathname.includes('/manage');
27-
const isAdmin = location.pathname.includes('/admin');
2828

2929
const isMyProfile = isLoggedIn && !isUserPage && !isManagePage;
3030
const getActiveIndex = useCallback(() => {

src/components/user/mypage/ContentTab.tsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { useEffect, useState } from 'react';
22
import * as S from './ContentTab.styled';
33
import { Link, Outlet, useLocation } from 'react-router-dom';
4-
import { ROUTES } from '../../../constants/routes';
54
import ScrollWrapper from './ScrollWrapper';
65
import MovedInquiredLink from '../customerService/MoveInquiredLink';
6+
import { ADMIN_ROUTE, ROUTES } from '../../../constants/routes';
77

88
interface Filter {
99
title: string;
@@ -19,29 +19,35 @@ interface ContentProps {
1919

2020
export default function ContentTab({ filter, $justifyContent }: ContentProps) {
2121
const { pathname } = useLocation();
22-
const [filterId, setFilterId] = useState<number>();
2322
const isAdmin = pathname.includes('/admin');
23+
const [filterId, setFilterId] = useState<number>();
2424

25-
function handleChangeId(id: number) {
26-
setFilterId(id);
27-
}
2825
useEffect(() => {
2926
if (
3027
pathname.includes(ROUTES.notificationsAppliedProjects) ||
31-
pathname.includes(ROUTES.activityInquiries)
28+
pathname.includes(ROUTES.activityInquiries) ||
29+
pathname.includes(ADMIN_ROUTE.appliedProject)
3230
) {
3331
return setFilterId(1);
34-
} else if (pathname.includes(ROUTES.notificationsCheckedApplicants)) {
32+
} else if (
33+
pathname.includes(ROUTES.notificationsCheckedApplicants) ||
34+
pathname.includes(ADMIN_ROUTE.joinedProject)
35+
) {
3536
return setFilterId(2);
3637
} else if (
37-
pathname.includes(`${ROUTES.myPageNotifications}/${ROUTES.comments}`)
38+
pathname.includes(`${ROUTES.myPageNotifications}/${ROUTES.comments}`) ||
39+
pathname.includes(ADMIN_ROUTE.createdProject)
3840
) {
3941
return setFilterId(3);
4042
} else {
4143
return setFilterId(0);
4244
}
4345
}, [setFilterId, pathname]);
4446

47+
function handleChangeId(id: number) {
48+
setFilterId(id);
49+
}
50+
4551
return (
4652
<S.Container>
4753
<S.FilterWrapper $justifyContent={$justifyContent}>
@@ -51,6 +57,7 @@ export default function ContentTab({ filter, $justifyContent }: ContentProps) {
5157
to={filter.url}
5258
onClick={() => handleChangeId(filter.id as number)}
5359
>
60+
{' '}
5461
<S.WrapperTitle $selected={filter?.id === filterId}>
5562
<S.FilterTitle>{filter.title}</S.FilterTitle>
5663
</S.WrapperTitle>
@@ -64,7 +71,7 @@ export default function ContentTab({ filter, $justifyContent }: ContentProps) {
6471
</S.WrapperButton>
6572
<ScrollWrapper $height='10%'>
6673
<S.FilterContainer>
67-
<Outlet />
74+
<Outlet context={{ filterId }} />
6875
</S.FilterContainer>
6976
</ScrollWrapper>
7077
</>

0 commit comments

Comments
 (0)