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

Commit

Permalink
feat: show error when requests on landing page fail
Browse files Browse the repository at this point in the history
  • Loading branch information
michael1011 committed Feb 18, 2019
1 parent 5fede40 commit df7b433
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 26 deletions.
19 changes: 13 additions & 6 deletions src/views/landingpage/landingpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@ const styles = theme => ({
},
},
loading: {
justifyContent: 'center',
alignItems: 'center',
height: '400px',
width: '600px',
height: '400px',
display: 'flex',
alignItems: 'center',
alignContent: 'center',
flexDirection: 'column',
justifyContent: 'center',
backgroundColor: theme.colors.white,
'@media (min-width: 1500px)': {
width: '800px',
Expand All @@ -51,6 +54,11 @@ const styles = theme => ({
loadingLogo: {
width: '200px',
height: '200px',
display: 'block',
marginBottom: '10px',
},
loadingText: {
fontSize: '20px',
},
});

Expand Down Expand Up @@ -121,12 +129,11 @@ class LandingPage extends React.Component {
Object.keys(limits).length === 0 ? (
<View className={classes.loading}>
<img
alt="logo"
src={boltz_logo}
height={100}
width={100}
className={classes.loadingLogo}
alt="logo"
/>
<p className={classes.loadingText}>Loading...</p>
</View>
) : (
<SwapTab
Expand Down
49 changes: 29 additions & 20 deletions src/views/landingpage/landingpageActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,24 @@ export const getPairs = cb => {

return dispatch => {
dispatch(pairsRequest());
axios.get(url).then(response => {
const rates = parseRates(response.data);
const currencies = parseCurrencies(response.data);

dispatch(
pairsResponse({
rates,
currencies,
})
);

cb();
});
axios
.get(url)
.then(response => {
const rates = parseRates(response.data);
const currencies = parseCurrencies(response.data);

dispatch(
pairsResponse({
rates,
currencies,
})
);

cb();
})
.catch(error => {
window.alert(`Could not get rates: ${error}`);
});
};
};

Expand Down Expand Up @@ -128,12 +133,16 @@ export const getLimits = (rates, cb) => {

return dispatch => {
dispatch(limitsRequest());
axios.get(url).then(response => {
const limits = parseLimits(rates, response.data);

dispatch(limitsResponse(limits));

cb();
});
axios
.get(url)
.then(response => {
const limits = parseLimits(rates, response.data);
dispatch(limitsResponse(limits));

cb();
})
.catch(error => {
window.alert(`Could not get limits: ${error}`);
});
};
};

0 comments on commit df7b433

Please sign in to comment.