Skip to content

Commit

Permalink
refactor: 생성한리뷰관리-정렬-안되는-에러-수정 (#94)
Browse files Browse the repository at this point in the history
* refactor: 최종 리뷰 결과 반영 안되는 문제 해결

* refactor: 수신자 전체에서 검색 안되는 문제 해결

* refactor: 작성자별 정렬 추가
  • Loading branch information
khj0426 authored Nov 29, 2023
1 parent cebd276 commit 69299a8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,7 @@ const AllResponseReviewByResponser = ({
/>
<UserList
hasDrawer
users={responseByReceiver.map((receiver) => {
return {
id: receiver.receiverId,
name: receiver.receiverName,
}
})}
users={findUserBySearchKeyword}
onClickUser={({ id, name }) => setSelectedUser({ id, name })}
responserCount={responseByReceiver?.map(
(value) => value.responserCount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const AllResponseReviewByResponser = ({
const { data: responseByResponser } = useGetAllResponseByResponser({
reviewId,
}).data || { data: [] }
const [sortState, setSortState] = useState(false)
const [keyword, setKeyword] = useState('')
const [filteredUsers, setFilteredUsers] = useState(
responseByResponser.sort((a, b) => a.user.name.localeCompare(b.user.name)),
Expand All @@ -36,12 +37,22 @@ const AllResponseReviewByResponser = ({
}

const sortByName = () => {
setFilteredUsers(
() =>
[...filteredUsers]?.sort((a, b) =>
a.user.name.localeCompare(b.user.name),
),
)
if (sortState) {
setFilteredUsers(
() =>
[...filteredUsers]?.sort((a, b) =>
a.user.name.localeCompare(b.user.name),
),
)
} else {
setFilteredUsers(
() =>
[...filteredUsers]?.sort((a, b) =>
b.user.name.localeCompare(a.user.name),
),
)
}
setSortState((prevState) => !prevState)
}

const sortByResponse = () => {
Expand Down

0 comments on commit 69299a8

Please sign in to comment.