From 49f1ad67dba8c7f166e4798d607490864fee47c1 Mon Sep 17 00:00:00 2001 From: boxak Date: Fri, 29 Dec 2023 00:25:59 +0900 Subject: [PATCH] =?UTF-8?q?=ED=98=84=EA=B8=88=EC=9E=85=EB=A0=A5,=EC=B9=9C?= =?UTF-8?q?=EA=B5=AC=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EB=93=B1=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/mind/FriendList.tsx | 16 +++++++++++++--- src/pages/mind/Mind.tsx | 30 ++++++++++++++++++++++-------- src/styles/pages/_mind.scss | 2 +- 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/src/pages/mind/FriendList.tsx b/src/pages/mind/FriendList.tsx index 38b1dba..6cef5c9 100644 --- a/src/pages/mind/FriendList.tsx +++ b/src/pages/mind/FriendList.tsx @@ -36,17 +36,26 @@ const FriendList = ({ isOpen, onClose, setContainerHeight, appendFriendList, sel let friendList: RelationshipResponseProto[] = RootStore.friendStore.getFriendList; + let tempCheckCount : number = 0; + friendList.forEach(friend => { if (friend.sequence && friend.nickname && friend.relationship) { + + const sequenceContains : boolean = selectedFriendSeqList.includes(friend.sequence); + friendCheckList.push({ friend: { id: friend.sequence, name: friend.nickname, relation: friend.relationship }, - check: selectedFriendSeqList.includes(friend.sequence), + check: sequenceContains, display: true }); + + if (sequenceContains) { + tempCheckCount++; + } } }); @@ -58,12 +67,13 @@ const FriendList = ({ isOpen, onClose, setContainerHeight, appendFriendList, sel } else { return 0; } - }) + }); setFriendList(friendCheckList); setTotalCount(friendCheckList.length); - }, [RootStore.friendStore.getFriendList]); + setCheckCount(tempCheckCount); + }, [isOpen]); const handleInput = () => { const text: string = inputRef.current?.value as string; diff --git a/src/pages/mind/Mind.tsx b/src/pages/mind/Mind.tsx index 1fed13f..ffbeebc 100644 --- a/src/pages/mind/Mind.tsx +++ b/src/pages/mind/Mind.tsx @@ -233,6 +233,7 @@ const Mind = () => { } const addMoney = (add: number) => { + let sum = add + money; setMoney(sum); @@ -253,7 +254,6 @@ const Mind = () => { inputText = !NullChecker.isEmpty(inputText) ? inputText : "0"; inputNumber = parseInt(inputText.replaceAll(',', '').replace('원', '')); - setMoney(inputNumber); } } @@ -511,7 +511,7 @@ const Mind = () => { setIsOkOpen(true); } } catch (err) { - console.log(err); + console.error(err); } } @@ -526,14 +526,28 @@ const Mind = () => { const onBlurMoneyInput = () => { if (moneyInputRef.current) { let moneyText = moneyInputRef.current.value; + moneyText = moneyText.replace(/[^0-9$]/g, ''); - moneyText = moneyText.replaceAll(',', '').replace('원', ''); - - moneyText = displayMoneyForm(parseInt(moneyText)); - + moneyText = !NullChecker.isEmpty(moneyText) ? moneyText : "0"; + setMoney(parseInt(moneyText)); + moneyText = parseInt(moneyText) > 0 ? displayMoneyForm(parseInt(moneyText)) : ''; moneyInputRef.current.value = moneyText; + } + } + const formatFriendNames = () => { + if (!inputArray[0]) { + return ""; } + const names: string[] = inputArray[0].split(','); + + if (names.length >= 4) { + const displayedNames = names.slice(0, 3).join(', '); + return `${displayedNames} 외 ${names.length}명`; + } else { + return inputArray[0]; + } + } return ( @@ -550,7 +564,7 @@ const Mind = () => { placeholder='기록할 친구들을 선택하세요.' id='friends' onClick={() => handleInputClick(0)} - value={inputArray[0]} + value={formatFriendNames()} /> {!validCheckArray[0] && { id='cash-input' placeholder='금액을 입력하세요' ref={moneyInputRef} - defaultValue={money + '원'} + defaultValue={money > 0 ? money + '원' : ''} onBlur={() => onBlurMoneyInput()} onKeyUp={() => { onChangeMindContent("cash"); onChangeMoneyInput(); }} /> diff --git a/src/styles/pages/_mind.scss b/src/styles/pages/_mind.scss index c39428c..0ac3455 100644 --- a/src/styles/pages/_mind.scss +++ b/src/styles/pages/_mind.scss @@ -115,7 +115,7 @@ display: block; width: 48%; font-weight: 500; - font-size: 3.7vw; + font-size: 3.9vw; color: #fff; background: $btn-active-color; border-radius: 8px;