From 4ca5ac55a4d37427cbe9f8ac4774d50417c52612 Mon Sep 17 00:00:00 2001 From: hayamaster Date: Wed, 29 Nov 2023 19:02:17 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EB=8B=B5=EB=B3=80=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EC=88=98=EC=8B=A0=EC=9E=90=20=EC=84=A0?= =?UTF-8?q?=ED=83=9D=20=EB=93=9C=EB=A1=AD=EB=8B=A4=EC=9A=B4=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Header/index.tsx | 2 +- src/components/Profile/index.tsx | 4 +- .../ReviewReplyStart/ReviewSelect.tsx | 83 ++++++++++--------- 3 files changed, 46 insertions(+), 43 deletions(-) diff --git a/src/components/Header/index.tsx b/src/components/Header/index.tsx index e6c79cbe..307cb4da 100644 --- a/src/components/Header/index.tsx +++ b/src/components/Header/index.tsx @@ -67,7 +67,7 @@ const Header = memo(({ handleGoBack }: HeaderProps) => { onClick={toggle} > {darkMode ? ( - + ) : ( )} diff --git a/src/components/Profile/index.tsx b/src/components/Profile/index.tsx index 2765ed6b..2dbda922 100644 --- a/src/components/Profile/index.tsx +++ b/src/components/Profile/index.tsx @@ -7,7 +7,9 @@ interface ProfileProps { } const Profile = ({ - image = , + image = ( + + ), name, className, }: ProfileProps) => { diff --git a/src/pages/ReviewReplyPage/components/ReviewReplyStart/ReviewSelect.tsx b/src/pages/ReviewReplyPage/components/ReviewReplyStart/ReviewSelect.tsx index ccc9e3d2..127bbe2c 100644 --- a/src/pages/ReviewReplyPage/components/ReviewReplyStart/ReviewSelect.tsx +++ b/src/pages/ReviewReplyPage/components/ReviewReplyStart/ReviewSelect.tsx @@ -1,6 +1,6 @@ import { ChangeEvent, useState, Dispatch, SetStateAction } from 'react' import { SubmitHandler, useFieldArray, useFormContext } from 'react-hook-form' -import { Profile, SearchBar } from '@/components' +import { Profile, SearchBar, Dropdown } from '@/components' import { useUser } from '@/apis/hooks' import { CloseIcon } from '@/assets/icons' import { Question } from '@/types' @@ -12,7 +12,6 @@ interface ReceiverSelectProps { } const ReceiverSelect = ({ setReviewStep, questions }: ReceiverSelectProps) => { - const [focus, setFocus] = useState(false) const [name, setName] = useState('') const { data: user } = useUser() @@ -106,7 +105,6 @@ const ReceiverSelect = ({ setReviewStep, questions }: ReceiverSelectProps) => { 'nonReceiverList', nonReceivers.sort((a, b) => a.receiverId - b.receiverId), ) - setFocus(true) } const handleChangeName = (e: ChangeEvent) => { @@ -120,44 +118,47 @@ const ReceiverSelect = ({ setReviewStep, questions }: ReceiverSelectProps) => { return (
-
- - {focus && ( -
    - {nonReceivers.length > 0 ? ( - nonReceivers - .filter((nonReceiver) => nonReceiver.name.includes(name)) - .map((nonReceiver, index) => ( -
  • { - appendReceiver(nonReceiver) - removeNonReceiver(index) - clearErrors('receiverList') - setFocus(false) - }} - key={nonReceiver.id} - className={`${index !== 0 && 'border-t'} ${ - index != nonReceivers.length - 1 && 'border-b' - } cursor-pointer border-gray-400 px-2.5 py-2.5 hover:bg-main-ivory dark:border-gray-300 dark:hover:bg-gray-300`} - > - -
  • - )) - ) : ( -

    - 더 이상 선택할 수 있는 유저가 없습니다. -

    - )} -
- )} -
+ + + + + + {nonReceivers.length > 0 ? ( + nonReceivers + .filter((nonReceiver) => nonReceiver.name.includes(name)) + .map((nonReceiver, index) => ( + { + const nonReceiverIndex = nonReceivers.findIndex( + (target) => target === nonReceiver, + ) + appendReceiver(nonReceiver) + removeNonReceiver(nonReceiverIndex) + clearErrors('receiverList') + setName('') + }} + > + + + )) + ) : ( + + {'더 이상 선택할 수 있는 유저가 없습니다.'} + + )} + +