From d59c23d3079a748ff99438833c9621dda80f08a4 Mon Sep 17 00:00:00 2001 From: choisohyun Date: Sat, 25 Jun 2022 22:34:39 +0900 Subject: [PATCH 01/82] =?UTF-8?q?fix:=20SearchSelector=20=EC=84=B8?= =?UTF-8?q?=EC=85=98=EC=8A=A4=ED=86=A0=EB=A6=AC=EC=A7=80=20=EC=9E=88?= =?UTF-8?q?=EC=9D=84=20=EA=B2=BD=EC=9A=B0=20=EA=B0=92=20=EC=9C=A0=EC=A7=80?= =?UTF-8?q?=EB=90=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/domain/survey/SearchSelector.tsx | 8 +++++++- src/pages/OurUniversitiesSurvey.tsx | 4 +--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/domain/survey/SearchSelector.tsx b/src/components/domain/survey/SearchSelector.tsx index 65f2e18..d1d497d 100644 --- a/src/components/domain/survey/SearchSelector.tsx +++ b/src/components/domain/survey/SearchSelector.tsx @@ -1,4 +1,4 @@ -import React, { ChangeEvent, useCallback, useRef, useState } from 'react'; +import React, { ChangeEvent, useCallback, useEffect, useRef, useState } from 'react'; import styled from 'styled-components'; import { DeleteIcon, SearchIcon } from '@/assets/img'; @@ -23,6 +23,12 @@ const SearchSelector = ({ placeholder, searchData, selectedResults, setSelectedR const findId = useCallback((value: string) => Number(searchData.find((data) => data.name === value)?.id), [searchData]); + useEffect(() => { + selectedResults.map((id) => { + setSelectedSchools(() => searchData.filter((name) => name.id === id).map(({ name }) => name)); + }); + }, []); + const handleInputChange = (e: ChangeEvent) => { const { value } = e.target; const id = findId(value); diff --git a/src/pages/OurUniversitiesSurvey.tsx b/src/pages/OurUniversitiesSurvey.tsx index b2c54d0..7ce9ef6 100644 --- a/src/pages/OurUniversitiesSurvey.tsx +++ b/src/pages/OurUniversitiesSurvey.tsx @@ -9,11 +9,9 @@ import { useMeetingSessionState } from '@/hooks/common'; const OurUniversitiesSurvey = () => { const meetingNavigate = useMeetingNavigate(); - const [ourUniversities, setOurUniversities] = useState([]); const { initMeetingState, setMeetingData } = useMeetingSessionState(); + const [ourUniversities, setOurUniversities] = useState(initMeetingState.ourUniversities); - // @TODO: SearchSelector에서 id, name으로 구분하지 않고 상위에서 구분해야 함. - // selectedResults를 상위에서 받아서 초기화해야 하는데 문자열로 받아지게 되어 있음. const handleNextClick = () => { if (initMeetingState) { setMeetingData({ ...initMeetingState, ourUniversities }); From 2a9efc30d9ad92b470424c78f057e4794b64e09a Mon Sep 17 00:00:00 2001 From: choisohyun Date: Sun, 26 Jun 2022 23:10:41 +0900 Subject: [PATCH 02/82] =?UTF-8?q?fix:=20=EC=A4=91=EB=B3=B5=EA=B0=92=20?= =?UTF-8?q?=EB=93=A4=EC=96=B4=EA=B0=80=EB=8A=94=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/domain/survey/SearchSelector.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/domain/survey/SearchSelector.tsx b/src/components/domain/survey/SearchSelector.tsx index d1d497d..3fc44ef 100644 --- a/src/components/domain/survey/SearchSelector.tsx +++ b/src/components/domain/survey/SearchSelector.tsx @@ -34,12 +34,12 @@ const SearchSelector = ({ placeholder, searchData, selectedResults, setSelectedR const id = findId(value); const noMatchData = !searchData.map(({ id }) => id).includes(id); + const existSelected = selectedResults.includes(id); const overMaxLimit = selectedResults.length >= MAX; - if (noMatchData || overMaxLimit) return; + if (noMatchData || existSelected || overMaxLimit) return; setSelectedResults((prev) => [...prev, id]); setSelectedSchools((prev) => [...prev, value]); - console.log(selectedResults); }; const handleDeleteClick = (value: string) => { From 91222e35f83a3ead657f9c285d919f623e7ee5f9 Mon Sep 17 00:00:00 2001 From: Jiyoung Kim Date: Mon, 27 Jun 2022 20:32:43 +0900 Subject: [PATCH 03/82] =?UTF-8?q?feat:=20=ED=81=B4=EB=A6=AD=20=EC=8B=9C=20?= =?UTF-8?q?input=20reset=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/domain/survey/SearchSelector.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/domain/survey/SearchSelector.tsx b/src/components/domain/survey/SearchSelector.tsx index 3fc44ef..8793db1 100644 --- a/src/components/domain/survey/SearchSelector.tsx +++ b/src/components/domain/survey/SearchSelector.tsx @@ -47,10 +47,16 @@ const SearchSelector = ({ placeholder, searchData, selectedResults, setSelectedR setSelectedResults((prev) => prev.filter((id) => id !== findId(value))); }; + const resetClick = () => { + if (inputRef.current) { + inputRef.current.value = ''; + } + }; + return ( <> - + {searchData.map(({ name, id }) => (