Skip to content

Commit

Permalink
Merge pull request #135 from bsideproject/jw-dev
Browse files Browse the repository at this point in the history
Jw dev
  • Loading branch information
boxak authored Jul 28, 2023
2 parents f36439b + 5c0222c commit dff083a
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function App() {
<Route path='/page/main' element={<Main />}></Route>
<Route path="/page/friend" element={<Friend />}></Route>
<Route path="/page/relationship/" element={<Mind />}></Route>
<Route path="/page/relationship/:nickname/:sequence" element={<Mind />}></Route>
<Route path="/page/relationship/:friendSequence/:nickname/:sequence" element={<Mind />}></Route>
<Route path="/page/detail" element={<Detail />}></Route>

<Route path="/page/setting" element={<Setting />}></Route>
Expand Down
2 changes: 1 addition & 1 deletion src/components/detail/ExchangeWrap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const ExchangeWrap = ({detailInfo, sequence}:params) => {
{exchangeData && exchangeData.length !== 0 ?
<ul className="exchange-wrap">
{exchangeData && exchangeData.relationships.map((item:any, key:any) => (
<li className="exchange-cont" key={key} onClick={() => navigate(`/page/relationship/${detailInfo?.nickname}/${item?.sequence}`)}>
<li className="exchange-cont" key={key} onClick={() => navigate(`/page/relationship/${sequence}/${detailInfo?.nickname}/${item?.sequence}`)}>
<i className={item?.type === "TAKEN" ? "exchanged-circle tak" : item?.type === "GIVEN" ? "exchanged-circle giv" : "exchanged-circle giv"}></i>
<h4 className={item?.type === "TAKEN" ? "taken" : ""}>
{item?.type === "GIVEN" ?
Expand Down
70 changes: 54 additions & 16 deletions src/pages/mind/Mind.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const Mind = () => {
list[1] = todayString;

// 관계 등록 후 넘어왔을 경우
if (location.state && location.state.friendData) {
if (location.state?.friendData) {
const friendData = location.state.friendData;

let text = '';
Expand All @@ -79,14 +79,15 @@ const Mind = () => {
});

setSelectedSeq(friendSeqList);

text = text.trim();
text = text.slice(0, -1);
} else {
text+=friendData.nickname;
pushFriendSeq(friendData.sequence);
}

// 마지막 comma 제거
text = text.trim();
text = text.slice(0, -1);
text =text.trim();
}

list[0] = text;

Expand All @@ -106,6 +107,7 @@ const Mind = () => {

setMindSeq(mindSeq);
setEditMode(true);
setSelectedSeq([friendSeq]);

const fetchRelationshipDetail = async () => {
try {
Expand Down Expand Up @@ -140,7 +142,7 @@ const Mind = () => {
setGift(itemName);
} else {
if (moneyInputRef.current) {
moneyInputRef.current.value = itemName;
moneyInputRef.current.value = displayMoneyForm(parseInt(itemName));
setMoney(parseInt(itemName));
}
}
Expand All @@ -166,9 +168,20 @@ const Mind = () => {
RootStore.friendStore.setFriendList();
}, []);


useEffect(() => {
console.log("seq : " + JSON.stringify(selectedSeq));
}, [selectedSeq]);

const displayMoneyForm = (money : number) : string => {
return money.toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ",") + '원';
}

const handleInputClick = (index : number) => {

if (index === 0 && (isEditMode || (location.state?.friendData))) {
return;
}

let list : boolean[] = [...openModal];
list[index] = true;
setOpenModal(list);
Expand Down Expand Up @@ -222,20 +235,22 @@ const Mind = () => {

const addMoney = (add : number) => {
let sum = add + money;

let reSum = sum.toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ",")

setMoney(sum);

if (moneyInputRef.current) {
moneyInputRef.current.valueAsNumber = sum;
moneyInputRef.current.value = displayMoneyForm(sum);
}
}

const onChangeMoneyInput = () => {
let inputNumber : number = 0;

if (moneyInputRef.current) {
inputNumber = moneyInputRef.current.valueAsNumber;

let inputText = moneyInputRef.current.value;

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

setMoney(inputNumber);
}
Expand Down Expand Up @@ -268,7 +283,7 @@ const Mind = () => {
setValidCheckArray([...array]);
valid = false;
} else if (mindType === 'cash') {
if (moneyInputRef && moneyInputRef.current) {
if (moneyInputRef?.current) {
const input = moneyInputRef.current.value;

if (NullChecker.isEmpty(input)) {
Expand All @@ -279,7 +294,7 @@ const Mind = () => {
}
}
} else if (mindType === 'gift') {
if (giftRef && giftRef.current) {
if (giftRef?.current) {
const input = giftRef.current.value;

if (NullChecker.isEmpty(input)) {
Expand Down Expand Up @@ -313,6 +328,10 @@ const Mind = () => {

if (mindType === 'cash' && moneyInputRef.current) {
item = moneyInputRef.current.value;

item = item.replace('원','');
item = item.replace(',','');

itemType = ItemTypeProto.CASH;
}

Expand Down Expand Up @@ -353,14 +372,19 @@ const Mind = () => {
if (isEditMode) {
const relationshipPutRequestProto : RelationshipPutRequestProto = {
sequence : mindSeq,
friendSequence : friendSequence[0],
type : type,
event : event,
date : dateProto,
item : itemProto,
memo : memoTxt
};

console.log("friendSeq : " + JSON.stringify(friendSequence));

console.log("relationshipPutRequest : " + JSON.stringify(relationshipPutRequestProto));

// await RootStore.mindStore.putMind(relationshipPutRequestProto);
await RootStore.mindStore.putMind(relationshipPutRequestProto);
} else {
const relationshipPostRequestProto : RelationshipPostRequestProto = {
relationships : saveList
Expand Down Expand Up @@ -474,6 +498,19 @@ const Mind = () => {
}
}

const onBlurMoneyInput = () => {
if (moneyInputRef.current) {
let moneyText = moneyInputRef.current.value;

moneyText = moneyText.replaceAll(',','').replace('원','');

moneyText = displayMoneyForm(parseInt(moneyText));

moneyInputRef.current.value = moneyText;

}
}

return (
<div className="Mind inner">
<button type="button" className="exel-btn" onClick={handleExelBtn}><img src={ImgExelBtn} alt="exel-btn" /></button>
Expand Down Expand Up @@ -526,12 +563,13 @@ const Mind = () => {
<Fragment>
<div className="InputTextBox">
<input
type="number"
type="text"
className="input-text-box"
id='cash-input'
placeholder='금액을 입력하세요'
ref={moneyInputRef}
defaultValue={money}
defaultValue={money+'원'}
onBlur={() => onBlurMoneyInput()}
onKeyUp={() => {onChangeMindContent("cash");onChangeMoneyInput();}}
/>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/prototypes/relationship/RelationshipRequestProto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export interface RelationshipPostRequestProto {
}

export interface RelationshipPutRequestProto {
sequence?: string;
sequence: string;
friendSequence : string;
type?: RelationshipTypeProto;
event?: string;
date?: DateProto;
Expand Down

0 comments on commit dff083a

Please sign in to comment.