Skip to content

Commit c785fa4

Browse files
committed
fix : "회원 상세 조회" 부분에서 지원/참여/기획한 프로젝트 탭 부분의 선택된 탭에 적용되는 스타일 버그 해결
1 parent 821d359 commit c785fa4

File tree

3 files changed

+41
-35
lines changed

3 files changed

+41
-35
lines changed

src/components/user/mypage/ContentTab.tsx

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Link, Outlet, useLocation } from 'react-router-dom';
44
import ScrollWrapper from './ScrollWrapper';
55
import MovedInquiredLink from '../customerService/MoveInquiredLink';
66
import useAuthStore from '../../../store/authStore';
7+
import { ADMIN_ROUTE, ROUTES } from '../../../constants/routes';
78

89
interface Filter {
910
title: string;
@@ -23,15 +24,26 @@ export default function ContentTab({ filter, $justifyContent }: ContentProps) {
2324
const [filterId, setFilterId] = useState<number>();
2425

2526
useEffect(() => {
26-
const currentFilter = filter.find((item) =>
27-
pathname.includes(item.url.split('/').pop() || '')
28-
);
29-
if (currentFilter && currentFilter.id !== undefined) {
30-
setFilterId(currentFilter.id);
27+
if (
28+
pathname.includes(ROUTES.notificationsAppliedProjects) ||
29+
pathname.includes(ROUTES.activityInquiries) ||
30+
pathname.includes(ADMIN_ROUTE.appliedProject)
31+
) {
32+
return setFilterId(1);
33+
} else if (
34+
pathname.includes(ROUTES.notificationsCheckedApplicants) ||
35+
pathname.includes(ADMIN_ROUTE.joinedProject)
36+
) {
37+
return setFilterId(2);
38+
} else if (
39+
pathname.includes(`${ROUTES.myPageNotifications}/${ROUTES.comments}`) ||
40+
pathname.includes(ADMIN_ROUTE.createdProject)
41+
) {
42+
return setFilterId(3);
3143
} else {
32-
setFilterId(filter[0]?.id || 0);
44+
return setFilterId(0);
3345
}
34-
}, [pathname, filter]);
46+
}, [setFilterId, pathname]);
3547

3648
function handleChangeId(id: number) {
3749
setFilterId(id);
@@ -46,6 +58,7 @@ export default function ContentTab({ filter, $justifyContent }: ContentProps) {
4658
to={filter.url}
4759
onClick={() => handleChangeId(filter.id as number)}
4860
>
61+
{' '}
4962
<S.WrapperTitle $selected={filter?.id === filterId}>
5063
<S.FilterTitle>{filter.title}</S.FilterTitle>
5164
</S.WrapperTitle>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { ADMIN_ROUTE } from '../routes';
2+
3+
export const PROJECT_TABS = [
4+
{
5+
title: '지원한 프로젝트',
6+
url: `${ADMIN_ROUTE.appliedProject}`,
7+
id: 1,
8+
},
9+
{
10+
title: '참여한 프로젝트',
11+
url: `${ADMIN_ROUTE.joinedProject}`,
12+
id: 2,
13+
},
14+
{
15+
title: '기획한 프로젝트',
16+
url: `${ADMIN_ROUTE.createdProject}`,
17+
id: 3,
18+
},
19+
] as const;
Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,10 @@
1-
import { useParams } from 'react-router-dom';
21
import ContentTab from '../../../components/user/mypage/ContentTab';
3-
import { ADMIN_ROUTE } from '../../../constants/routes';
4-
5-
const PROJECT_TABS = [
6-
{
7-
title: '지원한 프로젝트',
8-
url: `/admin/users/:userId/${ADMIN_ROUTE.projects}/${ADMIN_ROUTE.appliedProject}`,
9-
id: 0,
10-
},
11-
{
12-
title: '참여한 프로젝트',
13-
url: `/admin/users/:userId/${ADMIN_ROUTE.projects}/${ADMIN_ROUTE.joinedProject}`,
14-
id: 1,
15-
},
16-
{
17-
title: '기획한 프로젝트',
18-
url: `/admin/users/:userId/${ADMIN_ROUTE.projects}/${ADMIN_ROUTE.createdProject}`,
19-
id: 2,
20-
},
21-
];
2+
import { PROJECT_TABS } from '../../../constants/admin/userDetailContentHeader';
223

234
export default function AdminUserProjectsLayout() {
24-
const { userId } = useParams();
25-
26-
const filter = PROJECT_TABS.map((tab) => ({
27-
...tab,
28-
url: tab.url.replace(':userId', userId ?? ''),
29-
}));
30-
315
return (
326
<div>
33-
<ContentTab filter={filter} $justifyContent='space-evenly' />
7+
<ContentTab filter={PROJECT_TABS} $justifyContent='space-evenly' />
348
</div>
359
);
3610
}

0 commit comments

Comments
 (0)