Skip to content

Commit

Permalink
header & fast btc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
creed-victor committed Nov 6, 2020
1 parent 3566cf0 commit 8b77f0a
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 21 deletions.
16 changes: 2 additions & 14 deletions src/app/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ export function Header() {
<header>
<Container className="d-flex justify-content-between align-items-center mt-4 mb-5">
<div className="d-xl-none">
<StyledMenuButton>
<button className="hamburger" type="button">
<Popover content={<Menu>{dropDownMenu}</Menu>}>
<Icon icon="menu" />
</Popover>
</StyledMenuButton>
</button>
</div>
<div className="mr-3">
<Link to="/">
Expand Down Expand Up @@ -100,15 +100,3 @@ const StyledLogo = styled.img.attrs(_ => ({
margin: 0 15px 0 0;
`}
`;

const StyledMenuButton = styled.button.attrs(_ => ({
type: 'button',
}))`
width: 48px;
height: 48px;
text-align: left;
padding-left: 0;
color: var(--white);
background: none;
border: none;
`;
38 changes: 31 additions & 7 deletions src/app/containers/FastBtcForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
*/

import React, { useEffect } from 'react';
import React, { useCallback, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { useSelector, useDispatch } from 'react-redux';
import QRCode from 'qrcode.react';
Expand All @@ -19,7 +19,7 @@ import { selectFastBtcForm } from './selectors';
import { fastBtcFormSaga } from './saga';
import { FieldGroup } from '../../components/FieldGroup';
import { InputField } from '../../components/InputField';
import { useAccount } from '../../hooks/useAccount';
import { useAccount, useIsConnected } from '../../hooks/useAccount';
import { DummyField } from '../../components/DummyField';
import { SkeletonRow } from '../../components/Skeleton/SkeletonRow';
import { weiTo4, weiToFixed } from '../../../utils/blockchain/math-helpers';
Expand All @@ -34,6 +34,7 @@ export function FastBtcForm(props: Props) {
useInjectReducer({ key: sliceKey, reducer: reducer });
useInjectSaga({ key: sliceKey, saga: fastBtcFormSaga });

const isConnected = useIsConnected();
const state = useSelector(selectFastBtcForm);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const dispatch = useDispatch();
Expand All @@ -44,9 +45,18 @@ export function FastBtcForm(props: Props) {
const address = useAccount();

useEffect(() => {
dispatch(actions.changeReceiverAddress(address));
if (address && address.length) {
dispatch(actions.changeReceiverAddress(address));
}
}, [address, dispatch]);

const handleInputChange = useCallback(
e => {
dispatch(actions.changeReceiverAddress(e.currentTarget.value));
},
[dispatch],
);

return (
<>
<div className="row">
Expand All @@ -55,11 +65,10 @@ export function FastBtcForm(props: Props) {
<div className="sovryn-border p-3">
<FieldGroup label={'Your RSK Wallet'}>
<InputField
placeholder="Your RSK Wallet"
invalid={!state.isReceiverAddressValid}
value={state.receiverAddress}
onChange={e =>
dispatch(actions.changeReceiverAddress(e.currentTarget.value))
}
onChange={handleInputChange}
rightElement={
state.isReceiverAddressValidating && (
<>
Expand All @@ -70,6 +79,13 @@ export function FastBtcForm(props: Props) {
/>
</FieldGroup>

{!isConnected && (
<p>
Connect to your wallet or just enter wallet address above
yourself.
</p>
)}

{state.depositError && (
<div className="alert alert-warning">{state.depositError}</div>
)}
Expand Down Expand Up @@ -150,7 +166,15 @@ export function FastBtcForm(props: Props) {
{!state.history.length && !state.isHistoryLoading && (
<p className="mb-0">{t(s.history.empty)}</p>
)}
{state.isHistoryLoading && !state.history.length && <SkeletonRow />}
{state.isHistoryLoading && !state.history.length && (
<SkeletonRow
loadingText={
!state.receiverAddress || !state.isReceiverAddressValid
? 'Enter your RSK wallet address to see history.'
: 'Loading...'
}
/>
)}
{state.history.map(item => (
<div
className="d-flex flex-row justify-content-between w-100"
Expand Down
13 changes: 13 additions & 0 deletions src/styles/sass/new-design.scss
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,16 @@ input {
@extend .sovryn-border;
@extend .font-family-work-sans;
}


header {
.hamburger {
width: 48px;
height: 48px;
text-align: left;
padding-left: 0;
color: var(--white);
background: none;
border: none;
}
}

0 comments on commit 8b77f0a

Please sign in to comment.