Skip to content

Commit

Permalink
Merge pull request #177 from bsideproject/QA
Browse files Browse the repository at this point in the history
현금입력,친구리스트 등 수정
  • Loading branch information
boxak authored Dec 28, 2023
2 parents bd4401e + 49f1ad6 commit 5edbfbc
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
16 changes: 13 additions & 3 deletions src/pages/mind/FriendList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
}
});

Expand All @@ -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;
Expand Down
30 changes: 22 additions & 8 deletions src/pages/mind/Mind.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ const Mind = () => {
}

const addMoney = (add: number) => {

let sum = add + money;

setMoney(sum);
Expand All @@ -253,7 +254,6 @@ const Mind = () => {
inputText = !NullChecker.isEmpty(inputText) ? inputText : "0";

inputNumber = parseInt(inputText.replaceAll(',', '').replace('원', ''));

setMoney(inputNumber);
}
}
Expand Down Expand Up @@ -511,7 +511,7 @@ const Mind = () => {
setIsOkOpen(true);
}
} catch (err) {
console.log(err);
console.error(err);
}
}

Expand All @@ -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 (
Expand All @@ -550,7 +564,7 @@ const Mind = () => {
placeholder='기록할 친구들을 선택하세요.'
id='friends'
onClick={() => handleInputClick(0)}
value={inputArray[0]}
value={formatFriendNames()}
/>
{!validCheckArray[0] &&
<ErrorMessage
Expand Down Expand Up @@ -593,7 +607,7 @@ const Mind = () => {
id='cash-input'
placeholder='금액을 입력하세요'
ref={moneyInputRef}
defaultValue={money + '원'}
defaultValue={money > 0 ? money + '원' : ''}
onBlur={() => onBlurMoneyInput()}
onKeyUp={() => { onChangeMindContent("cash"); onChangeMoneyInput(); }}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/styles/pages/_mind.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5edbfbc

Please sign in to comment.