Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
Festivelo_frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Festivelo
Festivelo_frontend
Commits
e40412f2
Commit
e40412f2
authored
6 months ago
by
pjookim
Browse files
Options
Downloads
Patches
Plain Diff
refactor: improve place filtering logic in AddPlace component
parent
67bddcab
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/components/AddPlace.js
+8
-5
8 additions, 5 deletions
src/components/AddPlace.js
with
8 additions
and
5 deletions
src/components/AddPlace.js
+
8
−
5
View file @
e40412f2
...
@@ -157,23 +157,26 @@ const AddPlace = ({ tripId, day, onBack, onPlaceSelect, tripStartDate, tripEndDa
...
@@ -157,23 +157,26 @@ const AddPlace = ({ tripId, day, onBack, onPlaceSelect, tripStartDate, tripEndDa
const
currentState
=
tabStates
[
activeTab
];
const
currentState
=
tabStates
[
activeTab
];
if
(
!
currentState
.
places
)
return
[];
if
(
!
currentState
.
places
)
return
[];
// 검색어가 있을 때는 검색 결과만 반환
if
(
searchKeyword
.
trim
())
{
return
currentState
.
places
;
}
// 검색어가 없을 때만 즐겨찾기와 일반 항목 표시
const
currentTypeId
=
CONTENT_TYPE
[
activeTab
];
const
currentTypeId
=
CONTENT_TYPE
[
activeTab
];
const
currentAreaCode
=
getAreaCode
(
location
);
const
currentAreaCode
=
getAreaCode
(
location
);
// 현재 탭과 지역에 맞는 즐겨찾기 항목 필터링
const
matchingFavorites
=
favoriteItems
.
filter
(
place
=>
const
matchingFavorites
=
favoriteItems
.
filter
(
place
=>
String
(
place
.
type
)
===
currentTypeId
&&
String
(
place
.
type
)
===
currentTypeId
&&
place
.
areaCode
===
currentAreaCode
place
.
areaCode
===
currentAreaCode
);
);
// 즐겨찾기에 없는 일반 항목들만 필터링
const
nonFavoriteItems
=
currentState
.
places
.
filter
(
place
=>
const
nonFavoriteItems
=
currentState
.
places
.
filter
(
place
=>
!
favorites
.
has
(
place
.
id
)
!
favorites
.
has
(
place
.
id
)
);
);
// 즐겨찾기 항목을 먼저, 그 다음에 일반 항목들
return
[...
matchingFavorites
,
...
nonFavoriteItems
];
return
[...
matchingFavorites
,
...
nonFavoriteItems
];
},
[
tabStates
[
activeTab
].
places
,
favoriteItems
,
activeTab
,
location
,
favorites
]);
},
[
tabStates
[
activeTab
].
places
,
favoriteItems
,
activeTab
,
location
,
favorites
,
searchKeyword
]);
const
toggleFavorite
=
async
(
place
)
=>
{
const
toggleFavorite
=
async
(
place
)
=>
{
if
(
!
user
)
{
if
(
!
user
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment