Skip to content

Commit

Permalink
fix : 검색창 정렬순서 단축 평가 적용
Browse files Browse the repository at this point in the history
- 정렬 로직을 단축 평가를 활용하여 단순화 하였습니다.
  • Loading branch information
oxomi committed Jun 3, 2024
1 parent 487fd39 commit e3f3b74
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,9 @@ const MemberTypeChangeInput = ({
}: MemberTypeChangeInputProps) => {
const options: { value: number; label: string; group: string }[] = [];
memberList?.forEach((data) => options.push({ value: data.memberId, label: data.realName, group: data.generation }));
const sortedOptions = options.sort((a, b) => {
const aGroup = parseFloat(a.group);
const bGroup = parseFloat(b.group);
if (aGroup !== bGroup) {
return aGroup - bGroup;
}
return a.label.localeCompare(b.label);
});
const sortedOptions = options.sort(
(a, b) => parseFloat(a.group) - parseFloat(b.group) || a.label.localeCompare(b.label),
);

return (
<AutoComplete
Expand Down
11 changes: 3 additions & 8 deletions src/pages/admin/DutyManage/Modal/ChangeRolePersonModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,9 @@ const ChangeRolePersonModal = ({ open, toggleOpen, jobName, badgeImage }: Change

const options: { value: number; label: string; group: string }[] = [];
memberList?.forEach((data) => options.push({ value: data.memberId, label: data.realName, group: data.generation }));
const sortedOptions = options.sort((a, b) => {
const aGroup = parseFloat(a.group);
const bGroup = parseFloat(b.group);
if (aGroup !== bGroup) {
return aGroup - bGroup;
}
return a.label.localeCompare(b.label);
});
const sortedOptions = options.sort(
(a, b) => parseFloat(a.group) - parseFloat(b.group) || a.label.localeCompare(b.label),
);

const [value, setValue] = useState<SingleAutoCompleteValue>(null);
const [prevInfo, setPrevInfo] = useState<{ value: number; label: string; group: string }>({
Expand Down

0 comments on commit e3f3b74

Please sign in to comment.