Skip to content

Commit f934c15

Browse files
Merge pull request #496 from persistenceOne/tnc
add cancel unbonding
2 parents 763b027 + 905f02f commit f934c15

File tree

16 files changed

+738
-248
lines changed

16 files changed

+738
-248
lines changed

src/assets/scss/index.css

Lines changed: 12 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/assets/scss/index.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/assets/scss/views/_main.scss

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -318,29 +318,34 @@
318318
width: 100%;
319319
margin: auto;
320320

321+
&.unbond-modal{
322+
.button.button-primary {
323+
padding: 0.125rem 1rem !important;
324+
border-radius: 4px !important;
325+
}
326+
}
327+
.unbonding-schedule-list-container {
328+
max-height: 400px;
329+
overflow: auto;
330+
}
331+
321332
.unbonding-schedule-list-header {
322333
display: flex;
323334
display: -webkit-flex;
324335
justify-content: space-between;
325-
padding: 15px 20px;
326-
327-
p {
328-
font-family: 'Poppins', sans-serif;
329-
font-weight: 500;
330-
font-size: 14px;
331-
line-height: 150%;
332-
margin: 0;
333-
color: #8D9CB5;
334-
}
336+
align-items: center;
337+
padding: 15px 2px;
338+
margin-bottom: 12px;
339+
border-bottom: 1px solid #2E3239;
335340
}
336341

337342
.unbonding-schedule-list {
338343
width: 100%;
339344
display: flex;
340345
display: -webkit-flex;
341346
justify-content: space-between;
342-
padding: 10px 20px;
343-
347+
align-items: center;
348+
padding: 10px 4px;
344349
&:hover {
345350
background: rgba(0, 0, 0, .075);
346351
}

src/components/Internationalization/locales/en/translation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ let English = {
184184
RECEIVED_IBC_TOKENS: "Tokens received via IBC",
185185
OTHER_TOKENS: "Other Tokens",
186186
VIEW: "View",
187-
VIEW_UNBOND_SCHEDULE: `View Unbonding ${DefaultChainInfo.currency.coinDenom} Schedule`,
187+
VIEW_UNBOND_SCHEDULE: `View ${DefaultChainInfo.currency.coinDenom} Unbondings`,
188188
UNBONDING_AMOUNT: "Unbonding Amount",
189189
DATE: "Date",
190190
VESTING_SCHEDULE: "Vesting Schedule",
@@ -237,7 +237,7 @@ let English = {
237237
IBC_REWARDS: "IBC Rewards",
238238
DECRYPT_KEY_STORE: "Decrypt KeyStore",
239239
MIGRATE_TOKENS: "Migrate Tokens From 750 wallet to 118 wallet",
240-
TOKENIZE_SHARE: "Tokenize Share",
240+
TOKENIZE_SHARE: "Tokenize Share"
241241
}
242242
};
243243

src/constants/cancel-unbond.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export const CANCEL_UNBOND_DELEGATIONS_FETCH_SUCCESS =
2+
"CANCEL_UNBOND_DELEGATIONS_FETCH_SUCCESS";
3+
export const CANCEL_UNBOND_DELEGATIONS_FETCH_ERROR =
4+
"CANCEL_UNBOND_DELEGATIONS_FETCH_ERROR";
5+
export const CANCEL_UNBOND_DELEGATIONS_LIST = "CANCEL_UNBOND_DELEGATIONS_LIST";
6+
export const CANCEL_UNBOND_DELEGATIONS_FETCH_IN_PROGRESS =
7+
"CANCEL_UNBOND_DELEGATIONS_FETCH_IN_PROGRESS";
8+
9+
export const TX_CANCEL_UNBOND_MEMO_SET = "TX_CANCEL_UNBOND_MEMO_SET";
10+
export const TX_CANCEL_UNBOND_AMOUNT_SET = "TX_CANCEL_UNBOND_AMOUNT_SET";
11+
export const TX_CANCEL_UNBOND_TO_ADDRESS_SET =
12+
"TX_CANCEL_UNBOND_TO_ADDRESS_SET";
13+
export const TX_CANCEL_UNBOND_MODAL_SHOW = "TX_CANCEL_UNBOND_MODAL_SHOW";
14+
export const TX_CANCEL_UNBOND_MODAL_HIDE = "TX_CANCEL_UNBOND_MODAL_HIDE";
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
import React from "react";
2+
import Button from "../../../components/Button";
3+
import {
4+
hideTxCancelUnbondModal,
5+
submitFormData
6+
} from "../../../store/actions/transactions/cancel-unbond";
7+
import { useDispatch, useSelector } from "react-redux";
8+
import { keplrSubmit } from "../../../store/actions/transactions/keplr";
9+
import { CancelUnbondingMsg } from "../../../utils/protoMsgHelper";
10+
import { setTxIno } from "../../../store/actions/transactions/common";
11+
import { LOGIN_INFO } from "../../../constants/localStorage";
12+
13+
const ButtonSubmit = ({ entry, validatorAddress, type, list }) => {
14+
const dispatch = useDispatch();
15+
const loginInfo = JSON.parse(localStorage.getItem(LOGIN_INFO));
16+
const amount = useSelector((state) => state.cancelUnbondTx.amount);
17+
const memo = useSelector((state) => state.cancelUnbondTx.memo);
18+
19+
const onClick = () => {
20+
console.log(entry, validatorAddress, "clicked");
21+
let msgs = [];
22+
if (type === "individual") {
23+
msgs.push(
24+
CancelUnbondingMsg(
25+
loginInfo && loginInfo.address,
26+
validatorAddress,
27+
entry.balance,
28+
entry.creationHeight
29+
)
30+
);
31+
} else {
32+
list.map((item) => {
33+
item.entries.length > 0
34+
? item.entries.map((ItemEntry) => {
35+
msgs.push(
36+
CancelUnbondingMsg(
37+
loginInfo && loginInfo.address,
38+
item.validatorAddress,
39+
ItemEntry.balance,
40+
ItemEntry.creationHeight
41+
)
42+
);
43+
})
44+
: null;
45+
});
46+
}
47+
dispatch(submitFormData(msgs));
48+
};
49+
50+
const disable = memo.error.message !== "";
51+
52+
const onClickKeplr = () => {
53+
console.log(entry, validatorAddress, "clicked");
54+
let msgs = [];
55+
if (type === "individual") {
56+
msgs.push(
57+
CancelUnbondingMsg(
58+
loginInfo && loginInfo.address,
59+
validatorAddress,
60+
entry.balance,
61+
entry.creationHeight
62+
)
63+
);
64+
} else {
65+
list.map((item) => {
66+
item.entries.length > 0
67+
? item.entries.map((ItemEntry, entryIndex) => {
68+
msgs.push(
69+
CancelUnbondingMsg(
70+
loginInfo && loginInfo.address,
71+
item.validatorAddress,
72+
ItemEntry.balance,
73+
ItemEntry.creationHeight
74+
)
75+
);
76+
})
77+
: null;
78+
});
79+
}
80+
console.log(msgs, "msgs-txns");
81+
dispatch(
82+
setTxIno({
83+
value: {
84+
modal: hideTxCancelUnbondModal(),
85+
data: {
86+
message: "",
87+
memo: ""
88+
}
89+
}
90+
})
91+
);
92+
dispatch(keplrSubmit(msgs));
93+
};
94+
95+
return (
96+
<div className="buttons">
97+
<div className="button-section">
98+
<Button
99+
className="button button-primary"
100+
type="button"
101+
disable={disable}
102+
value={type === "individual" ? "Cancel Unbonding" : "Cancel All"}
103+
onClick={
104+
loginInfo && loginInfo.loginMode === "keplr"
105+
? onClickKeplr
106+
: onClick
107+
}
108+
/>
109+
</div>
110+
</div>
111+
);
112+
};
113+
114+
export default ButtonSubmit;
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
import React, { useState } from "react";
2+
import { OverlayTrigger, Popover } from "react-bootstrap";
3+
import Icon from "../../../components/Icon";
4+
import InputText from "../../../components/InputText";
5+
import { useDispatch, useSelector } from "react-redux";
6+
import { setTxMemo } from "../../../store/actions/transactions/cancel-unbond";
7+
import { useTranslation } from "react-i18next";
8+
import {
9+
ValidateAlphaNumericSpaces,
10+
ValidateMemo
11+
} from "../../../utils/validations";
12+
13+
const Memo = () => {
14+
const { t } = useTranslation();
15+
const [memoStatus, setMemoStatus] = useState(false);
16+
const memo = useSelector((state) => state.cancelUnbondTx.memo);
17+
const dispatch = useDispatch();
18+
19+
const handleMemoChange = () => {
20+
setMemoStatus(!memoStatus);
21+
};
22+
23+
const popoverMemo = (
24+
<Popover id="popover-memo">
25+
<Popover.Content>{t("MEMO_NOTE")}</Popover.Content>
26+
</Popover>
27+
);
28+
29+
const onChange = (evt) => {
30+
dispatch(
31+
setTxMemo({
32+
value: evt.target.value,
33+
error: ValidateMemo(evt.target.value)
34+
})
35+
);
36+
};
37+
38+
const onBlur = (evt) => {
39+
dispatch(
40+
setTxMemo({
41+
value: evt.target.value,
42+
error: ValidateMemo(evt.target.value)
43+
})
44+
);
45+
};
46+
47+
return (
48+
<>
49+
<div className="memo-dropdown-section">
50+
<p onClick={handleMemoChange} className="memo-dropdown">
51+
<span className="text">{t("ADVANCED")} </span>
52+
{memoStatus ? (
53+
<Icon viewClass="arrow-right" icon="up-arrow" />
54+
) : (
55+
<Icon viewClass="arrow-right" icon="down-arrow" />
56+
)}
57+
</p>
58+
<OverlayTrigger
59+
trigger={["hover", "focus"]}
60+
placement="bottom"
61+
overlay={popoverMemo}
62+
>
63+
<button className="icon-button info" type="button">
64+
<Icon viewClass="arrow-right" icon="info" />
65+
</button>
66+
</OverlayTrigger>
67+
</div>
68+
69+
<div
70+
className={`form-field memo-dropdown-section-body ${
71+
memoStatus ? "show" : ""
72+
}`}
73+
>
74+
<p className="label info">
75+
{t("MEMO")}
76+
<OverlayTrigger
77+
trigger={["hover", "focus"]}
78+
placement="bottom"
79+
overlay={popoverMemo}
80+
>
81+
<button className="icon-button info" type="button">
82+
<Icon viewClass="arrow-right" icon="info" />
83+
</button>
84+
</OverlayTrigger>
85+
</p>
86+
<InputText
87+
className="form-control"
88+
name="memo"
89+
type="text"
90+
value={memo.value}
91+
required={false}
92+
error={memo.error}
93+
onKeyPress={ValidateAlphaNumericSpaces}
94+
onBlur={onBlur}
95+
placeholder={t("ENTER_MEMO")}
96+
autofocus={false}
97+
maxLength={200}
98+
onChange={onChange}
99+
/>
100+
</div>
101+
</>
102+
);
103+
};
104+
105+
export default Memo;

0 commit comments

Comments
 (0)