Skip to content

Commit 8a33dfa

Browse files
committed
refactor: move maintenance to check page instead of confirm
1 parent 6485b6a commit 8a33dfa

File tree

6 files changed

+76
-38
lines changed

6 files changed

+76
-38
lines changed

app/sources/src/components/CheckDestination/styles.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,25 @@ export const Message = styled(MessageRaw)`
3636
}
3737
`;
3838

39+
export const Maintenance = styled(MessageRaw)`
40+
position: relative;
41+
display: flex;
42+
flex-direction: column;
43+
justify-content: center;
44+
align-items: center;
45+
white-space: pre-wrap;
46+
text-align: center;
47+
background: var(--colors__bg_warn);
48+
font-weight: 400;
49+
& * {
50+
word-break: break-word;
51+
}
52+
& > ${Span} {
53+
font-weight: 600;
54+
padding: 0!important;
55+
}
56+
`;
57+
3958
export const Root = withLoader(styled(Form)`
4059
height: 100%;
4160

app/sources/src/components/CheckDestination/view.js

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,18 @@ import PropTypes from 'prop-types';
1313
import GA from 'utils/GA';
1414
import logger from 'utils/logging';
1515

16-
import { Root, Input, Button, Message, P, Span, A, DestinationInfo, AmountInput } from './styles';
16+
import {
17+
Root,
18+
Input,
19+
Button,
20+
Message,
21+
P,
22+
Span,
23+
A,
24+
DestinationInfo,
25+
AmountInput,
26+
Maintenance,
27+
} from './styles';
1728

1829
const log = logger();
1930

@@ -28,11 +39,12 @@ export class CheckDestination extends Component {
2839
}
2940

3041
render() {
31-
const { wallets, wallet, className, history, t, accounts } = this.props;
42+
const { wallets, wallet, className, history, t, accounts, info } = this.props;
3243

3344
if (
3445
wallets.getDetails.data &&
35-
!(wallets.getDetails.data.latestPayment && wallets.getDetails.data.type === 'lightning')
46+
!(wallets.getDetails.data.latestPayment && wallets.getDetails.data.type === 'lightning') &&
47+
!(info.get.data && info.get.data.status && info.get.data.status.type === 'maintenance')
3648
) {
3749
history.push(
3850
`/payments/confirm?payment=${JSON.stringify({ ...wallet, ...wallets.getDetails.data })}`,
@@ -55,12 +67,34 @@ export class CheckDestination extends Component {
5567
wallets.getDetails.run(e.target.value, 'BTC');
5668
}}
5769
required
70+
disabled={
71+
info.get.data && info.get.data.status && info.get.data.status.type === 'maintenance'
72+
}
5873
/>
59-
{wallets.getDetails.error && (
60-
<Message type="error">
61-
{t([`errors.${wallets.getDetails.error.code}`, 'errors.default'])}
62-
</Message>
63-
)}
74+
{wallets.getDetails.error &&
75+
document.getElementById('sendAddress').value !== '' &&
76+
!(
77+
info.get.data &&
78+
info.get.data.status &&
79+
info.get.data.status.type === 'maintenance' &&
80+
info.get.data.status.message
81+
) && (
82+
<Message type="error">
83+
{t([`errors.${wallets.getDetails.error.code}`, 'errors.default'])}
84+
</Message>
85+
)}
86+
{info.get.data &&
87+
info.get.data.status &&
88+
info.get.data.status.type === 'maintenance' &&
89+
info.get.data.status.message ? (
90+
<Maintenance>
91+
<Span>{info.get.data.status.message.split('\n')[0]}</Span>
92+
{info.get.data.status.message
93+
.split('\n')
94+
.slice(1)
95+
.join('\n')}
96+
</Maintenance>
97+
) : null}
6498
{wallets.getDetails.data &&
6599
wallets.getDetails.data.latestPayment &&
66100
wallets.getDetails.data.type === 'lightning' && (
@@ -71,7 +105,15 @@ export class CheckDestination extends Component {
71105
accounts.get.data.auid === wallets.getDetails.data.latestPayment.auid ? (
72106
<Span
73107
onClick={() => {
74-
history.push(`/payments/${wallets.getDetails.data.latestPayment.puid}`);
108+
if (
109+
!(
110+
info.get.data &&
111+
info.get.data.status &&
112+
info.get.data.status.type === 'maintenance'
113+
)
114+
) {
115+
history.push(`/payments/${wallets.getDetails.data.latestPayment.puid}`);
116+
}
75117
}}
76118
>
77119
Go to payment details

app/sources/src/components/PaymentConfirmation/styles.js

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -290,25 +290,6 @@ export const SendResultCta = styled.a`
290290
margin-top: 1em;
291291
`;
292292

293-
export const Maintenance = styled(MessageRaw)`
294-
position: relative;
295-
display: flex;
296-
flex-direction: column;
297-
justify-content: center;
298-
align-items: center;
299-
white-space: pre-wrap;
300-
text-align: center;
301-
background: var(--colors__bg_warn);
302-
font-weight: 400;
303-
& * {
304-
word-break: break-word;
305-
}
306-
& > ${Span} {
307-
font-weight: 600;
308-
padding: 0!important;
309-
}
310-
`;
311-
312293
export const Root = withLoader(styled(Form)`
313294
flex-grow: 2;
314295

app/sources/src/components/PaymentConfirmation/view.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,6 @@ export class PaymentConfirmation extends Component {
246246
payments.estimate.error.code === '403RPA01'
247247
}
248248
/>
249-
{info.get.data && info.get.data.status && info.get.data.status.type === 'maintenance' && info.get.data.status.message ? (
250-
<Maintenance>
251-
<Span>{info.get.data.status.message.split('\n')[0]}</Span>
252-
{info.get.data.status.message.split('\n').slice(1).join('\n')}
253-
</Maintenance>
254-
) : null}
255249
{payments.estimate.error && !payments.estimate.loading && !payments.estimate.debouncing && (
256250
<Message type="error">
257251
{t([`errors.${payments.estimate.error.code}`, 'errors.default'], {

app/sources/src/scenes/Check/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ const log = logger();
2424

2525
class Wrapper extends React.Component {
2626
async componentDidMount() {
27-
const { wallets } = this.props;
27+
const { wallets, info } = this.props;
2828
const query = window.location.hash.match(/\?(.*)/);
29+
30+
info.get.run();
2931

3032
let wallet;
3133
if (query) {
@@ -72,4 +74,4 @@ class Wrapper extends React.Component {
7274

7375
Wrapper.propTypes = {};
7476

75-
export default inject('payments', 'wallets', 'accounts')(observer(Wrapper));
77+
export default inject('payments', 'wallets', 'accounts', 'info')(observer(Wrapper));

app/sources/src/scenes/Check/view.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ const log = logger();
1919
// Code
2020
// -----------------------------------------------------------------------------
2121

22-
const Send = ({ wallets, wallet, accounts }) => {
22+
const Send = ({ wallets, wallet, accounts, info }) => {
2323
return (
2424
<Root>
2525
<Header>
2626
<BackButton />
2727
<P>Pay</P>
2828
<Support className="openIntercom" />
2929
</Header>
30-
<CheckDestination wallets={wallets} wallet={wallet} accounts={accounts} />
30+
<CheckDestination wallets={wallets} wallet={wallet} accounts={accounts} info={info} />
3131
</Root>
3232
);
3333
};

0 commit comments

Comments
 (0)