Skip to content

Commit

Permalink
fix: 인원 탈주 시 검색이 되지 않는 버그 해결 (#368)
Browse files Browse the repository at this point in the history
  • Loading branch information
jinhokim98 authored Aug 16, 2024
1 parent 9634f15 commit 249fc3f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion client/src/apis/request/member.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const requestDeleteAllMemberList = async ({eventId, memberName}: WithEven
};

export type ResponseGetCurrentInMemberList = {
members: Array<{name: string}>;
memberNames: string[];
};

export const requestGetCurrentInMemberList = async (eventId: string) => {
Expand Down
12 changes: 5 additions & 7 deletions client/src/hooks/useSearchInMemberList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ const useSearchInMemberList = (
const [currentInputIndex, setCurrentInputIndex] = useState(-1);

// 서버에서 가져온 전체 리스트
const [currentInMemberList, setCurrentInMemberList] = useState<Array<{name: string}>>([]);
const [currentInMemberList, setCurrentInMemberList] = useState<Array<string>>([]);

// 검색된 리스트 (따로 둔 이유는 검색 후 클릭했을 때 리스트를 비워주어야하기 때문)
const [filteredInMemberList, setFilteredInMemberList] = useState<Array<string>>([]);

useEffect(() => {
const getCurrentInMembers = async () => {
const currentInMemberListFromServer = await fetch({queryFunction: () => requestGetCurrentInMemberList(eventId)});
setCurrentInMemberList(currentInMemberListFromServer.members);
setCurrentInMemberList(currentInMemberListFromServer.memberNames);
};

getCurrentInMembers();
Expand All @@ -40,11 +40,9 @@ const useSearchInMemberList = (
const filterMatchItems = (keyword: string) => {
if (keyword.trim() === '') return [];

const MatchItems = currentInMemberList.map(({name}) => name);

return MatchItems.filter(
matchItem => matchItem.toLocaleLowerCase().indexOf(keyword.toLocaleLowerCase()) > -1,
).slice(0, 3);
return currentInMemberList
.filter(member => member.toLocaleLowerCase().indexOf(keyword.toLocaleLowerCase()) > -1)
.slice(0, 3);
};

const chooseMember = (inputIndex: number, name: string) => {
Expand Down

0 comments on commit 249fc3f

Please sign in to comment.