From e3f3b740280f320beaec8a7a028da1ffa54f66f7 Mon Sep 17 00:00:00 2001 From: oxomi Date: Mon, 3 Jun 2024 15:33:18 +0900 Subject: [PATCH] =?UTF-8?q?fix=20:=20=EA=B2=80=EC=83=89=EC=B0=BD=20?= =?UTF-8?q?=EC=A0=95=EB=A0=AC=EC=88=9C=EC=84=9C=20=EB=8B=A8=EC=B6=95=20?= =?UTF-8?q?=ED=8F=89=EA=B0=80=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 정렬 로직을 단축 평가를 활용하여 단순화 하였습니다. --- .../Input/MemberTypeChangeInput.tsx | 11 +++-------- .../admin/DutyManage/Modal/ChangeRolePersonModal.tsx | 11 +++-------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/pages/admin/ActiveMemberManage/Input/MemberTypeChangeInput.tsx b/src/pages/admin/ActiveMemberManage/Input/MemberTypeChangeInput.tsx index 66ac2250..63c3356c 100644 --- a/src/pages/admin/ActiveMemberManage/Input/MemberTypeChangeInput.tsx +++ b/src/pages/admin/ActiveMemberManage/Input/MemberTypeChangeInput.tsx @@ -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 ( 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(null); const [prevInfo, setPrevInfo] = useState<{ value: number; label: string; group: string }>({