Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit

Permalink
fix: cleaning of swap reducers (#90)
Browse files Browse the repository at this point in the history
* refactor: fix complete swap reducers

* refactor: reset state

* refactor: fix style issues #95

* refactor: lint

* refactor: user correct nextStage in reverse swap

* refactor: clean up background style

* refactor: completeSwap

* refactor: fix reducer issue
  • Loading branch information
ImmanuelSegol authored and michael1011 committed Feb 19, 2019
1 parent 5f3b526 commit 168472d
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 66 deletions.
25 changes: 8 additions & 17 deletions src/components/background/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,22 @@ import injectSheet from 'react-jss';

const styles = theme => ({
wrapper: {
height: '100vh',
width: '100vw',
minHeight: '100vh',
flexDirection: 'column',
backgroundImage: 'linear-gradient(to bottom, #114357, #f29492)',
},
boltzWrapper: {
marginTop: '25px',
marginBottom: '25px',
marginLeft: 'auto',
marginRight: 'auto',
position: 'relative',
alignItems: 'center',
flexDirection: 'column',
},
boltz: {
bottom: 0,
color: theme.colors.white,
fontSize: '15px',
fontStyle: 'normal',
alignSelf: 'center',
lineHeight: 'normal',
fontWeight: 'normal',
fontStyle: 'normal',
fontStretch: 'normal',
lineHeight: 'normal',
letterSpacing: 'normal',
verticalAlign: 'bottom',
color: theme.colors.white,
zIndex: 2,
alignSelf: 'center',
paddingBottom: '10px',
zIndex: 99999,
},
});

Expand Down
23 changes: 9 additions & 14 deletions src/components/nodeinfo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const styles = () => ({
alignContent: 'center',
flexDirection: 'column',
justifyContent: 'center',
margin: '120px',
},
name: {
marginBottom: '0px',
Expand All @@ -25,25 +26,19 @@ const styles = () => ({
},
});

class NodeInfo extends React.Component {
render() {
const { classes, name, uri } = this.props;

return (
<View className={classes.node}>
<h3 className={classes.name}>{name}:</h3>

<QrCode className={classes.qr} size={200} link={uri} />
<code className={classes.uri}>{uri}</code>
</View>
);
}
}
const NodeInfo = ({ classes, size, name, uri }) => (
<View className={classes.node}>
<h3 className={classes.name}>{name}:</h3>
<QrCode className={classes.qr} size={size} link={uri} />
<code className={classes.uri}>{uri}</code>
</View>
);

NodeInfo.propTypes = {
classes: PropTypes.object.isRequired,
name: PropTypes.string.isRequired,
uri: PropTypes.string.isRequired,
size: PropTypes.number.isRequired,
};

export default injectSheet(styles)(NodeInfo);
6 changes: 3 additions & 3 deletions src/components/swaptab/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,15 @@ class SwapTab extends React.Component {
)}/${this.parseBoltSuffix(this.state.quote, false)}`;
};

componentWillMount() {
if (localStorage.length !== 0) {
componentWillMount = () => {
if (localStorage.getItem('quote')) {
this.setState({
base: localStorage.getItem('base'),
quote: localStorage.getItem('quote'),
baseAmount: localStorage.getItem('baseAmount'),
});
}
}
};

componentDidMount = () => {
const symbol = this.getSymbol();
Expand Down
38 changes: 18 additions & 20 deletions src/views/faq/faq.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,17 @@ import { bitcoinLnd, litecoinLnd } from '../../constants';

const twitterLink = 'https://twitter.com/boltzhq';

const styles = theme => ({
const styles = () => ({
wrapper: {
flex: 1,
alignItems: 'center',
justifyContent: 'space-around',
justifyContent: 'center',
overflowY: 'scroll',
},
tab: {
height: '100vh',
width: '800px',
marginTop: '20px',
paddingTop: '20px',
paddingBottom: '20px',
paddingStart: '50px',
paddingEnd: '50px',
display: 'flex',
alignItems: 'center',
alignContent: 'center',
flexDirection: 'column',
justifyContent: 'center',
backgroundColor: theme.colors.white,
'@media (min-width: 1500px)': {
width: '1000px',
},
},
questionTitle: {
marginBottom: '0px',
Expand Down Expand Up @@ -70,8 +60,8 @@ class Faq extends React.Component {
<a href={twitterLink}>on request</a> we will also open one to you:
</p>

<NodeInfo name={'Bitcoin LND node'} uri={bitcoinLnd} />
<NodeInfo name={'Litecoin LND node'} uri={litecoinLnd} />
<NodeInfo size={150} name={'Bitcoin LND node'} uri={bitcoinLnd} />
<NodeInfo size={150} name={'Litecoin LND node'} uri={litecoinLnd} />

<h2 className={classes.questionTitle}>
Why should one use a non custodial exchange?
Expand All @@ -85,6 +75,8 @@ class Faq extends React.Component {
you can read more about this in{' '}
<a
href={'https://medium.com/boltzhq/submarine-swaps-c509ce0fb1db'}
target="_blank"
rel="noopener noreferrer"
>
our blog post about how Boltz works
</a>
Expand All @@ -94,9 +86,15 @@ class Faq extends React.Component {
If you are <i>really</i> technical you can proof read our source
code and verify that the claims above are valid because everything
is open source and can be found on{' '}
<a href={'https://github.com/boltzexchange'}>our GitHub</a>. Also
we will soon add a version of our frontend that you can host
yourself easily.
<a
href={'https://github.com/boltzexchange'}
target="_blank"
rel="noopener noreferrer"
>
our GitHub
</a>
. Also we will soon add a version of our frontend that you can
host yourself easily.
</p>

<h2 className={classes.questionTitle}>
Expand Down
9 changes: 6 additions & 3 deletions src/views/landingpage/landingpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ class LandingPage extends React.Component {
limits,
} = this.props;

const loading =
Object.keys(rates).length === 0 ||
currencies.length === 0 ||
Object.keys(limits).length === 0;

return (
<BackGround>
<TaskBar goHome={goHome} goRefund={goRefund} goFaq={goFaq} />
Expand All @@ -125,9 +130,7 @@ class LandingPage extends React.Component {
onClose={this.toggleModal}
/>
</View>
{Object.keys(rates).length === 0 ||
currencies.length === 0 ||
Object.keys(limits).length === 0 ? (
{loading ? (
<View className={classes.loading}>
<img
alt="logo"
Expand Down
14 changes: 9 additions & 5 deletions src/views/reverse/reverse.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const ReverseSwap = ({
completeSwap,
goHome,
webln,
nextStage,
swapInfo,
swapResponse,
isFetching,
Expand Down Expand Up @@ -87,23 +86,28 @@ const ReverseSwap = ({
/>
<StepsWizard.Control
num={2}
render={() => (
render={props => (
<Controls
loading={isFetching}
text={'Done'}
loadingText={swapStatus}
loadingRender={() => <Loading />}
onPress={() => {
completeSwap();
nextStage();
props.nextStage();
}}
/>
)}
/>
<StepsWizard.Control
num={3}
render={() => (
<Controls text={'Swap Again!'} onPress={() => goHome()} />
<Controls
text={'Swap Again!'}
onPress={() => {
completeSwap();
goHome();
}}
/>
)}
/>
</StepsWizard.Controls>
Expand Down
2 changes: 1 addition & 1 deletion src/views/reverse/reverseReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const reducer = (state = initalState, action) => {
};

case actionTypes.COMPLETE_REVERSE_SWAP:
return initalState;
return { ...initalState };

default:
return state;
Expand Down
9 changes: 7 additions & 2 deletions src/views/swap/swap.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ const Swap = ({
errorAction={() => startSwap(swapInfo, props.nextStage)}
loadingRender={() => <Loading />}
onPress={() => {
completeSwap();
props.nextStage();
}}
/>
Expand All @@ -123,7 +122,13 @@ const Swap = ({
<StepsWizard.Control
num={4}
render={() => (
<Controls text={'Swap Again!'} onPress={() => goHome()} />
<Controls
text={'Swap Again!'}
onPress={() => {
completeSwap();
goHome();
}}
/>
)}
/>
</StepsWizard.Controls>
Expand Down
2 changes: 1 addition & 1 deletion src/views/swap/swapReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const reducer = (state = initalState, action) => {
};

case actionTypes.COMPLETE_SWAP:
return initalState;
return { ...initalState };

default:
return state;
Expand Down

0 comments on commit 168472d

Please sign in to comment.