-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e0c963a
commit a684f58
Showing
15 changed files
with
984 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React, { Component } from "react"; | ||
import { Router } from "react-router-dom"; | ||
import { createBrowserHistory } from "history"; | ||
import { Chart } from "react-chartjs-2"; | ||
import { ThemeProvider } from "@material-ui/styles"; | ||
import validate from "validate.js"; | ||
|
||
import { chartjs } from "./helpers"; | ||
import theme from "./theme"; | ||
import "react-perfect-scrollbar/dist/css/styles.css"; | ||
import "./assets/scss/index.scss"; | ||
import validators from "./common/validators"; | ||
import Routes from "./Routes"; | ||
import { CssBaseline } from "@material-ui/core"; | ||
|
||
//global store | ||
import { StoreProvider } from "./store/store"; | ||
|
||
const browserHistory = createBrowserHistory(); | ||
|
||
Chart.helpers.extend(Chart.elements.Rectangle.prototype, { | ||
draw: chartjs.draw | ||
}); | ||
|
||
validate.validators = { | ||
...validate.validators, | ||
...validators | ||
}; | ||
|
||
export default class App extends Component { | ||
render() { | ||
return ( | ||
<ThemeProvider theme={theme}> | ||
<CssBaseline /> | ||
<StoreProvider> | ||
<Router history={browserHistory}> | ||
<Routes /> | ||
</Router> | ||
</StoreProvider> | ||
</ThemeProvider> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import React from "react"; | ||
import { Switch, Redirect } from "react-router-dom"; | ||
|
||
import { RouteWithLayout } from "./components"; | ||
import { Main as MainLayout, Minimal as MinimalLayout } from "./layouts"; | ||
|
||
import { | ||
Dashboard as DashboardView, | ||
Wallet as WalletView, | ||
Savings as SavingsView, | ||
Investments as InvestmentsView, | ||
RealEstate as RealEstateView, | ||
Gold as GoldView, | ||
SignIn as SignInView, | ||
NotFound as NotFoundView, | ||
PortfolioSelect as PortfolioSelectView, | ||
AssetAllocator as AssetAllocatorView | ||
} from "./views"; | ||
|
||
const Routes = () => { | ||
return ( | ||
<Switch> | ||
<Redirect exact from="/" to="/sign-in" /> | ||
<RouteWithLayout | ||
component={PortfolioSelectView} | ||
exact | ||
layout={MinimalLayout} | ||
path="/select-portfolio" | ||
/> | ||
<RouteWithLayout | ||
component={AssetAllocatorView} | ||
exact | ||
layout={MinimalLayout} | ||
path="/allocate-assets" | ||
/> | ||
<RouteWithLayout | ||
component={DashboardView} | ||
exact | ||
layout={MainLayout} | ||
path="/dashboard" | ||
/> | ||
<RouteWithLayout | ||
component={SavingsView} | ||
exact | ||
layout={MainLayout} | ||
path="/savings" | ||
/> | ||
<RouteWithLayout | ||
component={WalletView} | ||
exact | ||
layout={MainLayout} | ||
path="/wallet" | ||
/> | ||
<RouteWithLayout | ||
component={InvestmentsView} | ||
exact | ||
layout={MainLayout} | ||
path="/investments" | ||
/> | ||
<RouteWithLayout | ||
component={RealEstateView} | ||
exact | ||
layout={MainLayout} | ||
path="/real-estate" | ||
/> | ||
<RouteWithLayout | ||
component={GoldView} | ||
exact | ||
layout={MainLayout} | ||
path="/gold" | ||
/> | ||
<RouteWithLayout | ||
component={DashboardView} | ||
exact | ||
layout={MainLayout} | ||
path="/account" | ||
/> | ||
<RouteWithLayout | ||
component={DashboardView} | ||
exact | ||
layout={MainLayout} | ||
path="/settings" | ||
/> | ||
<RouteWithLayout | ||
component={DashboardView} | ||
exact | ||
layout={MinimalLayout} | ||
path="/sign-up" | ||
/> | ||
<RouteWithLayout | ||
component={SignInView} | ||
exact | ||
layout={MinimalLayout} | ||
path="/sign-in" | ||
/> | ||
<RouteWithLayout | ||
component={NotFoundView} | ||
exact | ||
layout={MinimalLayout} | ||
path="/not-found" | ||
/> | ||
<Redirect to="/not-found" /> | ||
</Switch> | ||
); | ||
}; | ||
|
||
export default Routes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
import * as serviceWorker from './serviceWorker'; | ||
import App from './App'; | ||
|
||
ReactDOM.render(<App />, document.getElementById('root')); | ||
|
||
serviceWorker.unregister(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
// This optional code is used to register a service worker. | ||
// register() is not called by default. | ||
|
||
// This lets the app load faster on subsequent visits in production, and gives | ||
// it offline capabilities. However, it also means that developers (and users) | ||
// will only see deployed updates on subsequent visits to a page, after all the | ||
// existing tabs open on the page have been closed, since previously cached | ||
// resources are updated in the background. | ||
|
||
// To learn more about the benefits of this model and instructions on how to | ||
// opt-in, read http://bit.ly/CRA-PWA | ||
|
||
const isLocalhost = Boolean( | ||
window.location.hostname === 'localhost' || | ||
// [::1] is the IPv6 localhost address. | ||
window.location.hostname === '[::1]' || | ||
// 127.0.0.1/8 is considered localhost for IPv4. | ||
window.location.hostname.match( | ||
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ | ||
) | ||
); | ||
|
||
export function register(config) { | ||
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { | ||
// The URL constructor is available in all browsers that support SW. | ||
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href); | ||
if (publicUrl.origin !== window.location.origin) { | ||
// Our service worker won't work if PUBLIC_URL is on a different origin | ||
// from what our page is served on. This might happen if a CDN is used to | ||
// serve assets; see https://github.com/facebook/create-react-app/issues/2374 | ||
return; | ||
} | ||
|
||
window.addEventListener('load', () => { | ||
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; | ||
|
||
if (isLocalhost) { | ||
// This is running on localhost. Let's check if a service worker still exists or not. | ||
checkValidServiceWorker(swUrl, config); | ||
|
||
// Add some additional logging to localhost, pointing developers to the | ||
// service worker/PWA documentation. | ||
navigator.serviceWorker.ready.then(() => { | ||
console.log( | ||
'This web app is being served cache-first by a service ' + | ||
'worker. To learn more, visit http://bit.ly/CRA-PWA' | ||
); | ||
}); | ||
} else { | ||
// Is not localhost. Just register service worker | ||
registerValidSW(swUrl, config); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
function registerValidSW(swUrl, config) { | ||
navigator.serviceWorker | ||
.register(swUrl) | ||
.then(registration => { | ||
registration.onupdatefound = () => { | ||
const installingWorker = registration.installing; | ||
if (installingWorker == null) { | ||
return; | ||
} | ||
installingWorker.onstatechange = () => { | ||
if (installingWorker.state === 'installed') { | ||
if (navigator.serviceWorker.controller) { | ||
// At this point, the updated precached content has been fetched, | ||
// but the previous service worker will still serve the older | ||
// content until all client tabs are closed. | ||
console.log( | ||
'New content is available and will be used when all ' + | ||
'tabs for this page are closed. See http://bit.ly/CRA-PWA.' | ||
); | ||
|
||
// Execute callback | ||
if (config && config.onUpdate) { | ||
config.onUpdate(registration); | ||
} | ||
} else { | ||
// At this point, everything has been precached. | ||
// It's the perfect time to display a | ||
// "Content is cached for offline use." message. | ||
console.log('Content is cached for offline use.'); | ||
|
||
// Execute callback | ||
if (config && config.onSuccess) { | ||
config.onSuccess(registration); | ||
} | ||
} | ||
} | ||
}; | ||
}; | ||
}) | ||
.catch(error => { | ||
console.error('Error during service worker registration:', error); | ||
}); | ||
} | ||
|
||
function checkValidServiceWorker(swUrl, config) { | ||
// Check if the service worker can be found. If it can't reload the page. | ||
fetch(swUrl) | ||
.then(response => { | ||
// Ensure service worker exists, and that we really are getting a JS file. | ||
const contentType = response.headers.get('content-type'); | ||
if ( | ||
response.status === 404 || | ||
(contentType != null && contentType.indexOf('javascript') === -1) | ||
) { | ||
// No service worker found. Probably a different app. Reload the page. | ||
navigator.serviceWorker.ready.then(registration => { | ||
registration.unregister().then(() => { | ||
window.location.reload(); | ||
}); | ||
}); | ||
} else { | ||
// Service worker found. Proceed as normal. | ||
registerValidSW(swUrl, config); | ||
} | ||
}) | ||
.catch(() => { | ||
console.log( | ||
'No internet connection found. App is running in offline mode.' | ||
); | ||
}); | ||
} | ||
|
||
export function unregister() { | ||
if ('serviceWorker' in navigator) { | ||
navigator.serviceWorker.ready.then(registration => { | ||
registration.unregister(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from "react"; | ||
import { Heading, Text, Modal, Flex, Box, Loader } from "rimble-ui"; | ||
import ModalCard from "./ModalCard"; | ||
import { useStore } from "../../store/store"; | ||
|
||
const ConnectionPendingModal = (props) => { | ||
const { state, dispatch } = useStore(); | ||
let modals = state.modals; | ||
|
||
const closeModal = () => { | ||
modals.connectionPending = false; | ||
dispatch({ type: "setModals", modals }); | ||
}; | ||
|
||
const renderContent = () => { | ||
return ( | ||
<React.Fragment> | ||
<Heading.h2 my={3}>Connect your wallet</Heading.h2> | ||
|
||
<Text my={4}>Confirm the request from your {state.wallet} wallet</Text> | ||
|
||
<Box bg={"#f6f6fc"} p={3} display={["none", "block"]}> | ||
<Flex alignItems={"center"}> | ||
<Box position={"relative"} width={"4em"}> | ||
<Box> | ||
<Loader size={"3em"} /> | ||
</Box> | ||
</Box> | ||
<Box> | ||
<Text fontWeight={4}>Waiting for connection confirmation...</Text> | ||
<Text fontWeight={2}>This won’t cost you any Ether</Text> | ||
</Box> | ||
</Flex> | ||
</Box> | ||
</React.Fragment> | ||
); | ||
}; | ||
|
||
return ( | ||
<Modal isOpen={modals.connectionPending}> | ||
<ModalCard closeFunc={closeModal}> | ||
<ModalCard.Body>{renderContent()}</ModalCard.Body> | ||
</ModalCard> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default ConnectionPendingModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React, { useState } from "react"; | ||
import { Heading, Text, Modal, Flex, Box, Loader } from "rimble-ui"; | ||
import ModalCard from "./ModalCard"; | ||
import { useStore } from "../../store/store"; | ||
|
||
const LoadingsAssetsModal = props => { | ||
const { dispatch } = useStore(); | ||
const [modalOpen, setModalOpen] = useState(true); | ||
|
||
const closeModal = () => { | ||
setModalOpen(false); | ||
dispatch({ type: "disconnect" }); | ||
}; | ||
|
||
const renderContent = () => { | ||
return ( | ||
<React.Fragment> | ||
<Heading.h2 my={3}>Loading your assets</Heading.h2> | ||
|
||
<Text my={4}>We are reading your different assets from blockchain</Text> | ||
|
||
<Box bg={"#f6f6fc"} p={3} display={["none", "block"]}> | ||
<Flex alignItems={"center"}> | ||
<Box position={"relative"} width={"4em"}> | ||
<Box> | ||
<Loader size={"3em"} /> | ||
</Box> | ||
</Box> | ||
<Box> | ||
<Text fontWeight={4}>This might take a few seconds...</Text> | ||
</Box> | ||
</Flex> | ||
</Box> | ||
</React.Fragment> | ||
); | ||
}; | ||
|
||
return ( | ||
<Modal isOpen={modalOpen}> | ||
<ModalCard closeFunc={closeModal}> | ||
<ModalCard.Body>{renderContent()}</ModalCard.Body> | ||
</ModalCard> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default LoadingsAssetsModal; |
Oops, something went wrong.