11import { useEffect , useState } from 'react' ;
22import * as S from './ContentTab.styled' ;
33import { Link , Outlet , useLocation } from 'react-router-dom' ;
4- import { ROUTES } from '../../../constants/routes' ;
54import ScrollWrapper from './ScrollWrapper' ;
65import MovedInquiredLink from '../customerService/MoveInquiredLink' ;
6+ import { ADMIN_ROUTE , ROUTES } from '../../../constants/routes' ;
77
88interface Filter {
99 title : string ;
@@ -19,29 +19,35 @@ interface ContentProps {
1919
2020export 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